Popular Post KaFu Posted July 21, 2015 Popular Post Share Posted July 21, 2015 (edited) One more work-around for the old problem :). Update procedure must be quite different for these two control types under the hood. #include <WindowsConstants.au3> #include <EditConstants.au3> HotKeySet("{ESC}", "_Exit") GUICreate("My GUI") GUISetBkColor(0x00ff00) $c_Label = GUICtrlCreateLabel(0, 10, 10, 200, 20) $c_Input = GUICtrlCreateInput(0, 10, 60, 200, 20, $ES_READONLY, $WS_EX_TRANSPARENT) GUICtrlSetBkColor(-1, 0x00ff00) GUICtrlSetCursor(-1, 2) ; Arrow GUISetState(@SW_SHOW) While 1 GUICtrlSetData($c_Label, TimerInit()) GUICtrlSetData($c_Input, TimerInit()) WEnd Func _Exit() Exit EndFunc ;==>_Exit Edited July 21, 2015 by KaFu argumentum, coffeeturtle, UEZ and 2 others 5 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...
UEZ Posted July 21, 2015 Share Posted July 21, 2015 Nice catch KaFu Here an additional one:#include <WindowsConstants.au3> #include <EditConstants.au3> HotKeySet("{ESC}", "_Exit") GUICreate("My GUI", 300, 200, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED)) GUISetBkColor(0x00ff00) $c_Label = GUICtrlCreateLabel(0, 10, 10, 200, 20) $c_Input = GUICtrlCreateInput(0, 10, 60, 200, 20) ;, $ES_READONLY, $WS_EX_TRANSPARENT) GUICtrlSetBkColor(-1, 0x00ff00) GUICtrlSetCursor(-1, 2) ; Arrow GUISetState(@SW_SHOW) While 1 GUICtrlSetData($c_Label, TimerInit()) GUICtrlSetData($c_Input, TimerInit()) WEnd Func _Exit() Exit EndFunc ;==>_Exit KaFu, argumentum, jaberwacky and 1 other 4 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
BrewManNH Posted July 21, 2015 Share Posted July 21, 2015 Really great idea, at least this way you wouldn't have to add code to check to see if the value has changed just to avoid the flickering.When you click on the title bar it freezes the display, and one thing I noticed when I changed the code to what's below, that the Input control almost always has an earlier TimerDiff value than the label does even though it's in the script after the update to the label.While 1 GUICtrlSetData($c_Label, TimerDiff($Timer)) GUICtrlSetData($c_Input, TimerDiff($Timer)) WEnd If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
coffeeturtle Posted July 21, 2015 Share Posted July 21, 2015 Nice catch KaFu Here an additional one:Hi UEZ. Why does this work: BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED)) ??? Thanks to you both! Link to comment Share on other sites More sharing options...
UEZ Posted July 21, 2015 Share Posted July 21, 2015 According to MSWS_EX_COMPOSITED (0x02000000):Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 2000: This style is not supported.WS_EX_COMPOSITED works by forcing child windows to draw back to front and by double buffering them; however, the double buffering used by WS_EX_COMPOSITED for the child windows conflicts with the double buffering used by WS_EX_LAYERED windows and DWM so it does not remove the flicker in those contexts. Unfortunately, this means that your composited test application flickers with DWM turned on but not with DWM turned off. Narrowing the area invalidated to the minimum necessary and using WS_CLIPCHILDREN and WS_CLIPSIBLINGS appropriately can help reduce the amount of flicker. WS_EX_COMPOSITED does not eliminate flashing on Windows 8 with DWM (Desktop Windows Manager)WS_EX_COMPOSITED appears to work fine until you minimize then restore the window. Then the child windows will start flashing. To avoid flashing do not set the WS_EX_COMPOSITED style, do your own double buffering, and ignore the WM_ERASEBKGND message. This is a know issue with Microsoft. WS_EX_LAYERED (0x00080000):The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.WS_EX_LAYERED windows and all windows when DWM is enabled are rendered into an offscreen buffer and that buffer is then rendered to the screen. WM_PAINT messages can be skipped to update the onscreen buffer so long as the offscreen buffer is valid. Maybe this helps a little bit. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
coffeeturtle Posted July 21, 2015 Share Posted July 21, 2015 Thank you for the thorough answer!Appreciate your input as always! Link to comment Share on other sites More sharing options...
VAN0 Posted May 9, 2022 Share Posted May 9, 2022 (edited) How do we go about hiding cursor in edit box and not allow text selection, aka making it visibly true label element? Also, on label I can add 0x00100000 as extended style that allows dragging window by label element, this doesn't work on edit box unfortunately... [EDIT] At the moment my work around is to create a transparent label that covers the edit box, it works, but maybe there is a better solution? Edited May 9, 2022 by VAN0 Link to comment Share on other sites More sharing options...
pixelsearch Posted May 10, 2022 Share Posted May 10, 2022 Hi VAN0, I think you did well by adding a transparent label that covers the edit box, making the GUI draggable. It takes just 1 line of code and does the job. It's useful especially when the GUI got no caption. "About hiding cursor in edit box" : @jguinch showed a way to do it in this script, by registering WM_COMMAND and testing EN_SETFOCUS. You can see the difference in his script when you run it again, after commenting out the line : ; GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') But you also "don't want to allow text selection, aka making [the edit control] visibly a true label element" If you're ok with the fact that the front color of the edit box won't be black as night, then this could help : #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> Local $hForm = GUICreate('Test' , 400, 250) GUICtrlCreateLabel("", 10, 10, 380, 100, -1, $GUI_WS_EX_PARENTDRAG) ; => $Input1 draggable Local $Input1 = GUICtrlCreateEdit('No caret inside + Not selectable', 10, 10, 380, 100, _ $WS_HSCROLL + $WS_VSCROLL + $ES_READONLY) ; GUICtrlSetColor(-1, 0x000000) ; front color : black (doesn't work on disabled control) GUICtrlSetBkColor(-1, 0xFFFFFF) ; back color : white (works on disabled control) GUICtrlSetFont(-1, Default, 900) ; boldest (to appear a bit 'less grey' on disabled control) GUICtrlSetState(-1, $GUI_DISABLE) Local $Input2 = GUICtrlCreateEdit('Caret inside + selectable', 10, 110, 380, 100) Local $Button = GUICtrlCreateButton('Exit', 300, 220, 90, 20) Local $msg GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE OR $msg = $Button Then Exit WEnd @Melba23 indicated in this script : GUICtrlSetBackColor does work on disabled controls, although GUICtrlSetColor appears not to. Good luck VAN0 and KaFu 1 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted May 16, 2022 Share Posted May 16, 2022 (edited) I found a good way to alter the grayed (disabled) text color, becoming totally black. It looks much nicer for your script (an edit control appearing like a label) : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Local $iSaveGrayTextColor = _WinAPI_GetSysColor($COLOR_GRAYTEXT) ConsoleWrite("Original gray text color = " & $iSaveGrayTextColor & @crlf) ; 10070188 on my PC _WinAPI_SetSysColors($COLOR_GRAYTEXT, 0) ; force gray text to black during the script Local $hForm = GUICreate('Test' , 400, 250) GUICtrlCreateLabel("", 10, 10, 380, 100, -1, $GUI_WS_EX_PARENTDRAG) ; => $Input1 draggable Local $Input1 = GUICtrlCreateEdit('No caret inside + Not selectable', 10, 10, 380, 100) GUICtrlSetState(-1, $GUI_DISABLE) Local $Input2 = GUICtrlCreateEdit('Caret inside + selectable', 10, 110, 380, 100) Local $Button = GUICtrlCreateButton('Exit', 300, 220, 90, 20) Local $msg GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE OR $msg = $Button Then ExitLoop WEnd _WinAPI_SetSysColors($COLOR_GRAYTEXT, $iSaveGrayTextColor) ; restore the original color (+++) Exit Edited May 16, 2022 by pixelsearch typo dmob and VAN0 1 1 Link to comment Share on other sites More sharing options...
VAN0 Posted May 17, 2022 Share Posted May 17, 2022 (edited) On 5/16/2022 at 3:31 PM, pixelsearch said: I found a good way to alter the grayed (disabled) text color, becoming totally black. It looks much nicer for your script (an edit control appearing like a label) : Thank you it works very well, if one doesn't mind other apps gets affected too and as long as the script exists gracefully. In my case even overlapped label not needed, allowing dragging gui via edit control - nice! Edited May 17, 2022 by VAN0 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