Jump to content

InputBox with increased font size


Recommended Posts

Hi everybody
I needed to increase the font size of the text typed in the InputBox function, because it appears too small to my eyes.
This is how I scripted it, maybe it will be helpful to users who need it for the same reason.

#include <WinAPIGdiInternals.au3>
#include <WinAPISysWin.au3>
#Include <WindowsConstants.au3>

Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration

Global $g_sTitle ; 1 global variable for _TimerProc()
$g_sTitle = "InputBox with increased font size"

Local $sTextInput = _InputBox($g_sTitle, "Enter a string", "", " M", 300, 150) ; M means Mandatory
ConsoleWrite("$sTextInput = >" & $sTextInput & "<" & @crlf)

;===========================================
Func _InputBox($g_sTitle, $sPrompt, $sDefault = "", $sPasswordChar = "", $iWidth = -1, $iHeight = -1, $iLeft = Default, $iTop = Default, $iTimeOut = 0, $hWnd = 0)

    Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword')
    Local $iTimerID = _WinAPI_SetTimer(0, 0, 10, DllCallbackGetPtr($hTimerProc))

    Local $sTextInput = InputBox($g_sTitle, $sPrompt, $sDefault, $sPasswordChar, $iWidth, $iHeight, $iLeft, $iTop, $iTimeOut, $hWnd)

    _WinAPI_KillTimer(0, $iTimerID)
    DllCallbackFree($hTimerProc)

    Return $sTextInput
EndFunc   ;==>_InputBox

;===========================================
Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime)

    If WinActive($g_sTitle) Then
        _WinAPI_KillTimer(0, $iTimerID)
         Local $hCtrl = ControlGetHandle($g_sTitle, "", "Edit1") ; control where the InputBox string is typed
         Local $hFont = _WinAPI_CreateFont(16, 0)
         _SendMessage($hCtrl, $WM_SETFONT, $hFont, False) ; False = do not redraw the control immediately
         _WinAPI_DeleteObject($hFont)
    EndIf
EndFunc   ;==>_TimerProc

InputBoxwithincreasedfontsize.png.ceb2b3cd655157bf8190899bb813fb8e.png

Have a great day :bye:

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...