drapdv Posted February 26 Share Posted February 26 (edited) So, I feel like this is going to be a really stupid question, but I'm going to ask it anyway. I want to make an input control with rounded corners. I'd be fine with an edit control with rounded corners, or a label with rounded corners which I could then place a borderless input control over the top of. It's not going to be extravagant. It's going to be a white control, with (probably) a thin, light gray border, on a white GUI. I've dug through the forum, but the posts I'm finding are years old, and often take hundreds of lines to accomplish not-exactly what I'm looking for. I'm hoping someone familiar with modern GUI design will see this and just be like, "Oh yeah, you just do [blank]." Any help is appreciated. Edit: I built a function based on Nine's code. I've attached it. expandcollapse popup#include <GUIConstants.au3> #include <GuiEdit.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> Const $SC_MOVE = 0xF010 Dim $hGUI = GUICreate("Multiple Childs"), $hLabel1, $hLabel2, $iW = 250, $iH = 30, $sBkColor = 0xFFFFFF, $sTxtColor = 0x000000 GUISetFont(10, 500, 0, "Calibri") GUISetBkColor(0x5D6D7E) GUISetState() $hLabel1 = _GuiCtrlCreateRoundedInput($hGUI, "Cats", $iW, $iH, 20, 20, $sBkColor, $sTxtColor, "Input 1", 11, -1, -1, "Segoe UI") $hLabel2 = _GuiCtrlCreateRoundedInput($hGUI, "Dogs", $iW, $iH, 20, 70, $sBkColor, $sTxtColor, "Input 2", 11, -1, -1, "Segoe UI") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _GuiCtrlCreateRoundedInput($hParent, $sText, $iWd, $iHt, $iLeft, $iTop, $sBkClr = 0xFFFFFF, $sTxtClr = 0x000000, $sCue = "", $iFontSize = 10, $iFontWt = 500, $iFontAttrib = 0, $sFontName = "Calibri") Local $hGui_Inp, $hRgn, $hInp $hGui_Inp = GUICreate("", $iWd, $iHt, $iLeft, $iTop, $WS_CHILD, $WS_EX_CONTROLPARENT, $hParent) GUISetBkColor($sBkClr) GUICtrlCreateLabel("", 0, 0, $iWd, $iHt) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetBkColor(-1, $sBkClr) $hInp = GUICtrlCreateInput($sText, 5, 5, ($iWd - 10), ($iHt - 10), BitOR($ES_UPPERCASE, $SS_CENTERIMAGE), $WS_EX_TOOLWINDOW) GUICtrlSetFont(-1, $iFontSize, $iFontWt, $iFontAttrib, $sFontName) GUICtrlSetColor(-1, $sTxtClr) GUICtrlSetBkColor(-1, $sBkClr) _GUICtrlEdit_SetCueBanner(-1, $sCue) $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iWd, $iHt, 20, 20) _WinAPI_SetWindowRgn($hGui_Inp, $hRgn) GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") GUISetState() Return $hGui_Inp EndFunc ;==>_GuiCtrlCreateRoundedInput Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0xFFF0) = $SC_MOVE Then If $hWnd = $hGUI Then Return Return False EndIf Return $GUI_RUNDEFMSG EndFunc ;==>On_WM_SYSCOMMAND Edited March 17 by drapdv Link to comment Share on other sites More sharing options...
Nine Posted February 26 Share Posted February 26 Try this : #include <GUIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> Global $hGUI = GUICreate("Test") Global $iW = 150, $iH = 30 Global $hHelp = GUICreate("", $iW, $iH, 20, 20, $WS_CHILD, 0, $hGUI) Global $idLabel = GUICtrlCreateLabel("", 0, 0, $iW, $iH) GUICtrlSetBkColor(-1, 0x6BEFF5) GUICtrlCreateInput("", 5, 5, $iW - 10, $iH - 10, -1, $WS_EX_TOOLWINDOW) GUICtrlSetBkColor(-1, 0x6BEFF5) _WinAPI_SetParent($hHelp, $hGui) Global $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hHelp, $hRgn) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hHelp) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ioa747 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
drapdv Posted February 26 Author Share Posted February 26 (edited) Nine, Thank you so much for this! I have just one more question. Is it possible to have more than one label/input child window? I've tried to add one, using WinMove to position it within the $hGUI parent. While both display, the first one becomes unresponsive. Thank you again for your help! expandcollapse popup#include <GUIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> Global $hGUI = GUICreate("Test") Global $iW = 150, $iH = 30 Global $hLabel1 = GUICreate("", $iW, $iH, 20, 20, $WS_CHILD, 0, $hGUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateInput("INPUT1", 5, 5, $iW - 10, $iH - 10, -1, $WS_EX_TOOLWINDOW) GUICtrlSetBkColor(-1, 0xFFFFFF) WinMove($hLabel1, "", 0, 30, 150, 30) _WinAPI_SetParent($hLabel1, $hGui) Global $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hLabel1, $hRgn) Global $hLabel2 = GUICreate("", $iW, $iH, 20, 20, $WS_CHILD, 0, $hGUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlCreateInput("INPUT2", 5, 5, $iW - 10, $iH - 10, -1, $WS_EX_TOOLWINDOW) GUICtrlSetBkColor(-1, 0xFFFF00) WinMove($hLabel2, "", 0, 70, 150, 30) _WinAPI_SetParent($hLabel2, $hGui) Global $hRgn2 = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hLabel2, $hRgn2) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hLabel1) GUISetState(@SW_SHOW, $hLabel2) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Edited February 26 by drapdv Link to comment Share on other sites More sharing options...
Nine Posted February 27 Share Posted February 27 (edited) Here a better approach for multiple children (w/ code revision). You can tab from one input to the other. expandcollapse popup#include <GUIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> Global $hGUI = GUICreate("Multiple Childs") GUISetState() Global $iW = 150, $iH = 30 Global $hLabel1 = GUICreate("", $iW, $iH, 20, 20, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetBkColor(-1, 0xFFFFFF) $idInput1 = GUICtrlCreateInput("INPUT1", 5, 5, $iW - 10, $iH - 10, -1, $WS_EX_TOOLWINDOW) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hLabel1, $hRgn) GUISetState() Global $hLabel2 = GUICreate("", $iW, $iH, 20, 60, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetBkColor(-1, 0xFFFF00) $idInput2 = GUICtrlCreateInput("INPUT2", 5, 5, $iW - 10, $iH - 10, -1, $WS_EX_TOOLWINDOW) GUICtrlSetBkColor(-1, 0xFFFF00) Global $hRgn2 = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hLabel2, $hRgn2) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Not sure about WinMove (did not test), but the problem was not it... Edited February 27 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
drapdv Posted February 27 Author Share Posted February 27 Thank you again, Nine. I will play around with this and see what I can do. Cheers! Link to comment Share on other sites More sharing options...
ioa747 Posted February 28 Share Posted February 28 different approach: using-gui_gr_bezier I know that I know nothing Link to comment Share on other sites More sharing options...
drapdv Posted March 12 Author Share Posted March 12 Thank you, ioa747. I appreciate your example, too. I ended up building a function based on Nine's code, but there may well be advantages to using $GUI_GR_BEZIER. Again, thank you for replying. ioa747 1 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