What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Alert(MsgBox in VB) Help?

Alert(MsgBox in VB) Help?
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Alert(MsgBox in VB) Help?
With all due respect (so don't get me wrong), but I'm not certain if such scripts should be accepted in the database.

Reason: poorly written. So why not including it:
1) People who know how to script will also know how to do this simple function for themselfs.
2) People who do not know how to script (and want to learn scripting by looking at such simple scripts) will not learn proper formatting their scripts or why something is done, etc...

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{


var Val=Interop.Call("User32.dll", "MessageBoxW", 0,"Are you sure, you want to send:" + Message,"Sure?", 4|32);

if (Val==6) { // Yes
    // ....
}
else if (Val==7) { // No
  return "";
}

}


Instead of submitting something like the above, submit something like:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    If (Interop.Call("User32.dll", "MessageBoxW", ChatWnd.Handle, "Are you sure you want to send:\n" + Message, "Confirm", 36) === 7) return "";
}
Look at the above 1-line script and understand why this can be on one simple line. If you knew this you would have done something like this already and submitted that. If not, this proofs my point that scripts written like yours shouldn't be accepted as they don't teach much (if not teaching bad habits and what not).

---

Or, if you want to submit such a script and teach/help out other people who might want to learn something:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
        // Define constants to make up the message box
        var MB_ICONQUESTION = 32;
        var MB_YESNO = 4;

        // Define constants which can be returned
        var IDYES = 6;
        var IDNO = 7;

        // Show confirmation box
        // Note: We attached the chat window handle (ChatWnd.Handle) to make this message box a child of the chat window.
        //       In that way, you can't use the chat window any further until the message box is answered.
        // Note: We define a YES/NO message box (MB_YESNO) and show a question icon (MB_ICONQUESTION) by binary adding the constants with the OR function.
        var Result = Interop.Call("User32.dll", "MessageBoxW", ChatWnd.Handle, "Are you sure you want to send:\n" + Message, "Confirm", MB_YESNO | MB_ICONQUESTION);
   
        // Check the returned result
        switch(Result) {
                // User pressed 'yes', so simply return without doing anything
                case IDYES: return;
                // User pressed 'no', so return the new message being an empty string; nothing will be send
                case IDNO: return "";
        }
}
// More info in the MSDN Library:
//http://search.msdn.microsoft.com/search/Redirect.aspx?title=MessageBox+Function&url=http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messagebox.asp


---

So, I hope you don't take anything of this post offensive. It is just that I sometimes question the stuff in the database (yours was just an example). Although I have no doubt what-so-ever about the good intentions of the creators, the quality is important too.

;)

This post was edited on 08-22-2006 at 04:03 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-22-2006 04:01 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Alert(MsgBox in VB) Help? - by Hit on 08-21-2006 at 05:48 PM
RE: Alert(MsgBox in VB) Help? - by Eljay on 08-21-2006 at 05:58 PM
RE: Alert(MsgBox in VB) Help? - by KnRd_WC on 08-21-2006 at 06:05 PM
RE: Alert(MsgBox in VB) Help? - by Hit on 08-21-2006 at 06:14 PM
RE: Alert(MsgBox in VB) Help? - by KnRd_WC on 08-21-2006 at 06:19 PM
RE: Alert(MsgBox in VB) Help? - by Hit on 08-21-2006 at 06:28 PM
RE: RE: Alert(MsgBox in VB) Help? - by KnRd_WC on 08-21-2006 at 06:34 PM
RE: Alert(MsgBox in VB) Help? - by Matti on 08-21-2006 at 06:38 PM
RE: Alert(MsgBox in VB) Help? - by Hit on 08-21-2006 at 06:43 PM
RE: Alert(MsgBox in VB) Help? - by Matti on 08-21-2006 at 06:57 PM
RE: RE: Alert(MsgBox in VB) Help? - by CookieRevised on 08-22-2006 at 08:00 AM
RE: RE: RE: Alert(MsgBox in VB) Help? - by Hit on 08-22-2006 at 11:21 AM
RE: Alert(MsgBox in VB) Help? - by Hit on 08-21-2006 at 07:06 PM
RE: Alert(MsgBox in VB) Help? - by KnRd_WC on 08-21-2006 at 08:08 PM
RE: Alert(MsgBox in VB) Help? - by Hit on 08-21-2006 at 08:15 PM
RE: Alert(MsgBox in VB) Help? - by KnRd_WC on 08-21-2006 at 08:20 PM
RE: Alert(MsgBox in VB) Help? - by KnRd_WC on 08-22-2006 at 10:01 AM
RE: Alert(MsgBox in VB) Help? - by RaceProUK on 08-22-2006 at 10:24 AM
RE: Alert(MsgBox in VB) Help? - by -dt- on 08-22-2006 at 10:26 AM
RE: Alert(MsgBox in VB) Help? - by CookieRevised on 08-22-2006 at 04:01 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On