SEKOMD Posted January 13 Posted January 13 Hi all! Please tell me how to make sure that the text does not disappear after minimizing/maximizing the window? #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hGraphics,4) _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 200, "Tahoma", 66) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example
ioa747 Posted January 13 Posted January 13 Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) DrawText($hGraphics) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE DrawText($hGraphics) EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Func DrawText($hGraphics) _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4) _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 200, "Tahoma", 66) EndFunc ;==>DrawText SEKOMD 1 I know that I know nothing
Nine Posted January 13 Posted January 13 One simple way is to use a back buffer : expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphic) Local $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 4) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example SEKOMD and ioa747 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
SEKOMD Posted January 13 Author Posted January 13 Thank you very much for your quick reply! But to be honest - I need the caption to be static, if I move the window off the screen and back - the caption is erased. How can I make it so that it is static? Never disappears, like GUICtrlCreateLabel? Please sorry my English!
Nine Posted January 13 Posted January 13 12 minutes ago, SEKOMD said: How can I make it so that it is static? Use a static control. But with GDI+ the way you are using it, you need to patch things up, like this : expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGraphic, $hBitmap Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphic) Local $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 4) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) GUIRegisterMsg($WM_MOVE, WM_MOVE) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) Return $GUI_RUNDEFMSG EndFunc SEKOMD 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
SEKOMD Posted January 14 Author Posted January 14 On 1/13/2025 at 3:34 PM, Nine said: Use a static control. But with GDI+ the way you are using it, you need to patch things up, like this : Thanks for the example! Everything works, but please tell me how to make it so that the anti-aliasing does not disappear after dragging the window? Anti-aliasing does not work when dragging a window...
Solution Nine Posted January 14 Solution Posted January 14 Did not notice that. Here one way : expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGraphic, $hBitmap, $hBuffer Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphic) $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) GUIRegisterMsg($WM_PAINT, WM_PAINT) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) EndSwitch WEnd _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam) _GDIPlus_GraphicsClear($hBuffer, 0xFFF0F0F0) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) Return $GUI_RUNDEFMSG EndFunc SEKOMD 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
SEKOMD Posted January 14 Author Posted January 14 52 minutes ago, Nine said: Did not notice that. Here one way : Thank you very much!!!! 😀
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now