|
|
//DirectX特效 Chapter2第六???例
//修改後(凡是修改?都???fdef akira_test_),希望按下一???(by WM_KEYDOWN)就??嗬L?一???色方形(tt.bmp)在原?
???:?我按下任意?後,?K不??霈F?色的方?K在原?,而是要我?⒁?窗移出?幕外後在移回??才??⑿??K?出?色的方?K.
可是我在WM_KEYDOWN?r,有送出WM_PAINT,而且的?也有收到此command,就是不???出?色方?K.
?大家?臀铱匆幌率鞘颤N原因.
附上:source code
void PaintWindow(HDC hdc)
{
// set our mapping mode as text. this means 1 logical unit = 1 pixel.
SetMapMode(hdc, MM_TEXT);
// this function will draw the bitmap without stretching.
/*BitBlt(hdc,
0, 0, g_iScreenWidth, g_iScreenHeight,
g_hDCBitmap, 0, 0, SRCCOPY);
*/
// this function will stretch the bitmap so that it fits in the window.
StretchBlt(hdc,
0, 0, g_iScreenWidth, g_iScreenHeight,
g_hDCBitmap, 0, 0, g_iBitmapWidth, g_iBitmapHeight, SRCCOPY);
#ifdef _akira_test_
//?一???色方形
if (g_bDrawGreenSquare)
DrawOneBitmap(hdc);
#endif//_akira_test_
}
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg) {
#ifdef _akira_test_
case WM_KEYDOWN:
{
g_bDrawGreenSquare=true;
SendMessage(hwnd,WM_PAINT,0,0);
}
break;
#endif//_akira_test_
case WM_PAINT:
{
PAINTSTRUCT ps;
// get the DC we're supposed to use from Windows
BeginPaint(hwnd, &ps);
HDC hdc = ps.hdc;
// paint our window (function is defined above)
PaintWindow(hdc);
// tell Windows we're done painting.
EndPaint(hwnd, &ps);
TRACE(">>>>OnPaint\n");
}
// we processed the message, so return 0.
return(0);
|
|