nekkutta Posted February 21, 2011 Share Posted February 21, 2011 OK, I have a problem, I'm trying to set up a "Always on top" menu item, and it is not staying on top after clicking $progressGui[0] is the hwnd from the guicreate, and $progressGui[5] is the always on top menuitem Func mnuOnTopClick() If BitAnd(GUICtrlRead($progressGui[5]),$GUI_CHECKED) Then ;uncheck, remove always on top GUISetStyle(-1,-1,$progressGui[0]) GUICtrlSetState($progressGui[5],$GUI_UNCHECKED) Else ;check, set always on top GUISetStyle(-1,$WS_EX_TOPMOST,$progressGui[0]) GUICtrlSetState($progressGui[5],$GUI_CHECKED) EndIf EndFunc anyone know why this wouldn't be working [size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size] Link to comment Share on other sites More sharing options...
KaFu Posted February 21, 2011 Share Posted February 21, 2011 (edited) Setting the style itself is the hard way, better use the provided function WinSetOnTop(). Func mnuOnTopClick() If BitAND(GUICtrlRead($c_Checkbox), $GUI_CHECKED) Then WinSetOnTop($hGUI,"",1) Else WinSetOnTop($hGUI,"",0) EndIf EndFunc ;==>mnuOnTopClick Edit: Imho you could achieve the same with GUIGetStyle(), but you have to read the current style with GUIGetStyle() first, then subtract or add the $WS_EX_TOPMOST style flag and finally hide and show the gui again to apply the style change. So better stick to solution provided above . Edited February 21, 2011 by KaFu pixelsearch 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
nekkutta Posted February 21, 2011 Author Share Posted February 21, 2011 (edited) Setting the style itself is the hard way, better use the provided function WinSetOnTop().D'oh!!!! I didn't even notice that. I keep forgetting about the Win... functions. Thank you! maybe one of these days I actually remember that the Win... functions aren't just for controlling Other programs' windows.Thanks again.EDIT, Would It be possible to use that on the builtin ProgressOn() window? Edited February 21, 2011 by nekkutta [size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size] Link to comment Share on other sites More sharing options...
KaFu Posted February 21, 2011 Share Posted February 21, 2011 Sure, try something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered $c_Checkbox = GUICtrlCreateCheckbox("OnTop", 10, 10) GUISetState(@SW_SHOW) ; will display an empty dialog box ProgressOn("Progress Window", "Test") Global $hWnd_Progress = _hWnd_Progress("Progress Window") mnuOnTopClick() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $c_Checkbox mnuOnTopClick() EndSwitch WEnd Func mnuOnTopClick() If BitAND(GUICtrlRead($c_Checkbox), $GUI_CHECKED) Then WinSetOnTop($hGUI, "", 1) WinSetOnTop($hWnd_Progress, "", 1) Else WinSetOnTop($hGUI, "", 0) WinSetOnTop($hWnd_Progress, "", 0) EndIf EndFunc ;==>mnuOnTopClick Func _hWnd_Progress($sTitle = "") If Not $sTitle Then Return SetError(1) Local $aWinlist = WinList($sTitle) For $i = 1 To $aWinlist[0][0] If WinGetProcess($aWinlist[$i][1]) = @AutoItPID Then Return $aWinlist[$i][1] Next Return SetError(2) EndFunc ;==>_hWnd_Progress OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
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