I'm trying to learn tic's awesome GDI+ library, but have gotten a little confused about text.
Below is a sample of code adapted from example #8 in the GDI+ documentation.
#Include, Gdip.ahk pToken := Gdip_Startup() Width = 300 Height = 200 Options = x10p y30p w80p Centre cbbffffff r4 s20 Underline Italic Text = Tutorial 8`n`nThank you for trying this example Font = Arial DetectHiddenWindows, On Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop hwnd1 := WinExist() hbm := CreateDIBSection(Width, Height) hdc := CreateCompatibleDC() obm := SelectObject(hdc, hbm) G := Gdip_GraphicsFromHDC(hdc) Gdip_SetSmoothingMode(G, 4) pBrush := Gdip_BrushCreateSolid(0xAA000000) [color=red]Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)[/color] Gdip_DeleteBrush(pBrush) [color=violet]Gdip_TextToGraphics(G, Text, Options, Font, Width, Height)[/color] UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height) SelectObject(hdc, obm) DeleteObject(hbm) DeleteDC(hdc) Gdip_DeleteGraphics(G) Gui, 1: Show, NA w300 h300 Return Esc:: [color=orange]Gdip_Shutdown(pToken)[/color] ExitApp
This code draws a rectangle and writes the given message onto the rectangle. (This occurs at the line in violet.)
What I would like to do is to JUST write the text onto a gui without a rectangle. Sort of like the green OSD example in the GUI documentation, or like the screenshot in this script <!-- m -->http://www.autohotke...topic63584.html<!-- m --> . However, when I remove the line in red (the one that creates the rectangle), NOTHING happens. No text or rectangle.
How do I just add text to a bare canvas? Am I missing something?
(Also, is doing Gdip_Shutdown really necessary if I will be exiting the script anyway? Just curious.)