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 ?
}