Quote Originally Posted by novacain View Post
Do not add any lines to the WM_PAINT handler!

If you think you have to add lines to the WM_PAINT then your design is wrong.

Code:
static LRESULT CALLBACK WndProcForm(HWND HandleWindow, UINT msg, WPARAM wParam, LPARAM lParam)
        {
            static POINT PreviousLocation, Location;
            static bool Tracking = false;
            static MouseButtons MBButtons;
            static bool blControl = false;
            static bool blShift = false;
            static bool blResize = false;
            static int xPos = 0;
            static int yPos = 0;
            static UINT_PTR timerid=0;
            static UINT_PTR JoystickTimer=1;
            static bool blnDrag = false;
            static bool KeyPressed=false;
            static int KeyDownCount=0;
        
        //our GDI objects
            static HDC hdcimage = NULL;
            static HBITMAP hbitmap=NULL;

        statid bool state = false;

            //UINT JoystickCount =0;
//..............
//Working with messages
            switch(msg)
            {
                case WM_ERASEBKGND:
                    return (LRESULT)1;
        break;
        // when form created WM_INITDIALG or WM_CREATE
        case WM_INITDIALOG:
            //create your DC and BITMAP and selectobject

            //make the window redraw every 10 sec
            SetTimer(HandleWindow, 12345, 10000, NULL);
            
            return ?
        break;
        case WM_TIMER:
            IF(wParam == 12345)
            {
                return DrawScreen(HandleWindow, state);
            }

            return ?
        break;
        case WM_PAINT:
                {
                    PAINTSTRUCT  ps;
                    HDC hdc = BeginPaint( HandleWindow, &ps);       

                    BitBlt(ps.hdc,0,0,ps.rcPaint.right-ps.rcPaint.left,ps.rcPaint.bottom-ps.rcPaint.top,hdcimage,0,0,SRCCOPY);

                    EndPaint( HandleWindow, &ps);

                }
        break;
        case WM_DESTROY:
                {
        
                    DeleteObject(hbitmap);
                    DeleteDC(hdcimage);
                    joyReleaseCapture(JOYSTICKID1);
                    --FormCount;
                    if(FormCount == 0)
                        End();
                }
                break;
}}

bool DrawScreen(HWND hWnd, bool drawState)
{
    IF(drawState)
        //create white brush
    ELSE
        //create black brush

    //fill the hdcimage 
    
    //generate paint msg
    InvalidateRect()
    UpdateWindow()

    return ?
}
thanks for correct me.
but i'm confused with 2 things:
1 - i always use the InvalidateRect(), but why the UpdateWindow()?
2 - why you used the drawState? seems to be, always, false

so i did a mistake and the best is call my Paint() lambda function with a timer or something, right?
(in these case the Paint() lambda is for show an image to hdcimage nothing more)
anothing: i use the TransparentBlt() on my image class method, but i know about the memory leak, can be avoid for another function?