Jump to content


Photo

GDIP repaint?


  • Please log in to reply
2 replies to this topic

#1 Relayer

Relayer
  • Members
  • 104 posts

Posted 15 January 2013 - 11:09 PM

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



#2 Linear Spoon

Linear Spoon
  • Members
  • 406 posts

Posted 17 January 2013 - 12:03 AM

#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. 



#3 Relayer

Relayer
  • Members
  • 104 posts

Posted 17 January 2013 - 09:34 PM

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