Jump to content

Recommended Posts

Posted (edited)

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.

Edited by kcvinu
  Reveal hidden contents

 

Posted

@kylomas Already tried. But no way. 

  Reveal hidden contents

 

Posted (edited)

Create a small reproducer without all the fluff. You'll be surprised when you find out the problem was your end.

Edited by guinness
Typo

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

@guinness , Thanks for the inspiration. And i just avoid on fluff from this code. GUICtrlSetOnEvent function is the only one fluff i can found. :)

Edited by kcvinu
  Reveal hidden contents

 

  • Moderators
Posted

kcvinu,

Please shrink your signature - a spoiler seems indicated.

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:

  Reveal hidden contents

 

Posted

@Melba23 Done. :)

  Reveal hidden contents

 

Posted

I meant Alert.au3 and all the other junk you have there. If you want help, then don't expect people to have to fix your reproducer for you. Try using _GUICtrlListBox_Create() instead.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

@guinness, Success !. Thanks for pointing me to right direction.  I wonder why did this function changes for each controls. I mean, for ListView, it uses "WM_NOTIFY". For ListBox, it uses "WM_COMMAND".. Anyhow, i am decided to learn more on this stuff as soon as possible.

  Reveal hidden contents

 

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
×
×
  • Create New...