1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
//... NB 'window' is a retrieved pointer to a window wrapper object
// and 'ps' is a declared PAINTSTRUCT
case WM_PAINT:
{
// Prepare the window for painting.
HDC hdc = BeginPaint (hwnd, &ps);
int xPos=0;
int yPos=0;
// Check we have not scrolled away from origin
if ((styles&WS_HSCROLL)==WS_HSCROLL)
{
GetScrollInfo(hwnd,SB_HORZ,&si);
xPos=si.nPos;
}
if ((styles&WS_HSCROLL)==WS_VSCROLL)
{
GetScrollInfo(hwnd,SB_VERT,&si);
yPos=si.nPos;
}
RECT rect;
GetClientRect(hwnd,&rect);
// -------------------------------------------
// If instead of passing to the On_WM_PAINT function,
// the code is inserted here, there is no problem.
// -------------------------------------------
// Pass to window instance
window->On_WM_PAINT(hdc,rect,xPos,yPos);
// End Paint
EndPaint(hwnd,&ps);
return 0;
}
//...
}
bool Start_Up_Window::On_WM_PAINT(HDC hdc,RECT& rect,int,int)
{
rect.top=rect.bottom/5;
HFONT hf=CreateFont(100,0,0,0,550,0,0,0,0,0,0,0,0,0);
SelectObject(hdc,hf);
DrawText(hdc,_T("Title"),-1,&rect,DT_CENTER);
return true;
}
|