Jump to content

Changing MsgBox font


Recommended Posts

  • Moderators

Chaym,

Yes, but this would be a system wide setting change which may not be a good idea. Take a look at my ExtMsgBox UDF (link is in my sig) - it lets you set font, colour and a whole lot more. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

It is possible to change the font of a standard MessageBox. Find attached a real quick and dirty proof of concept using snippets from these two posts:

The SetFont() function from this post

In-cooperated into this shell-hooking example

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListboxConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>
 
Global $hFont = 0
 
#NoTrayIcon
Opt("GUICloseOnESC", 0)
Opt("GUIOnEventMode", 1)
Opt("WinWaitDelay", 0)
 
;~ Global Const $WM_SYSCOMMAND = 0x0112
Global Const $SC_MOVE = 0xF010
Global Const $SC_SIZE = 0xF000
Global Const $SC_CLOSE = 0xF060
 
;ShellHook notification codes:
Global Const $HSHELL_WINDOWCREATED = 1;
Global Const $HSHELL_WINDOWDESTROYED = 2;
Global Const $HSHELL_ACTIVATESHELLWINDOW = 3;
Global Const $HSHELL_WINDOWACTIVATED = 4;
Global Const $HSHELL_GETMINRECT = 5;
Global Const $HSHELL_REDRAW = 6;
Global Const $HSHELL_TASKMAN = 7;
Global Const $HSHELL_LANGUAGE = 8;
Global Const $HSHELL_SYSMENU = 9;
Global Const $HSHELL_ENDTASK = 10;
Global Const $HSHELL_ACCESSIBILITYSTATE = 11;
Global Const $HSHELL_APPCOMMAND = 12;
Global Const $HSHELL_WINDOWREPLACED = 13;
Global Const $HSHELL_WINDOWREPLACING = 14;
Global Const $HSHELL_RUDEAPPACTIVATED = 32772;
Global Const $HSHELL_FLASH = 32774;
 
Global $bHook = 1
;GUI stuff:
 
Global $iGuiW = 400, $iGuiH = 50, $sTitle = "Shell Hooker", $aBtnText[2] = ["START", "STOP"]
$hGui = GUICreate($sTitle, $iGuiW, $iGuiH, -1, 0, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "SysEvents")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SysEvents")
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
$cBtnMini = GUICtrlCreateButton("v", $iGuiW - $iGuiH, 0, $iGuiH / 2, $iGuiH / 2)
GUICtrlSetOnEvent(-1, "CtrlEvents")
GUICtrlSetTip(-1, "Minimize")
$cBtnClose = GUICtrlCreateButton("X", $iGuiW - $iGuiH / 2, 0, $iGuiH / 2, $iGuiH / 2)
GUICtrlSetOnEvent(-1, "CtrlEvents")
GUICtrlSetTip(-1, "Exit")
$cBtnHook = GUICtrlCreateButton("", $iGuiW - $iGuiH, $iGuiH / 2, $iGuiH, $iGuiH / 2)
GUICtrlSetData(-1, $aBtnText[$bHook])
GUICtrlSetTip(-1, "Hook/Unhook Shell")
GUICtrlSetOnEvent(-1, "CtrlEvents")
$cList = GUICtrlCreateList("", 0, 0, $iGuiW - $iGuiH - 1, $iGuiH, $LBS_NOINTEGRALHEIGHT + $WS_VSCROLL)
GUICtrlSetOnEvent(-1, "CtrlEvents")
 
;Hook stuff:
GUIRegisterMsg(RegisterWindowMessage("SHELLHOOK"), "HShellWndProc")
ShellHookWindow($hGui, $bHook)
 
 
GUISetState()
 
Sleep(1000)
 
MsgBox(0, "Test_MsgBox", "Test")
 
While 1
Sleep(1000)
WEnd
 
Func SysEvents()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_PRIMARYDOWN
;CTRL + Left click to drag GUI
If _IsPressed("11") Then
DllCall("user32.dll", "int", "ReleaseCapture")
DllCall("user32.dll", "int", "SendMessage", "hWnd", $hGui, "int", 0xA1, "int", 2, "int", 0)
EndIf
EndSwitch
EndFunc   ;==>SysEvents
Func CtrlEvents()
Switch @GUI_CtrlId
Case $cBtnMini
GUISetState(@SW_MINIMIZE)
Case $cBtnClose
_SendMessage($hGui, $WM_SYSCOMMAND, $SC_CLOSE, 0)
Case $cBtnHook
$bHook = BitXOR($bHook, 1)
ShellHookWindow($hGui, $bHook)
GUICtrlSetData($cBtnHook, $aBtnText[$bHook])
EndSwitch
EndFunc   ;==>CtrlEvents
Func HShellWndProc($hWnd, $Msg, $wParam, $lParam)
Switch $wParam
Case $HSHELL_WINDOWCREATED
MsgPrint("Window created: " & $lParam & " (" & WinGetTitle($lParam) & ")")
 
If WinGetTitle($lParam) = "Test_MsgBox" Then
WinMove($lParam, "", 100, 100, 400, 400)
Local $hHandle = ControlGetHandle($lParam, "", "Static1")
SetFont($hHandle, 18, 800, 0, 'Arial')
EndIf
 
Case $HSHELL_WINDOWDESTROYED
MsgPrint("Window destroyed: " & $lParam)
Case $HSHELL_ACTIVATESHELLWINDOW
MsgPrint("HSHELL_ACTIVATESHELLWINDOW: Not used.");
Case $HSHELL_WINDOWACTIVATED
MsgPrint("Window activated: " & $lParam & " (" & WinGetTitle($lParam) & ")")
Case $HSHELL_GETMINRECT
Local $tSHELLHOOKINFO = DllStructCreate("hwnd hwnd;int left;long top;long right;long bottom", $lParam)
MsgPrint("HSHELL_GETMINRECT: " & HWnd(DllStructGetData($tSHELLHOOKINFO, "hwnd")) & ' (' & _
DllStructGetData($tSHELLHOOKINFO, "left") & ',' & _
DllStructGetData($tSHELLHOOKINFO, "top") & ',' & _
DllStructGetData($tSHELLHOOKINFO, "right") & ',' & _
DllStructGetData($tSHELLHOOKINFO, "bottom") & ')')
Case $HSHELL_REDRAW
MsgPrint("Window redraw: " & $lParam & " (" & WinGetTitle($lParam) & ")")
Case $HSHELL_TASKMAN
MsgPrint("HSHELL_TASKMAN: Can be ignored.");
Case $HSHELL_LANGUAGE
MsgPrint("HSHELL_LANGUAGE: " & $lParam);
Case $HSHELL_SYSMENU
MsgPrint("HSHELL_SYSMENU: " & $lParam);
Case $HSHELL_ENDTASK
MsgPrint("Window needs to be closed: " & $lParam & " (" & WinGetTitle($lParam) & ")")
Case $HSHELL_ACCESSIBILITYSTATE
MsgPrint("HSHELL_ACCESSIBILITYSTATE: " & $lParam);
Case $HSHELL_APPCOMMAND
MsgPrint("HSHELL_APPCOMMAND: " & $lParam);
Case $HSHELL_WINDOWREPLACED
MsgPrint("Window replaced: " & $lParam & " (" & WinGetTitle($lParam) & ")")
Case $HSHELL_WINDOWREPLACING
MsgPrint("Window replacing: " & $lParam & " (" & WinGetTitle($lParam) & ")")
Case $HSHELL_RUDEAPPACTIVATED
MsgPrint("HSHELL_RUDEAPPACTIVATED: " & $lParam);
Case $HSHELL_FLASH
MsgPrint("Window flash: " & $lParam & " (" & WinGetTitle($lParam) & ")")
Case Else
MsgPrint("Unknown ShellHook message: " & $wParam & " , " & $lParam)
EndSwitch
EndFunc   ;==>HShellWndProc
;register/unregister ShellHook
Func ShellHookWindow($hWnd, $bFlag)
Local $sFunc = 'DeregisterShellHookWindow'
If $bFlag Then $sFunc = 'RegisterShellHookWindow'
Local $aRet = DllCall('user32.dll', 'int', $sFunc, 'hwnd', $hWnd)
MsgPrint($sFunc & ' = ' & $aRet[0])
Return $aRet[0]
EndFunc   ;==>ShellHookWindow
Func MsgPrint($sText)
ConsoleWrite($sText & @CRLF)
GUICtrlSendMsg($cList, $LB_SETCURSEL, GUICtrlSendMsg($cList, $LB_ADDSTRING, 0, $sText), 0)
EndFunc   ;==>MsgPrint
;register window message
Func RegisterWindowMessage($sText)
Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessage', 'str', $sText)
Return $aRet[0]
EndFunc   ;==>RegisterWindowMessage
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
Switch BitAND($wParam, 0xFFF0)
Case $SC_MOVE, $SC_SIZE
Case $SC_CLOSE
ShellHookWindow($hGui, 0)
Return $GUI_RUNDEFMSG
;Exit
EndSwitch
EndFunc   ;==>On_WM_SYSCOMMAND
 
 
; Set/create the font
Func SetFont($hWnd, $nSize, $nWeight, $nAtrribute, $szFont)
 
If $hFont = 0 Then
$hDc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $hWnd)
$nPixel = DllCall("gdi32.dll", "int", "GetDeviceCaps", "hwnd", $hDc[0], "int", 90)
$nHeight = DllCall("kernel32.dll", "int", "MulDiv", "int", $nSize, "int", $nPixel[0], "int", 72)
$hFont = DllCall('gdi32.dll', 'hwnd', 'CreateFont', _
'int', -$nHeight[0], _
'int', 0, _
'int', 0, _
'int', 0, _
'int', $nWeight, _
'int', BitAND($nAtrribute, 2), _
'int', BitAND($nAtrribute, 4), _
'int', BitAND($nAtrribute, 8), _
'int', 1, _
'int', 0, _
'int', 0, _
'int', 0, _
'int', 0, _
'str', $szFont)
EndIf
 
; Other possibility to select a font to the control:
;
; $hFont = DllCall('gdi32.dll', 'hwnd', 'GetStockObject', 'int', 11); Get "DEFAULT_GUI_FONT"
;
;   -> font numbers can be :
;   OEM_FIXED_FONT    10
;   ANSI_FIXED_FONT  11
;   ANSI_VAR_FONT      12
;   SYSTEM_FONT      13
;   DEVICE_DEFAULT_FONT 14
;   DEFAULT_PALETTE  15
;   SYSTEM_FIXED_FONT   16
;   DEFAULT_GUI_FONT    17
;
;   ! DeleteFont($hFont) before 'Exit' has to be commented out !
 
SendMessage($hWnd, $WM_SETFONT, $hFont[0], 1)
EndFunc   ;==>SetFont
 
Func SendMessage($hWnd, $Msg, $wParam = 0, $lParam = 0)
$a_Ret = DllCall('user32.dll', 'int', 'SendMessage', _
'hwnd', $hWnd, _
'int', $Msg, _
'int', $wParam, _
'int', $lParam)
Return $a_Ret[0]
EndFunc   ;==>SendMessage
Link to comment
Share on other sites

  • 5 years later...

In the code listed above, I found it was necessary to comment out the group of global variables related to Shellhook notification codes to get it to run, to avoid a "cannot declare variable twice" error. I assume the code ran as-is when originally posted in 2014, so just making a guess, perhaps these constants are now included in an updated version of the include files used by the code? I see this post is from 2014, so that may have changed since then.

It also doesn't quite work properly for me when I run it, see screenshot. Is there any chance the new values of these variables are different, assuming it is the case that they are now in one of the include files?

I see the changing msgbox appearance is a common question. This thread could be on the right track, in that if there were a way to store the windows default font settings, then change them temporarily, show a msgbox, then restore them, might be useful... though a bit of a dirty solution.

Custom message boxes are the most robust answer but it could also be useful (and much easier) to have a way to do the above.

Anyway just brainstorming. I use custom message boxes for this purpose currently and am satisfied with that. Just brainstorming randomly in a zombie thread. :)

 

screenshot.jpg

Link to comment
Share on other sites

Regarding 2014 you are right, the autoit codebase was changed and now includes these values.

Beside the window also the label and button have to be resized / moved, see

; MsgBox - Label

; MsgBox - Button1

Note that I did not include dynamic calc for label as I did for the button to show the grey background being covered. That's not a control, I don't know how to move that, maybe add a faked grey label?

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListboxConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>

Global $hFont = 0

#NoTrayIcon
Opt("GUICloseOnESC", 0)
Opt("GUIOnEventMode", 1)
Opt("WinWaitDelay", 0)

;~ Global Const $WM_SYSCOMMAND = 0x0112
Global Const $SC_MOVE = 0xF010
Global Const $SC_SIZE = 0xF000
Global Const $SC_CLOSE = 0xF060

;ShellHook notification codes:
#cs
    Global Const $HSHELL_WINDOWCREATED = 1 ;
    Global Const $HSHELL_WINDOWDESTROYED = 2 ;
    Global Const $HSHELL_ACTIVATESHELLWINDOW = 3 ;
    Global Const $HSHELL_WINDOWACTIVATED = 4 ;
    Global Const $HSHELL_GETMINRECT = 5 ;
    Global Const $HSHELL_REDRAW = 6 ;
    Global Const $HSHELL_TASKMAN = 7 ;
    Global Const $HSHELL_LANGUAGE = 8 ;
    Global Const $HSHELL_SYSMENU = 9 ;
    Global Const $HSHELL_ENDTASK = 10 ;
    Global Const $HSHELL_ACCESSIBILITYSTATE = 11 ;
    Global Const $HSHELL_APPCOMMAND = 12 ;
    Global Const $HSHELL_WINDOWREPLACED = 13 ;
    Global Const $HSHELL_WINDOWREPLACING = 14 ;
    Global Const $HSHELL_RUDEAPPACTIVATED = 32772 ;
    Global Const $HSHELL_FLASH = 32774 ;
#ce

Global $bHook = 1
;GUI stuff:

Global $iGuiW = 400, $iGuiH = 50, $sTitle = "Shell Hooker", $aBtnText[2] = ["START", "STOP"]
$hGui = GUICreate($sTitle, $iGuiW, $iGuiH, -1, 0, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "SysEvents")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SysEvents")
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
$cBtnMini = GUICtrlCreateButton("v", $iGuiW - $iGuiH, 0, $iGuiH / 2, $iGuiH / 2)
GUICtrlSetOnEvent(-1, "CtrlEvents")
GUICtrlSetTip(-1, "Minimize")
$cBtnClose = GUICtrlCreateButton("X", $iGuiW - $iGuiH / 2, 0, $iGuiH / 2, $iGuiH / 2)
GUICtrlSetOnEvent(-1, "CtrlEvents")
GUICtrlSetTip(-1, "Exit")
$cBtnHook = GUICtrlCreateButton("", $iGuiW - $iGuiH, $iGuiH / 2, $iGuiH, $iGuiH / 2)
GUICtrlSetData(-1, $aBtnText[$bHook])
GUICtrlSetTip(-1, "Hook/Unhook Shell")
GUICtrlSetOnEvent(-1, "CtrlEvents")
$cList = GUICtrlCreateList("", 0, 0, $iGuiW - $iGuiH - 1, $iGuiH, $LBS_NOINTEGRALHEIGHT + $WS_VSCROLL)
GUICtrlSetOnEvent(-1, "CtrlEvents")

; MsgBox(0, "Test_MsgBox", "Test")

;Hook stuff:
GUIRegisterMsg(RegisterWindowMessage("SHELLHOOK"), "HShellWndProc")
ShellHookWindow($hGui, $bHook)

GUISetState()

; Sleep(1000)

MsgBox(0, "Test_MsgBox", "Test")

#cs
    While Sleep(10)
    WEnd
#ce
Exit

Func SysEvents()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            ;CTRL + Left click to drag GUI
            If _IsPressed("11") Then
                DllCall("user32.dll", "int", "ReleaseCapture")
                DllCall("user32.dll", "int", "SendMessage", "hWnd", $hGui, "int", 0xA1, "int", 2, "int", 0)
            EndIf
    EndSwitch
EndFunc   ;==>SysEvents

Func CtrlEvents()
    Switch @GUI_CtrlId
        Case $cBtnMini
            GUISetState(@SW_MINIMIZE)
        Case $cBtnClose
            _SendMessage($hGui, $WM_SYSCOMMAND, $SC_CLOSE, 0)
        Case $cBtnHook
            $bHook = BitXOR($bHook, 1)
            ShellHookWindow($hGui, $bHook)
            GUICtrlSetData($cBtnHook, $aBtnText[$bHook])
    EndSwitch
EndFunc   ;==>CtrlEvents

Func HShellWndProc($hWnd, $Msg, $wParam, $lParam)
    Switch $wParam
        Case $HSHELL_WINDOWCREATED
            MsgPrint("Window created: " & $lParam & " (" & WinGetTitle($lParam) & ")")

            If WinGetTitle($lParam) = "Test_MsgBox" Then

                ; MsgBox - Window
                WinMove($lParam, "", 100, 100, 400, 400)
                Local $aWinSize = WinGetPos($lParam)

                ; MsgBox - Label
                Local $hHandle_label = ControlGetHandle($lParam, "", "Static1")
                WinMove($hHandle_label, "", 0, 0, 100, 100)
                SetFont($hHandle_label, 18, 800, 0, 'Arial')

                ; MsgBox - Button1
                Local $hHandle_button1 = ControlGetHandle($lParam, "", "Button1")
                Local $aButtonPos = WinGetPos($hHandle_button1)
                WinMove($hHandle_button1, "", ($aWinSize[2] / 2) - ($aButtonPos[2] / 2), ($aWinSize[3]) - ($aButtonPos[3]) - 50)

            EndIf

        Case $HSHELL_WINDOWDESTROYED
            MsgPrint("Window destroyed: " & $lParam)
        Case $HSHELL_ACTIVATESHELLWINDOW
            MsgPrint("HSHELL_ACTIVATESHELLWINDOW: Not used.") ;
        Case $HSHELL_WINDOWACTIVATED
            MsgPrint("Window activated: " & $lParam & " (" & WinGetTitle($lParam) & ")")
        Case $HSHELL_GETMINRECT
            Local $tSHELLHOOKINFO = DllStructCreate("hwnd hwnd;int left;long top;long right;long bottom", $lParam)
            MsgPrint("HSHELL_GETMINRECT: " & HWnd(DllStructGetData($tSHELLHOOKINFO, "hwnd")) & ' (' & _
                    DllStructGetData($tSHELLHOOKINFO, "left") & ',' & _
                    DllStructGetData($tSHELLHOOKINFO, "top") & ',' & _
                    DllStructGetData($tSHELLHOOKINFO, "right") & ',' & _
                    DllStructGetData($tSHELLHOOKINFO, "bottom") & ')')
        Case $HSHELL_REDRAW
            MsgPrint("Window redraw: " & $lParam & " (" & WinGetTitle($lParam) & ")")
        Case $HSHELL_TASKMAN
            MsgPrint("HSHELL_TASKMAN: Can be ignored.") ;
        Case $HSHELL_LANGUAGE
            MsgPrint("HSHELL_LANGUAGE: " & $lParam) ;
        Case $HSHELL_SYSMENU
            MsgPrint("HSHELL_SYSMENU: " & $lParam) ;
        Case $HSHELL_ENDTASK
            MsgPrint("Window needs to be closed: " & $lParam & " (" & WinGetTitle($lParam) & ")")
        Case $HSHELL_ACCESSIBILITYSTATE
            MsgPrint("HSHELL_ACCESSIBILITYSTATE: " & $lParam) ;
        Case $HSHELL_APPCOMMAND
            MsgPrint("HSHELL_APPCOMMAND: " & $lParam) ;
        Case $HSHELL_WINDOWREPLACED
            MsgPrint("Window replaced: " & $lParam & " (" & WinGetTitle($lParam) & ")")
        Case $HSHELL_WINDOWREPLACING
            MsgPrint("Window replacing: " & $lParam & " (" & WinGetTitle($lParam) & ")")
        Case $HSHELL_RUDEAPPACTIVATED
            MsgPrint("HSHELL_RUDEAPPACTIVATED: " & $lParam) ;
        Case $HSHELL_FLASH
            MsgPrint("Window flash: " & $lParam & " (" & WinGetTitle($lParam) & ")")
        Case Else
            MsgPrint("Unknown ShellHook message: " & $wParam & " , " & $lParam)
    EndSwitch
EndFunc   ;==>HShellWndProc
;register/unregister ShellHook
Func ShellHookWindow($hWnd, $bFlag)
    Local $sFunc = 'DeregisterShellHookWindow'
    If $bFlag Then $sFunc = 'RegisterShellHookWindow'
    Local $aRet = DllCall('user32.dll', 'int', $sFunc, 'hwnd', $hWnd)
    MsgPrint($sFunc & ' = ' & $aRet[0])
    Return $aRet[0]
EndFunc   ;==>ShellHookWindow
Func MsgPrint($sText)
    ConsoleWrite($sText & @CRLF)
    GUICtrlSendMsg($cList, $LB_SETCURSEL, GUICtrlSendMsg($cList, $LB_ADDSTRING, 0, $sText), 0)
EndFunc   ;==>MsgPrint
;register window message
Func RegisterWindowMessage($sText)
    Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessage', 'str', $sText)
    Return $aRet[0]
EndFunc   ;==>RegisterWindowMessage
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Switch BitAND($wParam, 0xFFF0)
        Case $SC_MOVE, $SC_SIZE
        Case $SC_CLOSE
            ShellHookWindow($hGui, 0)
            Return $GUI_RUNDEFMSG
            ;Exit
    EndSwitch
EndFunc   ;==>On_WM_SYSCOMMAND


; Set/create the font
Func SetFont($hWnd, $nSize, $nWeight, $nAtrribute, $szFont)

    If $hFont = 0 Then
        $hDc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $hWnd)
        $nPixel = DllCall("gdi32.dll", "int", "GetDeviceCaps", "hwnd", $hDc[0], "int", 90)
        $nHeight = DllCall("kernel32.dll", "int", "MulDiv", "int", $nSize, "int", $nPixel[0], "int", 72)
        $hFont = DllCall('gdi32.dll', 'hwnd', 'CreateFont', _
                'int', -$nHeight[0], _
                'int', 0, _
                'int', 0, _
                'int', 0, _
                'int', $nWeight, _
                'int', BitAND($nAtrribute, 2), _
                'int', BitAND($nAtrribute, 4), _
                'int', BitAND($nAtrribute, 8), _
                'int', 1, _
                'int', 0, _
                'int', 0, _
                'int', 0, _
                'int', 0, _
                'str', $szFont)
    EndIf

    ; Other possibility to select a font to the control:
    ;
    ; $hFont = DllCall('gdi32.dll', 'hwnd', 'GetStockObject', 'int', 11); Get "DEFAULT_GUI_FONT"
    ;
    ;   -> font numbers can be :
    ;   OEM_FIXED_FONT    10
    ;   ANSI_FIXED_FONT  11
    ;   ANSI_VAR_FONT      12
    ;   SYSTEM_FONT      13
    ;   DEVICE_DEFAULT_FONT 14
    ;   DEFAULT_PALETTE  15
    ;   SYSTEM_FIXED_FONT   16
    ;   DEFAULT_GUI_FONT    17
    ;
    ;   ! DeleteFont($hFont) before 'Exit' has to be commented out !

    SendMessage($hWnd, $WM_SETFONT, $hFont[0], 1)
EndFunc   ;==>SetFont

Func SendMessage($hWnd, $Msg, $wParam = 0, $lParam = 0)
    $a_Ret = DllCall('user32.dll', 'int', 'SendMessage', _
            'hwnd', $hWnd, _
            'int', $Msg, _
            'int', $wParam, _
            'int', $lParam)
    Return $a_Ret[0]
EndFunc   ;==>SendMessage

 

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...