charvi Posted December 11, 2008 Share Posted December 11, 2008 Hello,If you have an active ScreenSaver, resuming the screen will not redraw the GDIPlus elements - if drawn on a picture at least. Is this normal? How to avoid this behaviour?This is a snippet of the code that does not reappear:$h_Wnd = WinGetHandle($h_Win) GUISetState() _GDIPlus_Startup() $h_Graph2 = _GDIPlus_GraphicsCreateFromHWND($h_Wnd) $h_Pen = _GDIPlus_PenCreate() _GDIPlus_PenSetColor($h_Pen, 0xff838b83) _GDIPlus_GraphicsDrawRect($h_Graph2, 5, 62, $ci_ScreenW-10, $ci_ProgramBodyH-68, $h_Pen) _GDIPlus_PenDispose($h_Pen) _GDIPlus_GraphicsDispose($h_Graph2) _GDIPlus_Shutdown() Link to comment Share on other sites More sharing options...
ProgAndy Posted December 11, 2008 Share Posted December 11, 2008 yes, this is normal. to save it, you have to zse the UDF _setimage or redraw on WM_PAINT *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
charvi Posted December 11, 2008 Author Share Posted December 11, 2008 yes, this is normal. to save it, you have to zse the UDF _setimage or redraw on WM_PAINTAh, OK, but I'm not sure how to do that with WM_PAINT or _setimage. Even when using Alt+Tab to toggle windows, they clear the GDI+ stuff. In my thoughts, screens must then be constantly redrawn - if we want to be sure we are not missing anything. Link to comment Share on other sites More sharing options...
charvi Posted December 11, 2008 Author Share Posted December 11, 2008 Never mind, I found it. Zedna already told it to me how to draw on a picture, but I did not knew that it was keeping the drawings too. Ohmy, what does it become a bit more complex! It remains however easy when using discipline, that I will now share here: First, create a window: $h_Win = GUICreate("My window") Then, put the pictures: $h_Pic = GUICtrlCreatePic(@ScriptDir & "\image.jpg", 0, 0, 200, 150) Then, write a block to draw the GDI elements: ; ## Special Painting with GDI+ $h_Wnd = WinGetHandle($h_Win) _GDIPlus_Startup() $h_Graph = _GDIPlus_GraphicsCreateFromHWND($h_Wnd) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") Then, display everything: GUISetState() Then, when you leave the script, dispose the graphic elements and close the GDI: _GDIPlus_PenDispose($h_Pen) _GDIPlus_GraphicsDispose($h_Graph) _GDIPlus_Shutdown() Then, add a Func MY_WM_PAINT() with your drawings: Func MY_WM_PAINT() _WinAPI_RedrawWindow($h_Pic_H, 0, 0, $RDW_UPDATENOW); force redraw of pic (Rect=0 Region=0) ; Below is my WM Paint ===================================================================== $h_Pen = _GDIPlus_PenCreate() _GDIPlus_PenSetColor($h_Pen, 0xff838b83) _GDIPlus_GraphicsDrawRect($h_Graph, 5, 62, 200, 200, $h_Pen) ; End of my WM Paint ======================================================================= _WinAPI_RedrawWindow($h_Pic_H, 0, 0, $RDW_VALIDATE); then force no-redraw of pic Return $GUI_RUNDEFMSG EndFunc I hope this will help those with volatile graphic elements!! Link to comment Share on other sites More sharing options...
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