Viktor1703
AutoIT Гуру
- Сообщения
- 1,535
- Репутация
- 413
Создал контрол с помощью WinAPI, а сменить цвет текста и фона не получается
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <UDFGlobalID.au3>
$hForm = GUICreate("", 500, 300)
$Button = GUIControlStatic_Create($hForm, "Hello", 20, 20, 50, 20, 0x1000)
GUICtrlCreateButton("Hello", 20, 50, 50, 20)
GUISetState()
While 1
If GUIGetMsg() = -3 Then Exit
WEnd
Func GUIControlStatic_Create($hWnd, $Text, $iX, $iY, $iWidth = -1, $iHeight = -1, $iStyle = 0)
Local $hStyle = BitOR($iStyle, $WS_CHILD, $WS_VISIBLE, 0x1)
Local $hModule = DllCall("kernel32.dll", "handle", "GetModuleHandleW", "ptr", 0)
Local $hControl = DllCall("user32.dll", "hwnd", "CreateWindowExW", "dword", 0, "wstr", "Static", _
"wstr", $Text, "dword", $hStyle, "int", $iX, "int", $iY, _
"int", $iWidth, "int", $iHeight, "hwnd", $hWnd, _
"handle", __UDF_GetNextGlobalID($hWnd), "handle", $hModule[0], "ptr", 0)
Local $hDC = DllCall("user32.dll", "handle", "GetDC", "hwnd", 0)
Local $Pixel = DllCall("gdi32.dll", "int", "GetDeviceCaps", "hwnd", $hDC[0], "int", 90)
Local $Height = DllCall("kernel32.dll", "int", "MulDiv", "int", 11, "int", $Pixel[0], "int", 72)
Local $hFont = DllCall("gdi32.dll", "hwnd", "CreateFont", "int", $Height[0], "int", 0, _
"int", 0, "int", 0, "int", 500, "dword", BitAND(0, 2), _
"dword", BitAND(0, 4), "dword", BitAND(0, 8), "int", 1, _
"int", 0, "int", 0, "int", 0, "int", 0, "str", "Tahoma")
DllCall("user32.dll", "int", "SendMessage", "hwnd", $hControl[0], "int", 48, "int", $hFont[0], "int", 1)
DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hControl[0], "hwnd", $hDC[0])
DllCall("user32.dll", "int", "DeleteObject", "hwnd", $hFont[0])
Return $hControl[0]
EndFunc