Sign in to follow this  
Followers 0
RobertKipling

GDI+ window paint

3 posts in this topic

I'm designing a Windows side-bar right now, and everything was going pretty well, until I started working on the hands for the analog clock. Every time I "move" the clock or move a window over it, the hands disappear until another second ticks by.

How do I "stick" the hand graphics onto the window so they don't leave when something is dragged over it?

Share this post


Link to post
Share on other sites



I'm designing a Windows side-bar right now, and everything was going pretty well, until I started working on the hands for the analog clock. Every time I "move" the clock or move a window over it, the hands disappear until another second ticks by.

How do I "stick" the hand graphics onto the window so they don't leave when something is dragged over it?

Look in AutoIt install folder\Examples\GUI\Advanced\Clock.au3

There is a very nice clock example. You`ll find your answer in this example.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Here is an example of one way of re-painting.

Hope it helps.

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>

Global $GuiSizeX = 180, $GuiSizeY = 180

$hGui = GUICreate("GDIPlus Example", $GuiSizeX, $GuiSizeY)
GUISetState()

_GDIPlus_Startup()
;  Double Buffer
$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)
;End Double Buffer add-in 1 of 3

;Graphics here
_GDIPlus_GraphicsClear($hGraphic, 0xFFFFFF80)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF0080FF)
_GDIPlus_GraphicsFillEllipse($hGraphic, 3, 3, 50, 90, $hBrush)

$hPen = _GDIPlus_PenCreate(0xFFFF0000, 2)
_GDIPlus_GraphicsDrawLine($hGraphic, 0, $GuiSizeX, $GuiSizeY, 0, $hPen)

;End of graphics

;  Double Buffer
GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)
GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize.
_GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
;End Double Buffer add-on 2 of 3

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            _GDIPlus_BrushDispose($hBrush)
            _GDIPlus_PenDispose($hPen)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_GraphicsDispose($hGraphicGUI)
            _WinAPI_DeleteObject($hBMPBuff)
            _GDIPlus_Shutdown()         
            Exit            
    EndSwitch
WEnd

;Func to redraw on PAINT MSG, Double Buffer add-on 3 of 3
Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
    ; Check, if the GUI with the Graphic should be repainted
    _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
    _WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_PAINT

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0