BAM5 Posted August 14, 2010 Posted August 14, 2010 (edited) I've looked through the forums and the help file, but I can't figure out why the button or pic objects that work out of the status bar in the gui don't work while in the status bar. Neither events nor GUIGetMsg works. Could someone explain what's happening here? Edited August 22, 2010 by BAM5 [center]JSON Encoding UDF[/center]
BAM5 Posted August 16, 2010 Author Posted August 16, 2010 I could really use some help with this. [center]JSON Encoding UDF[/center]
BAM5 Posted August 16, 2010 Author Posted August 16, 2010 (edited) Found it after doing a google search of the forums.2nd post in this topic: http://www.autoitscript.com/forum/index.php?showtopic=63451 Edited August 17, 2010 by BAM5 [center]JSON Encoding UDF[/center]
BAM5 Posted August 17, 2010 Author Posted August 17, 2010 Alright, the previous didn't work for controls in the status bar, but did work for when you clicked the statusbar itself. So I could still use some help here! [center]JSON Encoding UDF[/center]
PsaltyDS Posted August 17, 2010 Posted August 17, 2010 Got a short-and-sweet reproducer script that demonstrates your issue? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
BAM5 Posted August 18, 2010 Author Posted August 18, 2010 (edited) I'll write one up right now. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> ;~ Opt("GUIOnEventMode", 1) Dim $parts[1] = [-1] $main = GUICreate("Statusbar clicking", 377, 80, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "close") $status = _GUICtrlStatusBar_Create($main) _GUICtrlStatusBar_SetMinHeight($status, 27) _GUICtrlStatusBar_SetParts($status, $parts) $_button = GUICtrlCreateButton("This CAN'T trigger anything", 0, 0, 150, 22) ;~ GUICtrlSetOnEvent(-1, "click") $_hndl = GUICtrlGetHandle($_button) _GUICtrlStatusBar_EmbedControl($status, 0, $_hndl, 3) GUISetState(@SW_SHOW) While 1 Sleep(10) Switch GUIGetMsg() Case $_button MsgBox(0, "Awesome", "This works"); doesn't actually work :( Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func close() Exit EndFunc Func click() MsgBox(0, "Awesome", "This works"); doesn't actually work :( EndFunc I included both methods, GUIGetMsg and Events. Edited August 18, 2010 by BAM5 [center]JSON Encoding UDF[/center]
PsaltyDS Posted August 19, 2010 Posted August 19, 2010 (edited) I see now. The problem is that messages from the button are going to the status bar process, which is separate from the GUI's. You have to subclass the status bar, which tells it to send messages to a function in your script. Here's a working example by rover: expandcollapse popup;the usual paint and resize issues apply with the StatusBar not being native AutoIt code ;Note: if using a resizable gui you need to recalculate StatusBar parts #include <GUIConstantsEX.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiButton.au3> Local $aparts[3] = [80, 160, -1] $hgui = GUICreate("StatusBar Embed Control", 400, 300, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX,$WS_MAXIMIZEBOX)) $button = GUICtrlCreateButton('Ok', 0, 0, 100, 20) $hstatus = _GUICtrlStatusBar_Create($hgui) _GUICtrlStatusBar_SetParts($hstatus, $aparts) _GUICtrlStatusBar_SetText($hstatus, "Part 1") _GUICtrlStatusBar_SetText($hstatus, "Part 2", 1) ;$hBtnStatusBar = _GUICtrlButton_Create($hgui, "Ok", 0, 0, 0, 0) $cBtnStatusBar = GUICtrlCreateButton('Ok', 0, 0) $hBtnStatusBar = GUICtrlGetHandle($cBtnStatusBar) $cBtnDummy = GUICtrlCreateDummy() _GUICtrlStatusBar_EmbedControl($hstatus, 2, $hBtnStatusBar) ; subclass StatusBar window: $wProcNew = DllCallbackRegister("_StatusBarWindowProc", "int", "hwnd;uint;wparam;lparam") $wProcOld = _WinAPI_SetWindowLong($hstatus, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew)) GUIRegisterMsg($WM_SIZE, "_WM_SIZE") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 ;Delete StatusBar window callback function _WinAPI_SetWindowLong($hstatus, $GWL_WNDPROC, $wProcOld) DllCallbackFree($wProcNew) Exit 0 Case $button MsgBox(262144, '', 'Main form button is pressed!') Case $cBtnDummy MsgBox(262144, '', 'StatusBar button is pressed!') EndSwitch WEnd Func _WM_SIZE() _GUICtrlStatusBar_Resize($hstatus) Return $GUI_RUNDEFMSG EndFunc Func _StatusBarWindowProc($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Switch $Msg Case $WM_COMMAND Switch $lParam Case $hBtnStatusBar ;ConsoleWrite('-$nID = ' & $nID & @crlf) ;ConsoleWrite('-$nNotifyCode = ' & $nNotifyCode & @crlf) Switch $nNotifyCode Case $BN_CLICKED GUICtrlSendToDummy($cBtnDummy) ;ConsoleWrite("$BN_CLICKED" & @CRLF) EndSwitch EndSwitch Case $WM_NCPAINT ;update button position when StatusBar repainted (when gui resized or restored from minimized) ;must be better way of doing this _GUICtrlStatusBar_EmbedControl($hstatus, 2, $hBtnStatusBar) EndSwitch ; pass the unhandled messages to default WindowProc Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam) EndFunc ;==>_NewWindowProc Edited August 19, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
BAM5 Posted August 22, 2010 Author Posted August 22, 2010 <3 I thought it was something like that, but I'm not that experienced in windows programming, just autoit. [center]JSON Encoding UDF[/center]
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