Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/27/2024 in all areas

  1. Hi everybody The purpose of this post is to indicate how simple it is to change your "too small" Gui for a bigger one, resizing (or not) the associated controls font. 1) SampleControls.au3 The original example is found in AutoIt package (subfolder ..\Example\GUI) and displays its GUI like this : 2) "SampleControls (resizable Gui).au3" [ based on SampleControls.au3 ] If you want to enlarge the Gui because it appears too small depending on your screen resolution, here are the changes to apply, where the Gui is resizable but the control fonts are unchanged : ; Added ; ----- #include <StaticConstants.au3> ; center the label control #include <WindowsConstants.au3> ; $WS_OVERLAPPEDWINDOW Opt("GUIResizeMode", $GUI_DOCKAUTO) ;0 = (default) keep default control resizing , <1024 = any type of resizing ; Modified ; -------- ; GUICreate("Sample GUI", 400, 400) GUICreate("Sample GUI", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW) ; GUICtrlCreateLabel("Green" & @CRLF & "Label", 350, 165, 40, 40) GUICtrlCreateLabel("Label", 350, 165, 40, 40, BitOr($SS_CENTERIMAGE, $SS_CENTER)) 3) "SampleControls (resizable Gui & fonts).au3" [ based on "SampleControls (resizable Gui).au3" ] If you want to enlarge the Gui AND resize the controls font so they appear bigger, here are the changes to apply : ; Added ; ----- Global $hGUI, $iGUIInitSizeW = 400, $iLast_DummyControl $iLast_DummyControl = GUICtrlCreateDummy() ; just before GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SIZE, "WM_SIZE") Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI Then Local Static $iFontSize_Old = 0 Local $iParentW = BitAND($lParam, 0xFFFF) ; low word (new width of the client area) ; Local $iParentH = BitShift($lParam, 16) ; high word (new height of the client area) Local $iFontSize = Int(2 * (.5 + (8 * $iParentW / $iGUIInitSizeW))) / 2 If $iFontSize_Old <> $iFontSize Then For $i = 3 To $iLast_DummyControl - 1 ; 1st control in GUI is always 3 GUICtrlSetFont($i, $iFontSize) Next $iFontSize_Old = $iFontSize EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE ; Modified ; -------- ; GUICreate("Sample GUI", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW) $hGUI = GUICreate("Sample GUI", $iGUIInitSizeW, 400, -1, -1, $WS_OVERLAPPEDWINDOW) Below, a bolder font appears when more resizing is applied to the GUI : I just tried all this on a personal script and the results looked fine, hope it will be same for you. Big thanks to @Melba23 for his script, found here Mods, I don't know where this post should be placed on the Forum. Please move it if you think its place isn't the appropriate one, thanks.
    1 point
  2. Andreik

    TAB in Inputbox

    Here is a hacky way: #include <WinAPISysWin.au3> #include <GuiEdit.au3> HotKeySet('{TAB}', 'Tab') $hGUI = GUICreate('Test') $cInput1 = GUICtrlCreateInput('test', 100, 100, 150, 25) $hInput1 = GUICtrlGetHandle($cInput1) $cInput2 = GUICtrlCreateInput('', 100, 200, 150, 25) $cInput3 = GUICtrlCreateInput('', 100, 300, 150, 25) GUISetState() Do Until GUIGetMsg() = -3 Func Tab() HotKeySet('{TAB}') If _WinAPI_GetFocus() = $hInput1 Then _GUICtrlEdit_ReplaceSel($hInput1, @TAB) Else Send('{TAB}') EndIf HotKeySet('{TAB}', 'Tab') EndFunc
    1 point
  3. pixelsearch

    TAB in Inputbox

    @abberration here is a way to disable / enable $WS_TABSTOP (or another style) using a function named Alter_Style . You can indicate several controls when calling the function, as shown in the script lines that are commented out. After the style is disabled, the TAB key won't select anymore the control(s) which don't have this style. A similar function should be easy to script to take care of Extended styles. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Local $hGUI = GUICreate("TabStop", 316, 207) Local $Label1 = GUICtrlCreateLabel("Input1", 40, 40, 50, 17, $SS_CENTERIMAGE) Local $Input1 = GUICtrlCreateInput("123", 100, 40, 170, 20) Local $Label2 = GUICtrlCreateLabel("Input2", 40, 88, 50, 20, $SS_CENTERIMAGE) Local $Input2 = GUICtrlCreateInput("456", 100, 90, 170, 20) Local $idRemoveStyle = GUICtrlCreateButton("Remove TabStop ", 25, 155, 125, 25) Local $idAddStyle = GUICtrlCreateButton("Add TabStop", 170, 155, 125, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idRemoveStyle Alter_Style(0, $WS_TABSTOP, $Input1) ; Alter_Style(0, $WS_TABSTOP, $Input1, $Input2) ; Alter_Style(0, $WS_TABSTOP, $Input1, $Input2, $idRemoveStyle) Case $idAddStyle Alter_Style(1, $WS_TABSTOP, $Input1) ; Alter_Style(1, $WS_TABSTOP, $Input1, $Input2) ; Alter_Style(1, $WS_TABSTOP, $Input1, $Input2, $idRemoveStyle) EndSwitch WEnd ;=========================================== Func Alter_Style($iRemoveOrAdd, $iStyleToAlter, $id1, $id2 = 0, $id3 = 0, $id4 = 0, $id5 = 0, _ $id6 = 0, $id7 = 0, $id8 = 0, $id9 = 0, $id10 = 0) Local $hControl, $iStyle For $i = 1 To @NumParams - 2 $hControl = GUICtrlGetHandle(Eval("id" & $i)) $iStyle = _WinAPI_GetWindowLong($hControl, $GWL_STYLE) Switch $iRemoveOrAdd Case 0 ; remove style If BitAND($iStyle, $iStyleToAlter) = $iStyleToAlter Then _WinAPI_SetWindowLong($hControl, $GWL_STYLE, BitXOR($iStyle, $iStyleToAlter)) Endif Case 1 ; add style If BitAND($iStyle, $iStyleToAlter) <> $iStyleToAlter Then _WinAPI_SetWindowLong($hControl, $GWL_STYLE, BitOR($iStyle, $iStyleToAlter)) Endif Case Else MsgBox(0, "", "Scripter, wake up :)") EndSwitch Next EndFunc ;==>Alter_Style
    1 point
×
×
  • Create New...