Search the Community
Showing results for tags 'tollbar'.
-
I tried to come up with a simple toolbar which displays the plain icons (without a button frame) but also shows a button effect when hovered or clicked on. My approach was to create a button, add an icon and hide the icon button again. Then place the icon without the button on top of it. When the mouse is moved over the icon I hide the icon (which leaves button displayed) giving me the hover effect for hover and clicks (using GUIGetCursorInfo() to get the icon ID). It seem to work ... but sometimes the hover effect does not show as expected especially when the mouse is moved slowly to the edge of the icon. While the icon ID is being read and action triggered (see Mouse OVER text) the icon itself is not being hidden (and button displayed). I found that the effect is more likely to occur when the GUI is freshly loaded. Can anyone reproduce this effect? I wonder what may causes this effect or is anything wrong in my coding? Any hint and support would be appreciated! Many thanks #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) f_toolbar() Func f_toolbar() Local $id_button_1_a, $id_button_2_a, $id_button_3_a Local $id_button_1_b, $id_button_2_b, $id_button_3_b Local $id_button_close Local $h_toolbar_gui, $msg_pop, $id_output_lbl ; -- Declare and set mouse over variables Local $last_tool_b_id = 0 ; ID of last button/icon visited Local $a_cursor_b_info ; GUIGetCursorInfo() array Local $win_w = 400 ; GUI width Local $win_h = 400 ; GUI height Local $icon_file = @SystemDir & "\shell32.dll" ; -- Create the GUI ------------------------------------------------------------------------------------------------------- $h_toolbar_gui = GUICreate("Toolbar hover - Test ...", $win_w, $win_h) ; -- A frame for the toolbar GUICtrlCreateLabel("", 3, 3, $win_w-3, 44, $SS_ETCHEDFRAME ) GUICtrlSetState(-1, $GUI_DISABLE) ; -- The Toolbar ; -- 1. Toolbar button ----------------------------------------------------------------------------------------------------- $id_button_1_a = GUICtrlCreateButton("1", 4, 4, 40, 40, $BS_ICON) ; Create BUTTON GUICtrlSetImage(-1, $icon_file, -71, 1) ; Add ICON to button GUICtrlSetState(-1, $GUI_HIDE) ; Hide ICON BUTTON again $id_button_1_b = GUICtrlCreateIcon($icon_file, -71, 4, 4, 40, 40, $BS_CENTER) ; Create ICON to display ; -- 2. Toolbar button ----------------------------------------------------------------------------------------------------- $id_button_2_a = GUICtrlCreateButton("2", 44, 4, 40, 40, $BS_ICON) ; Create BUTTON GUICtrlSetImage(-1, $icon_file, -5, 1) ; Add ICON to button GUICtrlSetState(-1, $GUI_HIDE) ; Hide ICON BUTTON again $id_button_2_b = GUICtrlCreateIcon($icon_file, -5, 44, 4, 40, 40, $BS_CENTER) ; Create ICON to display ; -- 3. Toolbar button ----------------------------------------------------------------------------------------------------- $id_button_3_a = GUICtrlCreateButton("3", 84, 4, 40, 40, $BS_ICON) GUICtrlSetImage(-1, $icon_file, -28, 1) ; Add ICON to button GUICtrlSetState(-1, $GUI_HIDE) ; Hide ICON BUTTON again $id_button_3_b = GUICtrlCreateIcon($icon_file, -28, 84, 4, 40, 40, $BS_CENTER) ; Create ICON to display ; -- Lable CTRL for feedback $id_output_lbl = GUICtrlCreateLabel("Move mouse over toolbar ...", 4, 100, $win_w-8, 16) ; Lable for feedback GUICtrlSetBkColor($id_output_lbl, 0xFFFFFF) ; -- The Close button $id_button_close = GUICtrlCreateButton("Close", $win_w/2-40, $win_h-40, 80, 24, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $msg_pop = GUIGetMsg() Select Case $msg_pop = $GUI_EVENT_CLOSE ExitLoop Case $msg_pop = $id_button_close ExitLoop Case $msg_pop = $id_button_1_a Or $msg_pop = $id_button_1_b GUICtrlSetState($id_button_1_a, $GUI_SHOW) ; Show BUTTON MsgBox(32, "DEBUG", "Button 1 pressed ...", 0, $h_toolbar_gui) Case $msg_pop = $id_button_2_a Or $msg_pop = $id_button_2_b GUICtrlSetState($id_button_2_a, $GUI_SHOW) ; Show BUTTON MsgBox(32, "DEBUG", "Button 2 pressed ...", 0, $h_toolbar_gui) Case $msg_pop = $id_button_3_a Or $msg_pop = $id_button_3_b GUICtrlSetState($id_button_3_a, $GUI_SHOW) ; Show BUTTON MsgBox(32, "DEBUG", "Button 3 pressed ...", 0, $h_toolbar_gui) Case Else $a_cursor_b_info = GUIGetCursorInfo($h_toolbar_gui) ; - $aArray[4] = ID of the control that the mouse cursor is hovering over (or 0 if none) Select ; -- Button 1 - Cursor ------------------------------------------------------------------------------------- Case $a_cursor_b_info[4] = $id_button_1_b And $last_tool_b_id <> $id_button_1_b And $last_tool_b_id = 0 ; MOUSE OVER GUICtrlSetState($id_button_1_a, $GUI_SHOW) ; Show BUTTON GUICtrlSetData($id_output_lbl, "Mouse OVER - Ctrl ID:" & @TAB & $a_cursor_b_info[4]) GUICtrlSetBkColor($id_output_lbl, 0xFFFF00) $last_tool_b_id = $id_button_1_b ; -- DEBUG ----------------------------------------------------------------- ConsoleWrite("> ... " & "$last_tool_b_id - Ctrl ID:" & @TAB & $last_tool_b_id & @CRLF) ; -- DEBUG ----------------------------------------------------------------- Case $a_cursor_b_info[4] <> $id_button_1_b And $last_tool_b_id = $id_button_1_b ; NO MOUSE OVER GUICtrlSetState($id_button_1_a, $GUI_HIDE) ; Hide BUTTON $a_cursor_b_info[4] = 0 GUICtrlSetData($id_output_lbl, "Mouse AWAY - Ctrl ID:" & @TAB & $a_cursor_b_info[4]) GUICtrlSetBkColor($id_output_lbl, 0x99CCFF) $last_tool_b_id = 0 ; -- DEBUG ----------------------------------------------------------------- ConsoleWrite("> ... " & "$last_tool_b_id - Ctrl ID:" & @TAB & $last_tool_b_id & @CRLF) ; -- DEBUG ----------------------------------------------------------------- ; -- Button 2 - Cursor ------------------------------------------------------------------------------------- Case $a_cursor_b_info[4] = $id_button_2_b And $last_tool_b_id <> $id_button_2_b And $last_tool_b_id = 0 ; MOUSE OVER GUICtrlSetState($id_button_2_a, $GUI_SHOW) ; Show BUTTON GUICtrlSetData($id_output_lbl, "Mouse OVER - Ctrl ID:" & @TAB & $a_cursor_b_info[4]) GUICtrlSetBkColor($id_output_lbl, 0xFFFF00) $last_tool_b_id = $id_button_2_b ; -- DEBUG ----------------------------------------------------------------- ConsoleWrite("> ... " & "$last_tool_b_id - Ctrl ID:" & @TAB & $last_tool_b_id & @CRLF) ; -- DEBUG ----------------------------------------------------------------- Case $a_cursor_b_info[4] <> $id_button_2_b And $last_tool_b_id = $id_button_2_b ; NO MOUSE OVER GUICtrlSetState($id_button_2_a, $GUI_HIDE) ; Hide BUTTON $a_cursor_b_info[4] = 0 GUICtrlSetData($id_output_lbl, "Mouse AWAY - Ctrl ID:" & @TAB & $a_cursor_b_info[4]) GUICtrlSetBkColor($id_output_lbl, 0x99CCFF) $last_tool_b_id = 0 ; -- DEBUG ----------------------------------------------------------------- ConsoleWrite("> ... " & "$last_tool_b_id - Ctrl ID:" & @TAB & $last_tool_b_id & @CRLF) ; -- DEBUG ----------------------------------------------------------------- ; -- Button 3 - Cursor ------------------------------------------------------------------------------------- Case $a_cursor_b_info[4] = $id_button_3_b And $last_tool_b_id <> $id_button_3_b And $last_tool_b_id = 0 ; MOUSE OVER GUICtrlSetState($id_button_3_a, $GUI_SHOW) ; Show BUTTON GUICtrlSetData($id_output_lbl, "Mouse OVER - Ctrl ID:" & @TAB & $a_cursor_b_info[4]) GUICtrlSetBkColor($id_output_lbl, 0xFFFF00) $last_tool_b_id = $id_button_3_b ; -- DEBUG ----------------------------------------------------------------- ConsoleWrite("> ... " & "$last_tool_b_id - Ctrl ID:" & @TAB & $last_tool_b_id & @CRLF) ; -- DEBUG ----------------------------------------------------------------- Case $a_cursor_b_info[4] <> $id_button_3_b And $last_tool_b_id = $id_button_3_b ; NO MOUSE OVER GUICtrlSetState($id_button_3_a, $GUI_HIDE) ; Hide BUTTON $a_cursor_b_info[4] = 0 GUICtrlSetData($id_output_lbl, "Mouse AWAY - Ctrl ID:" & @TAB & $a_cursor_b_info[4]) GUICtrlSetBkColor($id_output_lbl, 0x99CCFF) $last_tool_b_id = 0 ; -- DEBUG ----------------------------------------------------------------- ConsoleWrite("> ... " & "$last_tool_b_id - Ctrl ID:" & @TAB & $last_tool_b_id & @CRLF) ; -- DEBUG ----------------------------------------------------------------- EndSelect EndSelect WEnd GUIDelete() EndFunc ;==> f_toolbar()