Автор: Maza Faka
Дата сообщения: 12.08.2008 10:52
NIKZZZZ
В общем вот, быстрый и грубый пример изменения шрифта в MsgBox:
Код: #include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <WinAPI.au3>
#include <FontConstants.au3>
Global $hCallBack = DllCallbackRegister("_MsgBoxCustomize", "none", "hwnd;int;int;dword")
$IDTimer = DllCall("user32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 10, "ptr", DllCallbackGetPtr($hCallBack))
MsgBox(0, "Message", "Hello world! AutoIt Rulez! Hello world! AutoIt Rulez!")
Func _MsgBoxCustomize($hWnd, $Msg, $IdTimer, $dwTime)
If WinExists("Message") Then
DllCallbackFree($hCallBack)
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $IDTimer)
Local $hFont, $hDC, $TextFont, $hOldFont, $sText, $tSize, $aWinPos, $aTextPos
$hWnd = WinGetHandle("Message")
$aWinPos = WinGetPos("Message")
$hText = ControlGetHandle($hWnd, "", "Static1")
$aTextPos = ControlGetPos($hWnd, "", $hText)
$hFont = _CreateFont($hText, 12, 800, 2, "Arial")
$hDC = _WinAPI_GetDC($hText)
$TextFont = _SendMessage($hText, $WM_GETFONT)
$OldFont = _WinAPI_SelectObject($hDC, $TextFont)
$sText = ControlGetText($hWnd, "", $hText)
$tSize = _WinAPI_GetTextExtentPoint32($hDC, $sText & " ")
ControlMove($hWnd, "", $hText, $aTextPos[0], $aTextPos[1], DllStructGetData($tSize, "X") + 20, DllStructGetData($tSize, "Y") + 20)
$aTextPos = ControlGetPos($hWnd, "", $hText)
WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], $aTextPos[2] + 10, $aWinPos[3] + 10)
_WinAPI_SetFont($hText, $hFont)
_WinAPI_SelectObject($hDC, $OldFont)
_WinAPI_DeleteObject($hFont)
_WinAPI_ReleaseDC($hWnd, $hDC)
EndIf
EndFunc
Func _CreateFont($hWnd, $nFontSize, $nFontWeight, $nFontAtrribute, $nFont)
Local $hDc = _WinAPI_GetDC($hWnd)
Local $nPixel = DllCall("gdi32.dll", "int", "GetDeviceCaps", "hwnd", $hDc, "int", $LOGPIXELSY)
Local $nHeight = DllCall("kernel32.dll", "int", "MulDiv", "int", $nFontSize, "int", $nPixel[0], "int", 72)
Local $hFont = DllCall("gdi32.dll", "hwnd", "CreateFont", "int", $nHeight[0], "int", 0, _
"int", 0, "int", 0, "int", $nFontWeight, "dword", BitAND($nFontAtrribute, 2), _
"dword", BitAND($nFontAtrribute, 4), "dword", BitAND($nFontAtrribute, 8), "int", $DEFAULT_CHARSET, _
"int", $OUT_DEFAULT_PRECIS, "int", $CLIP_DEFAULT_PRECIS, "int", $DEFAULT_QUALITY, "int", 0, _
"str", $nFont)
_WinAPI_ReleaseDC($hWnd, $hDC)
Return $hFont[0]
EndFunc