Jump to content

Recommended Posts

Posted

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!

  • Moderators
Posted

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:

  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...