Разобрался в примере:
; Example 8: Gdip.Tutorial.8-Write.text.onto.a.gui.ahk http://www.autohotkey.net/~tic/Gdip.Tutorial.8-Write.text.onto.a.gui.ahk
#SingleInstance Force
SetBatchLines -1
If !pToken := Gdip_Startup() {
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
OnMessage(0x201, "WM_LBUTTONDOWN")
Width := 400, Height := 250
BackTrans = ba
BackColor = 2943AF
Font = Arial
FontSize = 42
FontColor = ffffff
Text = Tutorial 8`nThank you for trying this example
Options = x10p y10p w80p Centre cff%FontColor% r4 s%FontSize% Italic
Gui, +HWNDhGui -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs -DPIScale
Gui, Show, NA
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm), G := Gdip_GraphicsFromHDC(hdc), Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid("0x" BackTrans BackColor)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 10)
Gdip_DeleteBrush(pBrush)
If !Gdip_FontFamilyCreate(Font) {
MsgBox, 48, Font error!, The font you have specified does not exist on the system
ExitApp
}
Gdip_TextToGraphics(G, Text, Options, Font, Width, Height)
UpdateLayeredWindow(hGui, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G)
Return
WM_LBUTTONDOWN() {
PostMessage, 0xA1, 2
}
Esc::
Exit:
GuiClose:
GuiEscape:
Gdip_Shutdown(pToken)
ExitApp
Теперь такой вопрос: тут заранее указывается размер окну. А как можно сделать размер окна в зависимости от содержимого текста, по аналогии с этим:
#SingleInstance Force
Text1 = Tutorial 8`nThank you for trying this example
Text2 = 000`n0`n0`n0`n0`n0`n0`n0`n000
Text3 = ``
FontSize = 28
I = 0
Gui, +AlwaysOnTop +ToolWindow -Caption +DPIScale
Gui, Color, 2943AF
Gui, Font, s%FontSize% cffffff Italic, Times New Roman
Loop {
DllCall("DestroyWindow", "Ptr", hText), I := ++I > 3 ? 1 : I
Gui, Add, Text, % "Center hwndhText x" FontSize " y" FontSize / 2, % Text%I%
Gui, Show, AutoSize Center
Sleep 1111
}
Esc::
ExitApp
По вопросам возмездной помощи пишите на
E-Mail: serzh82saratov@mail.ru Telegram:
https://t.me/sergiol982Win10x64
AhkSpy,
Hotkey,
ClockGui