eJan Posted June 26, 2006 Posted June 26, 2006 (edited) I'd like to have "real" Hover Button which capture $GUI_EVENT_PRIMARYUP on desired control. GUIGetMsg should work when Button was released inside control - not (only) clicked. Please help. expandcollapse popup#include <GUIConstants.au3> $hGUI = GUICreate("GUI", 226, 88) $text = GUICtrlCreateLabel("Label", 8, 10, 209, 29, $SS_SUNKEN) GUICtrlSetColor($text, 0x737373) $progress = GUICtrlCreateProgress(8, 43, 209, 16, $PBS_SMOOTH) $btn2 = GUICreateBiStateControl(GUICtrlCreateLabel("", 83, 63, 60, 17), $hGUI, "OnHover", "OnLeave") $btnW = GUICtrlCreateLabel("", 84, 64, 58, 15, $SS_WHITEFRAME) ; Button (white) $btnG = GUICtrlCreateLabel("", 83, 63, 60, 17, $SS_GRAYFRAME) ; Button (gray) GUICtrlCreateLabel("", 2, 4, 221, 81, $SS_GRAYFRAME) ; Group (gray) $btn1 = GUICtrlCreateLabel("Button", 83, 63, 60, 17, $SS_CENTER) GUICtrlSetColor($btn1, 0x8C8C8C) HotKeySet("{ENTER}", "Action") GUISetState(@SW_SHOW) Func Close() GUISetState(@SW_HIDE) Exit EndFunc While 1 CheckBiStateControl($btn2) $msg = GUIGetMsg() Select Case $msg = $btn2[0] Action() Case $msg = $GUI_EVENT_CLOSE Close() EndSelect WEnd Func Action() HotKeySet("{ENTER}") MsgBox(0, "", "Clicked") For $i = 1 To 100 Step 20 Sleep(1) GUICtrlSetData($progress, $i, $i) Next GUICtrlSetData($btn1, "Close") GUICtrlDelete($progress) $text2 = GUICtrlCreateLabel("Complete", 8, 43, 209, 16, $SS_CENTER + $SS_SUNKEN) GUICtrlSetColor($text2, 0x737373) HotKeySet("{ENTER}", "Close") While 1 CheckBiStateControl($btn2) $msg = GUIGetMsg() Select Case $msg = $btn2[0] Or $msg = $GUI_EVENT_CLOSE Close() EndSelect WEnd EndFunc Func OnHover() GUICtrlSetColor($btn1, 0x4AAACA) EndFunc Func OnLeave() GUICtrlSetColor($btn1, 0x8C8C8C) EndFunc Func GUICreateBiStateControl($hControl, $hGUI, $hover_func, $leave_func) Local $cPos = ControlGetPos($hGUI, "", $hControl) Local $hBSControl[8] $hBSControl[0] = $hControl $hBSControl[1] = $cPos[0] $hBSControl[2] = $cPos[1] $hBSControl[3] = $cPos[0] + $cPos[2] $hBSControl[4] = $cPos[1] + $cPos[3] $hBSControl[5] = $hover_func $hBSControl[6] = $leave_func $hBSControl[7] = 0 Return $hBSControl EndFunc Func CheckBiStateControl(ByRef $hControl) Local $info = GUIGetCursorInfo() If $info[0] > $hControl[1] And $info[0] < $hControl[3] And _ $info[1] > $hControl[2] And $info[1] < $hControl[4] Then If $hControl[7] Then Return 0 $vCallData = $hControl[0] Call($hControl[5]) $hControl[7] = 1 ElseIf $hControl[7] Then $vCallData = $hControl[0] Call($hControl[6]) $hControl[7] = 0 EndIf EndFuncEdit: AutoIt 3.1.1.92 Edited June 27, 2006 by eJan
livewire Posted June 27, 2006 Posted June 27, 2006 Can't really understand what you're trying to do, but you can create your own ActiveX button with more events like the one seen here. The button in this link can process Primary Up. You could also make labels that do the same thing.-Livewire
eJan Posted June 27, 2006 Author Posted June 27, 2006 Can't really understand what you're trying to do, but you can create your own ActiveX button with more events like the one seen here. The button in this link can process Primary Up. You could also make labels that do the same thing.-LivewireActiveX - NO, I have already use Labels which simulate Button - all I wanna do is: to use that label and capture mouse event when the mouse is released over Label - not clicked (because in Windows if user click on button and move cursor outside that button - nothing happen. Best explanation is HyperLink control where the action is taken when mouse is released inside HyperLink - not clicked)
syberschmo Posted June 27, 2006 Posted June 27, 2006 ActiveX - NO, I have already use Labels which simulate Button - all I wanna do is: to use that label and capture mouse event when the mouse is released over Label - not clicked (because in Windows if user click on button and move cursor outside that button - nothing happen. Best explanation is HyperLink control where the action is taken when mouse is released inside HyperLink - not clicked) Perhaps something like Case $msg = $GUI_EVENT_PRIMARYUP $pos = GuiGetCursorInfo() IF $pos[4] = 3 Then MsgBox(0,"Hi","You released your cursor over the label") EndIf Maybe I have misunderstood you as well? Regards, Gradient-Filled Progress Bars UDF
eJan Posted June 27, 2006 Author Posted June 27, 2006 Thanks syberschmo, very close, unfortunately doesn't work everytime when the mouse is released.
syberschmo Posted June 27, 2006 Posted June 27, 2006 (edited) Thanks syberschmo, very close, unfortunately doesn't work everytime when the mouse is released.I don't know why you need two While..Wend GUIGetMsg loops, although I'm not sure that that's the problem. If all you want is that hover button functionality, this works fine for every primary up release:#include <GUIConstants.au3> $hGUI = GUICreate("GUI", 226, 88) $text = GUICtrlCreateLabel("Label", 8, 10, 209, 29, $SS_SUNKEN) GUICtrlSetColor($text, 0x737373) $progress = GUICtrlCreateProgress(8, 43, 209, 16, $PBS_SMOOTH) $btnW = GUICtrlCreateLabel("", 84, 64, 58, 15, $SS_WHITEFRAME) ; Button (white) $btnG = GUICtrlCreateLabel("", 83, 63, 60, 17, $SS_GRAYFRAME) ; Button (gray) GUICtrlCreateLabel("", 2, 4, 221, 81, $SS_GRAYFRAME) ; Group (gray) $btn1 = GUICtrlCreateLabel("Button", 83, 63, 60, 17, $SS_CENTER) GUICtrlSetColor($btn1, 0x8C8C8C) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_PRIMARYUP $pos = GuiGetCursorInfo() IF $pos[4] = 3 Then MsgBox(0,"Hi","You released your cursor over the label") EndIf EndSelect WEnd Exit Why don't you just go from there? Add that hover functionality differently and see, specifically, what's wrong with what you are doing. I would rewrite it myself, but I'm a bit busy at the moment Regards, Edited June 27, 2006 by syberschmo Gradient-Filled Progress Bars UDF
Uten Posted June 27, 2006 Posted June 27, 2006 Thanks syberschmo, very close, unfortunately doesn't work everytime when the mouse is released.Could you explain a scenario where it does not work? Provide your code? Works everytime for me, so I'm curious. #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 303, 204, 192, 125) $lblHoover1 = GUICtrlCreateLabel("ALabel1", 8, 8, 283, 17) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg(1) Switch $msg[0] Case 0 Sleep(250) Case -11 Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYUP ConsoleWrite("$msg[0]:=" & $msg[0] & ", $msg[1]:=" & $msg[1] & ", $msg[2]:=" & $msg[2] & ", $msg[3]:=" & $msg[3] & @LF) $pos = GuiGetCursorInfo() IF $pos[4] = $lblHoover1 Then MsgBox(0,"Hi","You released your cursor over the label",5) EndIf Case Else ConsoleWrite("$msg[0]:=" & $msg[0] & ", $msg[1]:=" & $msg[1] & ", $msg[2]:=" & $msg[2] & ", $msg[3]:=" & $msg[3] & @LF) ;;;;;;; EndSwitch WEnd Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
syberschmo Posted June 27, 2006 Posted June 27, 2006 Could you explain a scenario where it does not work? Provide your code? Works everytime for me, so I'm curious.This code selectively fires... expandcollapse popup#include <GUIConstants.au3> $hGUI = GUICreate("GUI", 226, 88) $text = GUICtrlCreateLabel("Label", 8, 10, 209, 29, $SS_SUNKEN) GUICtrlSetColor($text, 0x737373) $progress = GUICtrlCreateProgress(8, 43, 209, 16, $PBS_SMOOTH) $btn2 = GUICreateBiStateControl(GUICtrlCreateLabel("", 83, 63, 60, 17), $hGUI, "OnHover", "OnLeave") $btnW = GUICtrlCreateLabel("", 84, 64, 58, 15, $SS_WHITEFRAME) ; Button (white) $btnG = GUICtrlCreateLabel("", 83, 63, 60, 17, $SS_GRAYFRAME) ; Button (gray) GUICtrlCreateLabel("", 2, 4, 221, 81, $SS_GRAYFRAME) ; Group (gray) $btn1 = GUICtrlCreateLabel("Button", 83, 63, 60, 17, $SS_CENTER) GUICtrlSetColor($btn1, 0x8C8C8C) HotKeySet("{ENTER}", "Action") GUISetState(@SW_SHOW) Func Close() GUISetState(@SW_HIDE) Exit EndFunc While 1 CheckBiStateControl($btn2) $msg = GUIGetMsg() Select Case $msg = $btn2[0] Action() Case $msg = $GUI_EVENT_CLOSE Close() Case $msg = $GUI_EVENT_PRIMARYUP $pos = GuiGetCursorInfo() IF $pos[4] = 3 Then MsgBox(0,"Hi","You released your cursor over the label") EndIf EndSelect WEnd Func Action() HotKeySet("{ENTER}") MsgBox(0, "", "Clicked") For $i = 1 To 100 Step 20 Sleep(1) GUICtrlSetData($progress, $i, $i) Next GUICtrlSetData($btn1, "Close") GUICtrlDelete($progress) $text2 = GUICtrlCreateLabel("Complete", 8, 43, 209, 16, $SS_CENTER + $SS_SUNKEN) GUICtrlSetColor($text2, 0x737373) HotKeySet("{ENTER}", "Close") While 1 CheckBiStateControl($btn2) $msg = GUIGetMsg() Select Case $msg = $btn2[0] Or $msg = $GUI_EVENT_CLOSE Close() Case $msg = $GUI_EVENT_PRIMARYUP $pos = GuiGetCursorInfo() IF $pos[4] = 3 Then MsgBox(0,"Hi","You released your cursor over the label") EndIf EndSelect WEnd EndFunc Func OnHover() GUICtrlSetColor($btn1, 0x4AAACA) EndFunc Func OnLeave() GUICtrlSetColor($btn1, 0x8C8C8C) EndFunc Func GUICreateBiStateControl($hControl, $hGUI, $hover_func, $leave_func) Local $cPos = ControlGetPos($hGUI, "", $hControl) Local $hBSControl[8] $hBSControl[0] = $hControl $hBSControl[1] = $cPos[0] $hBSControl[2] = $cPos[1] $hBSControl[3] = $cPos[0] + $cPos[2] $hBSControl[4] = $cPos[1] + $cPos[3] $hBSControl[5] = $hover_func $hBSControl[6] = $leave_func $hBSControl[7] = 0 Return $hBSControl EndFunc Func CheckBiStateControl(ByRef $hControl) Local $info = GUIGetCursorInfo() If $info[0] > $hControl[1] And $info[0] < $hControl[3] And _ $info[1] > $hControl[2] And $info[1] < $hControl[4] Then If $hControl[7] Then Return 0 $vCallData = $hControl[0] Call($hControl[5]) $hControl[7] = 1 ElseIf $hControl[7] Then $vCallData = $hControl[0] Call($hControl[6]) $hControl[7] = 0 EndIf EndFunc Seems to fire over the text/caption part of the label. Gradient-Filled Progress Bars UDF
eJan Posted June 27, 2006 Author Posted June 27, 2006 I'm sorry! I didnt't explain what and where to do. Case $msg = $btn2[0] Action()I would like this one to replace with $GUI_EVENT_PRIMARYUP, where $btn2[0] is HoverButton (Label). Maybe it's little complicated because there is GUICreateBiStateControl() function which maybe doesn't allow to capture event?
marfdaman Posted July 8, 2006 Posted July 8, 2006 Take a look at the post in my sig Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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