Jump to content

Help with $WM_COMMAND


 Share

Recommended Posts

Hi ppl, i need a little help!

I'm trying to understand how to use the GuiRegisterMsg(), and in this teste above:

why it capture the click on Button, but not capture the click in the tab?

how to use it correctly?

#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
$Gui = GUICreate("Test", 300, 300, -1, -1)
$tab = _GUICtrlTab_Create($Gui, 0, 0, 300, 300)
_GUICtrlTab_InsertItem($tab, 0, "Tab 1")
$button = GUICtrlCreateButton("Button test", 100, 100)
_GUICtrlTab_InsertItem($tab, 1, "Tab 2")
_GUICtrlTab_SetItem($tab, 0)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
While 1
Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   ExitLoop
EndSwitch
WEnd
Func _WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
  Case $button
   MsgBox(0,'','Click on Button')
  Case $tab
   MsgBox(0,'','Click on Tab')
   EndSwitch
   Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND

thanks a lot!

Link to comment
Share on other sites

  • Moderators

golfinhu,

It is because you have created the tab using the GUITab UDF. This returns a handle and not a ControlID. Within your message handler you are testing for the ControlID - as the tab does not have one, you do not detect it. ;)

To detect clicks on UDF created tabs you need to register WM_NOTIFY - look at the Help file for _GUICtrlTab_Create to see how to do it. :)

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

 

Link to comment
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
 Share

×
×
  • Create New...