News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SendMessage returned value...

Started by jdoe, November 29, 2007, 02:26:08 AM

Previous topic - Next topic

jdoe

Hi,

I'll try to make my question clear. I have a DialogProc (for DialogBoxParam) that start a thread proc when a button is clicked. That DialogProc process a custom message WM_APP_INIT that is called (SendMessage, hWndDlg, WM_APP_INIT, NULL, NULL) from the new thread proc created. The WM_APP_INIT message move a value in EAX and returns. The SendMessage is supposed to return when completed but in my thread proc, the value I have set in EAX is always zero. So I have to conclude that between the WM_APP_INIT returns and when the thread proc reads the value of EAX, some more APIs are processed.

Is there a way to process a custom message from a DialogProc and get the returned value in the calling thread. Some links about that would be appreciated.


evlncrn8

SetWindowLong....

DWL_MSGRESULT   Sets the return value of a message processed in the dialog box procedure.

push your_special_return_value
push DWL_MSGRESULT
push windowhandle
call SetWindowLong

should do the trick :)

Shantanu Gadgil

QuoteThe WM_APP_INIT message move a value in EAX and returns.
A DlgProc returns only TRUE or FALSE right ? ("return" here is through EAX )

Note: Returning TRUE after the SetWindowLong seems to be important !!!

Ref: http://msdn2.microsoft.com/en-us/library/ms645469.aspx

Quote
    Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message.

    If the dialog box procedure processes a message that requires a specific return value, the dialog box procedure should set the desired return value by calling SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult) immediately before returning TRUE. Note that you must call SetWindowLong immediately before returning TRUE; doing so earlier may result in the DWL_MSGRESULT value being overwritten by a nested dialog box message.

Regards,
Shantanu
To ret is human, to jmp divine!

jj2007

Is your WM_APP_INIT a private message registered with RegisterWindowMessage? If not, is it in the right range, i.e. 0x8000 through 0xBFFF ?

jdoe


I was already using SetWindowLong with GWL_USERDATA but I didn't thought about DWL_MSGRESULT.

Sometimes, it is good to read again the documentation that was read in the past. What was skipped at first read can be important the second time.
I will take advice from that.

Thank you all.


sinsi

Quote from: jdoe on November 29, 2007, 02:59:33 PM
Sometimes, it is good to read again the documentation that was read in the past. What was skipped at first read can be important the second time.
I hear you, brother  :'(

Don't forget that wparam and lparam can point to a thread-local variable (can't they?)


P.S. Your avatar freaks me out when it blinks...heh heh  :8)
Light travels faster than sound, that's why some people seem bright until you hear them.

jdoe

#6
Quote from: sinsi on November 30, 2007, 09:57:43 AM
Don't forget that wparam and lparam can point to a thread-local variable (can't they?)

I don't see why it couldn't as long as SendMessage is used and not another send message function that returns immediatly. In that case, the thread-local variable may not exist anymore when used by the other proc.

Quote from: sinsi on November 30, 2007, 09:57:43 AM
P.S. Your avatar freaks me out when it blinks...heh heh  :8)

When I played with Macromedia Fireworks few years ago, I made this gif starting with a jpeg, adding a 3d look and making the blinks animation. I hate playing with picture but I had time to lose at that time I guess.