c.haslam

GuiRegisterMsg() and WM_COMMAND

5 posts in this topic

#1 ·  Posted

My script (script A) has a main dialog that detects double-clicking on an image by using Melba23's code, which includes registering function MY_WM_COMMAND and checking for an STN_DBLCLK on the image. This works well.

I have written another script (script B) that has a list box in a dialog. This script detects double-clicking on a list box item. It includes registering function MY_OTHER_WM_COMMAND and checking for $LBN_DBLCLK. It too works well.

Now I want to integrate the dialog function in script B with script A: when a button in script A is clicked, the list-box dialog function  will run.

There are several other dialogs in script A that don't need WM_COMMAND.

Now my questions:

  • How do I combine the 2 WM_COMMAND functions, or do I have 2 WM_COMMAND functions?
  • Do I make one call to GUIRegisterMsg() for the whole script?
  • Do I call GUIRegisterMsg() with the second parameter as "" before switching to the list-box dialog?

 


...chris

Share this post


Link to post
Share on other sites



#2 ·  Posted

In a registered user function like _WM_COMMAND(), you can specify which GUI, which notification message has been sent, and which control identification (id) was used.

Note in Siao's Magnifier Tool, there are two Windows Messages registered to call the same  user function.

#include <GUIConstants.au3>
#include <WinApi.au3>

GUIRegisterMsg($WM_COMMAND, _WM_COMMAND)
;...


; Assuming 2 different GUI's -  $hGUI1 has an image control, and $hGUI2 has a list box control
Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

    If $hWnd = $hGUI1 And _WinAPI_HiWord($wParam) = $LBN_DBLCLK And _WinAPI_LoWord($wParam) = $idImage Then
        ;.....
    EndIf
    ; "_WinAPI_HiWord($wParam)" same as "BitShift($wParam, 16)"; and,  "_WinAPI_LoWord($wParam)" same as "BitAND($wParam, 0xFFFF)"
    If $hWnd = $hGUI2 And BitShift($wParam, 16) = $LBN_DBLCLK And BitAND($wParam, 0xFFFF) = $idListBox Then
        ;.....
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>_WM_COMMAND

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thank you for clarifying my thinking!

I was forgetting that the handle of the GUI, what GuiCreate() returns, is available in the user function.

I had one surprise: Return "GUI_RUNDEFMSG". Does this do the same as Return $GUI_RUNDEFMSG ? (Return $GUI_RUNDEFMSG is in the Help for GUIRegisterMsg.)


...chris

Share this post


Link to post
Share on other sites

#4 ·  Posted

5 hours ago, c.haslam said:

....

I had one surprise: Return "GUI_RUNDEFMSG". Does this do the same as Return $GUI_RUNDEFMSG ? ....

Yes, in  the include file GUIConstantsEx.au3, you will find Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'.

Share this post


Link to post
Share on other sites

#5 ·  Posted

Now I know. Thanks.


...chris

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now