A question for a guru.
I was having some trouble using SendMessage to send a message to a modeless dialog box.
my dialog procedure is:
DlgProc PROC _hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM

within this i have:

.elseif iMsg==MM_BUGDIALOG
...do something...

whats the difference between these two invoke statements:

1.) invoke DlgProc, DlgHndl, MM_BUGDIALOG, NULL, NULL
2.) invoke SendMessage,DlgHndl,MM_BUGDIALOG,NULL,NULL

SendMessage works now but i'm wondering what the difference is if any. does SendMessage just look up the window procedure for the given handle and eventually call the first invoke anyway? i guess my question is: if my window were sending itself repeated messages for example, an animation, is there a speed saving in using the first over the second or is it just bad programming practice or is there an even faster way of doing things like having a seperate procedure containing only the specific animation code to save the program having to drop through all those elseifs? sorry if this doesn't make sense. i'm going to sleep now and i'll check back here tomorrow.
Posted on 2003-03-15 09:40:33 by Crunchi
When you send a message to a procedure the mouse position and time it was received is available as well. They can be accessed using GetMessagePos and GetMessageTime respectively. This may not seem too important normally but in a clock intensive or multi-threaded application it can be critical to know the exact conditions under which the message was received and not the conditions at the time it is executed. Another alternative to the SendMessage API is PostMessage which also does not bypass the message queue but it returns immediately after the message is placed in the queue unlike SendMessage which waits for a return value. Also keyboard input must be properly formatted with the TranslateMessage function, this would not be available if you bypass the message loop.

Posted on 2003-03-15 10:19:13 by donkey
Another (imo much more important) difference is that using SendMessage ensures no two threads can call the wndproc at the same time. This way you don't need to worry about synchronization (mutexes etc.) for your data.

Posted on 2003-03-15 10:20:59 by Thomas
thanks, this site has been my only teacher, i have no experience with dos assembly and until not too long ago my ENTIRE experience with any assembler was with PDP8 for a few projects at uni. i'm starting to get my head around this now but expect alot more newbie Q's before i'm through.
Posted on 2003-03-16 08:40:09 by Crunchi