Jump to content
Sign in to follow this  
mistersquirrle

[Solved] GUIRegisterMsg Conflicts

Recommended Posts

mistersquirrle

I'm making a little chat client, and I'm using Melbas GUIFrame ().

I want it, so that when I re-size the window (with min/max sizes) it re-sizes the input and history boxes to match the new window size. That's working fine with re-sizing the whole GUI (using GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")), but when I try to move the frame separator bar, the history box (since it's made with _GUICtrlRichEdit instead of GUICtrlEdit) doesn't update until after you're finished moving the separator.

Using the other GUIRegisterMsg, the history edit re-sizes instantly as you move the separator bar, but the other controls in the window don't change at all.

Using both at once causes only the second one to work.

Is there a way to have both things happen (re-size edits on window and separator bar re-size)?

#include <GUIRichEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <GUIEdit.Au3>
#include "GUIFrame.au3"
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $GUIMINWID = 300, $GUIMINHT = 100 ;Min window sizes
Local $GUIMAXWID = @DesktopWidth, $GUIMAXHT = @DesktopHeight ;Max window sizes

$hGUI = GUICreate('MEOW', 500, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

$iFrames = _GUIFrame_Create($hGUI, 0, 200) ;Creation of the two GUI frames
_GUIFrame_ResizeSet(0, 1) ;Required for proper resizing
_GUIFrame_ResizeReg() ;Required for proper resizing
_GUIFrame_SetMin($iFrames, 150, 200, True) ;Set frame min size
_GUIFrame_Switch($iFrames, 2) ;Switch to second frame to create controls

$History = _GUICtrlRichEdit_Create(_GUIFrame_Switch($iFrames, 2), 'adsfadsfasdf', 2, 2, 263, 255)
$Input = GUICtrlCreateEdit('', 2, 272, 293, 20, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 400, 0, "Courier New")
GUICtrlSetResizing(-1, 582) ;Resizing parameters


GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
;~ GUIRegisterMsg($WM_SIZE, "WM_SIZE")


$SepPos = _GUIFrame_GetSepPos($iFrames) ;Get the seperator bars current position

While 1
    Sleep(10)

    If $SepPos <> _GUIFrame_GetSepPos($iFrames) Then History_Resize()

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($History)
            Exit
    EndSwitch
WEnd

Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X
    DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y
    DllStructSetData($tagMaxinfo, 9, $GUIMAXWID); max X
    DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y
    History_Resize()
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO

Func WM_SIZE($hwnd, $iMsg, $wParam, $lParam)
    History_Resize()
EndFunc   ;==>WM_SIZE

Func History_Resize()
    $SepPos = _GUIFrame_GetSepPos($iFrames)
    $hGpos = WinGetPos($hGUI)
    $iPos = ControlGetPos($hGUI, '', 'Edit1')
    _WinAPI_MoveWindow($History, 2, 2, ($hGpos[2] - $SepPos) - 50, $hGpos[3] - $iPos[3] - 55, False)
EndFunc   ;==>History_Resize
Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites
Melba23

mistersquirrle,

Easy! :)

Just run the resizing function inside your own message handler and call the UDF handle from there:

#include <GUIRichEdit.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <GUIEdit.Au3>
#include "GUIFrame.au3"
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $GUIMINWID = 300, $GUIMINHT = 100 ;Min window sizes
Local $GUIMAXWID = @DesktopWidth, $GUIMAXHT = @DesktopHeight ;Max window sizes

$hGUI = GUICreate('MEOW', 500, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

$iFrames = _GUIFrame_Create($hGUI, 0, 200) ;Creation of the two GUI frames
_GUIFrame_ResizeSet(0, 1) ;Required for proper resizing
;_GUIFrame_ResizeReg() ;Required for proper resizing ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Do not use this
_GUIFrame_SetMin($iFrames, 150, 200, True) ;Set frame min size
_GUIFrame_Switch($iFrames, 2) ;Switch to second frame to create controls
Global $hWinHandle = _GUIFrame_GetHandle($iFrames, 2)

$History = _GUICtrlRichEdit_Create(_GUIFrame_Switch($iFrames, 2), 'adsfadsfasdf', 2, 2, 263, 255)

$Input = GUICtrlCreateEdit('', 2, 272, 293, 20, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 10, 400, 0, "Courier New")
GUICtrlSetResizing(-1, 582) ;Resizing parameters

GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
GUIRegisterMsg($WM_SIZE, "WM_SIZE") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Do this instead

While 1
    Sleep(10) ; Not needed if you use GUIGetMsg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($History)
            Exit
    EndSwitch
WEnd

Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    If $hwnd = $hGUI Then ; Check it is the main GUI
        $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X
        DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y
        DllStructSetData($tagMaxinfo, 9, $GUIMAXWID); max X
        DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y
        History_Resize() ; Resize richedit
    EndIf
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO

Func WM_SIZE($hwnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Here we resize the richedit if required
    _GUIFrame_SIZE_Handler($hwnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< But also call the UDF handler
    If $hwnd = $hWinHandle Then ; Check it is the frame being resized
        History_Resize() ; Resize richedit
    EndIf
EndFunc   ;==>WM_SIZE

Func History_Resize()
    $SepPos = _GUIFrame_GetSepPos($iFrames)
    $hGpos = WinGetPos($hGUI)
    $iPos = ControlGetPos($hGUI, '', 'Edit1')
    _WinAPI_MoveWindow($History, 2, 2, ($hGpos[2] - $SepPos) - 50, $hGpos[3] - $iPos[3] - 55, False)
EndFunc   ;==>History_Resize

All clear? :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
mistersquirrle

Ahh, indeed, that works. I remember even reading that while looking at your UDF, not to use the ResizeReg and WM_SIZE together. I just forgot, and I probably wouldn't have known quite how to use it anyway. :P

For the most part, I get that.

I just found a little bug with resizing things when the system (Windows 7 32-bit) doesn't have the "Show window contents while dragging" (System Properies -> Advanced -> Performance -> Visual Effects). When you resize the window, the history edit doesn't resize instantly. It doesn't get repainted until you click to start resizing again, move the window, or move the separator bar. Any thoughts on this?


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites
Melba23

mistersquirrle,

Yes, tick the "Show window contents while dragging" box. ;)

Seriously, if you tell Windows not to redraw the GUI when you change it, it seems a little churlish to blame my UDF for not doing it for you instead. ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
mistersquirrle

I wasn't blaming your UDF at all. This issue is completely separate from your UDF. It still works when you move the separator bar with that setting unticked. I just would've expected the window, after being resized, to redraw everything, a Windows issue, I suppose.

I actually did find a workaround, with your code.

Commenting out lines 56 & 58 (If $hwnd = $hWinHandle Then/EndIf) allows the history edit to be resized without the option ticked, immediately after being resized.

Why are those lines needed?

Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites
Melba23

mistersquirrle,

Those lines are checking that it is the particular frame in which you have placed the richedit being resized. I added them so that resizing other sections of the GUI would not force a richedit resize when it was not required - in this particular GUI it always will be, but if there were other frames within the GUI it would be a valid test to run.

It appears that without the "Show window contents while dragging" option the resized message for the frame is only received after the main GUI resizing is complete. I have very little knowledge of the scheduling of Windows messages so I had no idea that this might be the case. Thanks for noticing - and finding a solution. :thumbsup:

M23

P.S. And I know you were not really complaining - look at the emoticon on that line. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
mistersquirrle

Yeah, ok. I thought that's what they were. Thanks for your help :)

BTW, can I edit my own topic titles? Or is that Mod+ only? I was gonna put a [solved] tag, or something.

Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites
Melba23

mistersquirrle,

Edit the first post and select the "Use Full Editor" option - that opens up the titles for amendment. :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
Sign in to follow this  

  • Similar Content

    • Skysnake
      By Skysnake
      I have read the Tutorial. Used the Help File and used an example script by @Melba23.  I am still struggling.
      To use GUIRegisterMsg one needs the following
      a control in the GUI a GUIRegisterMsg instruction in the GUI to link the control to the WM_COMMAND function a Case statement in the Switch loop to run it a WM_COMMAND function and a processor function... Mine looks like this
      ;~ ; QuickSearch combo box $g_cbQwkSrch = GUICtrlCreateCombo("", 8, 26, 180, 17) ; start blank GUICtrlSetTip($g_cbQwkSrch, "Type to search", "QuickSearch") GUIRegisterMsg($WM_COMMAND, "__WM_COMMAND_QWKSEARCH_CMB") ;------------------------------------ ; use in Switch Loop ;~ ; QuickSearch Case $g_cbQwkSrch ConsoleWrite("221 Case $g_cbQwkSrch" & @CRLF) ;-------------------------------------- Func _QwkSrch_Edit_Changed() ConsoleWrite("41 _QwkSrch_Edit_Changed" & @CRLF) ; Autocomplete the edit _GUICtrlComboBox_AutoComplete($g_cbQwkSrch) ; Change the label to match the autocompleted edit entry EndFunc ;==>_QwkSrch_Edit_Changed Func __WM_COMMAND_QWKSEARCH_CMB($hWnd, $iMsg, $wParam, $lParam) ; GUIRegisterMsg($WM_COMMAND, "__WM_COMMAND_QWKSEARCH_CMB") ConsoleWrite("50 _WM_COMMAND_QWKSEARCH_CMB fired " & @CRLF) Local $Found = '' #forceref $hWnd, $iMsg If $lParam = GUICtrlGetHandle($g_cbQwkSrch) And BitShift($wParam, 16) = $CBN_EDITCHANGE Then ; Our combo edit content has changed ; get data from source ---------------------------- Local $datafromsource = fFindFilesForQuickSearch($stringtofind) ; datafromsource convert to Combo friendly format ; Add data to combo _GUICtrlComboBox_BeginUpdate($g_cbQwkSrch) GUICtrlSetData($g_cbQwkSrch, $Found) _GUICtrlComboBox_EndUpdate($g_cbQwkSrch) EndIf _QwkSrch_Edit_Changed() ; Action this function EndIf EndFunc ;==>_WM_COMMAND_QWKSEARCH_CMB Func fFindFilesForQuickSearch($stringtofind) ; helper function for QuickSearch ; get data here Return $aResult EndFunc ;==>fFindFilesForQuickSearch Now the following:
      Can I declare the variable $g_cbQwkSrch in Global, then use in multiple functions - reassigning different combo's to it as I go along? Should GUIRegisterMsg be expressly de-registered, or does that happen automatically at GuiDelete()? Where is the best/correct place to call GUIRegisterMsg? With the creation of its control, before the GUISetState, or before the start of the loop? The Help File contains this entry, what is the intent?  Must this always be called with four args, or a max of four...   !!! To make the user function workable you have to define it with maximum 4 function parameters otherwise the function won't be called !!!
    • Skysnake
      By Skysnake
      Hi
      Best example I could find is here
      ::/html/libfunctions/_GUICtrlTreeView_ClickItem.htm
      The way I understand this, the standard Windows messages, such as Left/Right Click etc are covered by AutoIt macros, but the real power is locked up inside this WM_NOTIFY .  I have tried, but I am not even sure I understand what I am looking at.
      I need help understanding this.  What I am looking for is Help file or Tutorial explaining how this works?  
      Perhaps if there is a script showing both the working of an AutoIt macro and the WM_NOTIFY  in action, it would help.
      Right now I am so lost, I do not even know what are the right questions to ask.  One issue I have is on ListViews, how to combine the "Click" of a line with a standard Switch loop?  Like users clicks a line, then get the loop to detect the click and ;do something ...
      Any ideas?
      Skysnake
    • kcvinu
      By kcvinu
        Hi all,
      I know this is a crazy idea. But i think it might be a help for somebody. The name of this program is GRM Helper. i.e. GUIRegisterMsg Helper. 
      This program helps you to write the guiregistermsg function code automatically. You can choose a control from the combo box. Then all events of that control will be displayed in a list view. You can click on an event for it;s details. Then you can check the events which you want to include in your code. Then type some details like; 1) Your control's handle. 2) Line number for inserting GUIRegisterMsg code. 3) Line number for inserting main function.
      And press the "Isert To SciTE" button. Your code is ready in scite.
       
      Here is the program.
      Updated Version 1.1
      GRM Helper V1.1.zip
       
       

      The code written by this program.
      GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox If Not IsHWnd($Sample) Then $hWndListBox = GUICtrlGetHandle($Sample) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $Sample, $hWndListBox Switch $iCode Case $LBN_ERRSPACE ; Insert your code here Case $LBN_SELCHANGE ; Insert your code here Case $LBN_DBLCLK ; Insert your code here Case $LBN_SELCANCEL ; Insert your code here EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND  
       
    • kcvinu
      By kcvinu
      Hi all,
      I am playing with a combo box. The code from help file is working. But the code i wrote is not working. Help file uses "_GUICtrlComboBox_Create" for creating combo box. But i used native "GUICtrlCreateCombo". Then i replaced my native combo creation function with the UDF. Then my code worked. I think the hi word and low word parameters are the problem. 
      Here is my code.
      #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $sCMB_Items = "Apple|Orange|Mango|Banana|Grape" #Region ### START Koda GUI section ### Form= Global $hForm1 = GUICreate("Form1", 283, 188, 312, 166) Global $hCombo1 = GUICtrlCreateCombo("", 40, 48, 185, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($hCombo1, $sCMB_Items) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $hCombo1 Switch $iCode Case $CBN_DBLCLK ; Insert your code here MsgBox(0,"","$CBN_DBLCLK") Case $CBN_DROPDOWN ; Insert your code here MsgBox(0,"","$CBN_DROPDOWN") Case $CBN_EDITCHANGE ; Insert your code here MsgBox(0,"","$CBN_EDITCHANGE") Case $CBN_SELCHANGE ; Insert your code here MsgBox(0,"","$CBN_SELCHANGE") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND And this is the code from help file. Slightly modified. But working
      #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $g_hCombo Example() Func Example() Local $hGUI ; Create GUI $hGUI = GUICreate("(UDF) ComboBox Create", 400, 296) $g_hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296) GUISetState(@SW_SHOW) ; Add files _GUICtrlComboBox_BeginUpdate($g_hCombo) _GUICtrlComboBox_AddDir($g_hCombo, "", $DDL_DRIVES, False) _GUICtrlComboBox_EndUpdate($g_hCombo) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $g_hCombo Switch $iCode Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed MsgBox(0,"","$CBN_CLOSEUP") Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box MsgBox(0,"","$CBN_DBLCLK") Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible MsgBox(0,"","$CBN_DROPDOWN") Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box MsgBox(0,"","$CBN_EDITCHANGE") Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box MsgBox(0,"","$CBN_SELCHANGE") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND For those who wants the au3 file;
      Here it is
       
      Code From help file.au3
      My code.au3
    • kcvinu
      By kcvinu
      Hi all,
      I am playing with GUIRegisterMsg function for learning it. This is my code. It is not working. The error msg is this
      Variable used without being declared.:
      $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
      $tNMHDR = DllStructCreate($tagNMHDR, ^ ERROR
      I can't find lParam as a declared variable in _GUICtrlListView_Create.au3 in help file.
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <MouseOnEvent.au3> #include <Alert.au3> #include <ListBoxConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=K:\GUI Reg Msg Test works\GRM test GUI.kxf Global $Form1 = GUICreate("Form1", 611, 430, 260, 140) GUISetFont(12, 400, 0, "Segoe UI") GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") Global $Button1 = GUICtrlCreateButton("Button1", 368, 360, 137, 49) GUICtrlSetOnEvent(-1, "Button1Click") Global $List1 = GUICtrlCreateList("", 16, 216, 161, 181) GUICtrlSetOnEvent(-1, "List1Click") Global $Combo1 = GUICtrlCreateCombo("Combo1", 352, 24, 193, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetOnEvent(-1, "Combo1Change") Global $Input1 = GUICtrlCreateInput("Input1", 48, 32, 169, 33) GUICtrlSetOnEvent(-1, "Input1Change") Global $Edit1 = GUICtrlCreateEdit("", 248, 80, 321, 161) GUICtrlSetData(-1, "Edit1") GUICtrlSetOnEvent(-1, "Edit1Change") GUIRegisterMsg($WM_NOTIFY,"List1Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $tmp = ["Orange","Apple","Banana","Papaya","Grapes"] For $i = 0 to 4 GUICtrlSetData($List1,$tmp[$i]) Next While 1 Sleep(100) WEnd Func List1Click($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom,$iIDfrom, $iCode, $tNMHDR, $hWndList, $tInfo $hWndList = $List1 if Not IsHWnd($List1) Then $hWndList = GUICtrlGetHandle($List1) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR,"hWndFrom")) $iIDfrom = DllStructGetData($tNMHDR,"IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $List1 Switch $iCode Case $LBN_DBLCLK ;$tInfo = DllStructCreate($tagNMMOUSE) Alert("You Clicked Twice") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc This gui is only for learning pupose. So please don't mind its aesthetic style.
×