The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bawrobin on March 23, 2010, 07:14:04 AM

Title: How to open two and more MsgBox(s)
Post by: bawrobin on March 23, 2010, 07:14:04 AM
Hello.
I am a newbie.
In my program I have a code:


    invoke  wsprintf,ADDR buffer,ADDR MsgText,ebx
    invoke  MessageBox,0,ADDR buffer,ADDR MsgTitle,MB_OK
    invoke  ExitProcess,0



This code open a window with MB_OK.
Please tell me how I can open one more window when running a program ?

Thank you.
Title: Re: How to open two and more MsgBox(s)
Post by: bawrobin on March 23, 2010, 07:28:53 AM
And if you can please tell me where I can read full description of MessageBox ?

For example, there is no descrpition in: http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/

May be you can suggest a site where I can view function descriptions ?
I tried to find it at msdn.microsoft.com but I failed. May be you can show a link or something.
I think it would be interesting to all newbies. Thank you.
Title: Re: How to open two and more MsgBox(s)
Post by: MichaelW on March 23, 2010, 07:46:51 AM
As far as I know all message boxes are modal dialogs, so an app cannot open more than one because the app that opened the message box is disabled until the message box is closed. One (possibly too difficult) way to get around this limitation would be to create your own message box as a modeless dialog.

MSDN: MessageBox Function (http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx)

MSDN: About Dialog Boxes (http://msdn.microsoft.com/en-us/library/ms644994(v=VS.85).aspx)

MSDN: Using Dialog Boxes (http://msdn.microsoft.com/en-us/library/ms644996(VS.85).aspx)


Title: Re: How to open two and more MsgBox(s)
Post by: bawrobin on March 23, 2010, 10:04:49 AM
Thank you
Title: Re: How to open two and more MsgBox(s)
Post by: Slugsnack on March 23, 2010, 10:37:38 AM
You could potentially make a MessageBox appear modeless by putting the call in a procedure then creating a new thread there each time you want to make one appear.
Title: Re: How to open two and more MsgBox(s)
Post by: hutch-- on March 23, 2010, 02:16:07 PM
Yep, threads are the way to do it.
Title: Re: How to open two and more MsgBox(s)
Post by: MichaelW on March 23, 2010, 05:41:21 PM
I wasn't thinking too well when I replied. The modal/modeless behavior depends on the message box (or any other modal dialog) having an owner window. If the message box has an owner window then that window will be disabled until the message box is closed. If the message box has no owner window then it will operate independently of the app that opened it. So if you specify 0 for the hWnd parameter then you can open multiple message boxes. The problem with this method is that the message boxes will not be automatically closed when the owner window is closed. A modeless message box with an owner window would not disable the owner window, so it could create multiple message boxes, but closing the owner window would cause the system to automatically close all of the message boxes it owned. The attachment contains an example that shows the effect for a normal message box.
Title: Re: How to open two and more MsgBox(s)
Post by: RotateRight on March 24, 2010, 02:29:14 AM
[]