I have this MessageBox, and I wan't my own icon on the titlebar.
I have done this several times before, but not with the MessageBox api.
The minimized icon and alt+tab icon works ok.

What have I missed here :confused:
Posted on 2004-06-03 13:22:49 by The SharK


use MessageBoxIndirect, with
mov mbp.lpszIcon,eax ; loaded icon...
mov mbp.dwStyle, MB_OK or [b]MB_USERICON[/b]
Posted on 2004-06-03 14:13:39 by Ultrano
oh, that's why :)


Thanks Ultrano :alright:
Posted on 2004-06-03 14:42:00 by The SharK
Hi the Shark,

The MessageBoxIndirect function just displays that in the icon-box not in the caption, I thought you wanted it in the caption ?
Posted on 2004-06-03 15:06:54 by donkey
you're right donkey,
I wanted the icon in the titlebar.....

So what can I do about it then....:(
Posted on 2004-06-03 15:11:10 by The SharK
As far as I can tell you will have to make your own dialog and have it act like a message box, I could not find a way to do it with a standard message box.
Posted on 2004-06-03 15:24:51 by donkey
okay, so I'll just keep it as it is, thanks anyway :)
Posted on 2004-06-03 15:44:10 by The SharK
Hmm, I know of a way to do this with the standard MessageBox.

Its a little unorthodox, but I dont think I will have that much trouble
drumming up a demo or code snip or something. I dont have the
time right now (taking kids to the park), but gimme about three hours
and I will see if I can locate the base code...
Posted on 2004-06-03 18:28:06 by Graebel
Ok as promised, here ya go. Full example :cool:
Just left click anywhere in the client area to get a new message box...

For the most part it should be self explanitory, but if you have any questions
about it just let me know
Posted on 2004-06-03 22:00:55 by Graebel
Crud, just realized I was sending a file chop full of macros most people wouldnt
have. Modified the file so everyone would be able to re-compile it... my bad
Posted on 2004-06-03 22:32:19 by Graebel
Hi Graebel

Thanks for the example,
but you use CreateWindowEx.
As I mentioned I have done this several times before, using
other api's, but I was looking for a way to make use of
the MessageBox or the like api.

But what the heck, it's no big deal.


Thanks anyway ;)
Posted on 2004-06-04 10:27:13 by The SharK
I just glanced at his code, but didn't he use createwindowex for the main window and MessageBox (or maybe it was MessageBoxEx) for the message box? It looked like he did a cbt hook and changed the icon from the MessageBox that way. Unless I'm crazy I don't see what the problem is.
Posted on 2004-06-04 11:56:45 by Will
Unless I'm crazy I don't see what the problem is


Hi Will

Seems I was to quick in judging the code.
You're right, it seems like you have got the
"picture" of his code - at least I guess.
My problem was/is, that I didn't/don't quite understand
everything in the Template example, so I guess
I have to study it a little closer :notsure:

Sorry for that :(
And Will - You're NOT crazy :tongue:


Hi Graebel,

Your skill in Win32Asm is beyond me, so I'M the apprentice here :alright:
Posted on 2004-06-04 12:16:58 by The SharK
basically that example isn't too complicated (although it may look it at first)....

;)



invoke SetWindowsHookEx, WH_CBT, ADDR CBTProc, hInstance, 0
mov hHook, eax
invoke MessageBox, hWnd, ADDR szDisplayName, ADDR szDisplayName, MB_OK


When left mouse button is pressed, this code gets called. You just start a cbt hook and then call MessageBox function. The cbt hook proc then loads the IDI_ASTERISK system icon, subclasses the messagebox, and sets the new icon with a WM_SETICON message. Then the hook is unloaded.


hope that helps,
will
Posted on 2004-06-04 18:25:27 by Will
There's a lot easier way, you just need at least one window with the default class (any dialog box will do). All you have to do is change the small icon for the default class. (Of course this will affect all message boxes and most dialogs in your process). For a small app you might find it useful. :)
Posted on 2004-06-07 17:38:43 by QvasiModo
Hi QvasiModo

you mean changing the small icon in the WNDCLASSEX: HICON hIconSm
with my own.

So I have to Register the WNDCLASSEX first, then create a main window,
with the hIconSm changed, and then create the MessageBox ?
Posted on 2004-06-07 17:49:36 by The SharK
If you create your main window using a custom class, you'll not be affecting message boxes at all! I meant to change the default class :)

Message boxes are supposed to be of the same class than dialog boxes. If your app has a dialog box as it's main window, just change the hIconSm using the SetClassLong API. This will also affect other dialogs in your app, like the "open file" dialog (GetOpenFileName).

The trick won't work if the dialog box has a custom class, or if you use CreateWindowEx with your own class. If you must use CreateWindowEx, you have to use the default class. I don't remember it's name right now but it should be trivial to write a test program to find out.
Posted on 2004-06-09 15:06:28 by QvasiModo