ccxw1983 Posted January 19, 2010 Posted January 19, 2010 the function 'GUIRegisterMsg' do not work after the function 'GUICtrlSetStyle' is execute. expandcollapse popup#include <Date.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1); GUI OnEvent Global Const $STN_DBLCLK = 1 Local $win_main = GUICreate("", 450, 30, 450, 30) GUISetOnEvent($GUI_EVENT_CLOSE, "gui_win_tool") Local $Label = GUICtrlCreateLabel("", 0, 0, 450, 30) ;GUICtrlSetOnEvent($Label, "gui_win_tool") GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) Local $begin_ticks = _Date_Time_GetTickCount() Local $waitticks = 9000 / 1 While 1 If _Date_Time_GetTickCount() - $begin_ticks > $waitticks Then GUICtrlSetStyle($Label, $SS_CENTER) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUICtrlSetData($Label, "double click me can not show TrayTip now! ") Else GUICtrlSetData($Label, "double click me to show TrayTip. " & @CRLF _ & "after " & Int(($waitticks - _Date_Time_GetTickCount() + $begin_ticks) / 1000) _ & " seconds, this will not work,is this a bug for GUIRegisterMsg?") EndIf Sleep(100) WEnd Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) ;ConsoleWrite("$hWnd=" & $hWnd & @CRLF) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Local $hCtrl = $lParam Switch $nID Case $Label Switch $nNotifyCode Case $STN_DBLCLK TrayTip("", "dbclick at " & @HOUR & ":" & @MIN & ":" & @SEC, 1, 1) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func gui_win_tool() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit ;Case $Label ; TrayTip("", " some click at " & @HOUR & ":" & @MIN & ":" & @SEC, 1, 1) EndSwitch EndFunc ;==>gui_win_tool
jvanegmond Posted January 19, 2010 Posted January 19, 2010 The default style for a label is not $SS_LEFT, it's actually a lot more styles combined. By assigning $SS_CENTER you are overriding all other styles, causing the style that is responsible for notifying you on a click to be no longer active. github.com/jvanegmond
Moderators Melba23 Posted January 19, 2010 Moderators Posted January 19, 2010 ccxw1983,No bug!When you set any of the styles, you overwrite any styles that already exist. In your case, using GUICtrlSetStyle($Label, $SS_CENTER) removes all the default styles that were put in place when you created the label.From the Help file, these are $SS_NOTIFY, $SS_LEFT. See the first one? That is what fires the WM_COMMAND message - so by removing it you prevent the message from being sent! Replace it with this: GUICtrlSetStyle($Label, BitOr($SS_NOTIFY, $SS_CENTER)) and all will be well. By the way, you do not need another GUIRegisterMsg in your loop - one per script is quite enough! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ccxw1983 Posted January 20, 2010 Author Posted January 20, 2010 Manadar,Melba23, you are great, thank you very much!!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now