The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bloodhound on April 23, 2006, 06:26:12 AM

Title: Own/User defined Icon on Messagebox
Post by: bloodhound on April 23, 2006, 06:26:12 AM
how do you do this?? instead of ICON_INFORMATION, etc etc..
you load your own icon on the messagebox

or you just create a child window?
Title: Re: Own/User defined Icon on Messagebox
Post by: hutch-- on April 23, 2006, 06:51:54 AM
Can't be done in a normal message box. Give the following code a blast, you can set your own icon this way.


; ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤

MessageBoxI proc hParent:DWORD,lpMsg:DWORD,
             lpTitle:DWORD,dlgStyle:DWORD,iconID:DWORD

    LOCAL mbp:MSGBOXPARAMS

    mov mbp.cbSize, SIZEOF MSGBOXPARAMS
    mov eax, hParent
    mov mbp.hwndOwner, eax
    mov eax, hInstance
    mov mbp.hInstance, eax
    mov eax, lpMsg
    mov mbp.lpszText, eax
    mov eax, lpTitle
    mov mbp.lpszCaption, eax
    mov eax, dlgStyle
    or eax, MB_USERICON
    mov mbp.dwStyle, eax
    mov eax, iconID
    mov mbp.lpszIcon, eax
    mov mbp.dwContextHelpId, NULL
    mov mbp.lpfnMsgBoxCallback, NULL
    mov mbp.dwLanguageId, NULL

    invoke MessageBoxIndirect,ADDR mbp

    ret

MessageBoxI endp

; ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤
Title: Re: Own/User defined Icon on Messagebox
Post by: bloodhound on April 23, 2006, 07:04:22 AM
Thanks hutch-- ,will try it  :U
Title: Re: Own/User defined Icon on Messagebox
Post by: Vortex on April 23, 2006, 09:15:34 AM
Hutch, you should add this procedure to masm32.lib :U
Title: Re: Own/User defined Icon on Messagebox
Post by: hutch-- on April 23, 2006, 10:39:56 AM
Erol,

I was supposed to, I just forgot.  ::)
Title: Re: Own/User defined Icon on Messagebox
Post by: Vortex on April 23, 2006, 06:35:48 PM
Hutch,

I added the missing hInstance parameter to your procedure :

MessageBoxI PROC hInstance:DWORD,hParent:DWORD,lpMsg:DWORD,lpTitle:DWORD,\
                 dlgStyle:DWORD,iconID:DWORD


Attached is a quick example.

[attachment deleted by admin]
Title: Re: Own/User defined Icon on Messagebox
Post by: bloodhound on April 25, 2006, 06:31:12 AM
Thanks Vortex!  :U
Title: Re: Own/User defined Icon on Messagebox
Post by: hutch-- on April 25, 2006, 08:04:07 AM
Vortex is right, I normally set hInstance as a global but it should properly be self contained so it remains as close as possible to the normal MesageBox API call. I have attached a simple demo on how it works with the minor change.

[attachment deleted by admin]