Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

GDIP repaint?


  • Please log in to reply
2 replies to this topic
Relayer
  • Members
  • 122 posts
  • Last active: Jun 22 2015 09:21 PM
  • Joined: 24 Nov 2008

I'm using Tic's Gdip library and it's working great.  I'm displaying a few .png files inside a GUI.  If another window overlaps my GUI or if the GUI is minimized, the images are gone from the screen.  Tooling around I found that windows sends a message to a window to tell it to repaint itself again once it has a view on the screen, even partial view.

 

How do I do that using Gdip?

 

Relayer



Linear Spoon
  • Members
  • 842 posts
  • Last active: Sep 29 2015 03:56 AM
  • Joined: 29 Oct 2011
#include gdip.ahk

Gui, +hwndhgui
Gui, Show, w200 h200, Test

pToken := Gdip_Startup()
dc := GetDC(hgui)
pGraphics := Gdip_GraphicsFromHDC(dc)
pBrush := Gdip_BrushCreateSolid(0xff800080) ;purple
Gdip_FillRectangle(pGraphics, pBrush, 0, 0, 200, 200)

OnMessage(0xF, "WM_PAINT") ;Set the function to run when 0xF is received
OnExit, GuiClose
return

GuiClose:
 ;Free resources
 ReleaseDC(dc)
 Gdip_DeleteBrush(pBrush)
 Gdip_DeleteGraphics(pGraphics)
 Gdip_Shutdown(pToken)
 ExitApp
return

;This function will run when AHK gets a WM_PAINT message
WM_PAINT(wparam, lparam)
{
  global pGraphics, pBrush ;They say globals are bad but for simplicity...
  TrayTip, Gdip example, WM_PAINT received
  Gdip_FillRectangle(pGraphics, pBrush, 0, 0, 200, 200) ;fill in the rectangle again
}

 

On my computer I don't get WM_PAINT for a window overlapping my gui, but it doesn't erase the image either..

Hope it helps anyway. 


Join us at the new forum - http://www.ahkscript.org/

 


Relayer
  • Members
  • 122 posts
  • Last active: Jun 22 2015 09:21 PM
  • Joined: 24 Nov 2008

Thanks.  I saw this on the MSDN site but as you say, the GUI in AHK doesn't receive a WM_PAINT message.  Doing a search on the forum shows that this issue has come up before but I'm not sophisticated enough in Gdip to grasp it.

 

Relayer