我最初调整了客户端窗口的大小,并使其不可调整大小。唯一的问题,我现在面临的是当我移动窗口(向左或向右拖动标题栏)时,其中的内容消失了,这就是为什么我要将其固定在左上角直到终止。
BOOL CMainFrame :: PreCreateWindow(CREATESTRUCT& cs) {
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.x=0;
cs.y=0;
// Create a window without min/max buttons or sizable border
cs.style = WS_OVERLAPPED | WS_SYSMENU | WS_BORDER;
return TRUE;
}
这是我的OnDraw():
void CblockmaniaView::OnDraw(CDC* pDC)
{
CblockmaniaDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CImage* img= new CImage();
pDC->FillSolidRect( 0, 0,810,640, RGB(128,128,128));
for (int i=0;i<16;i++)
{
for (int j=0;j<16;j++)
{
if (updateInfo[j]==true)
{
if (GetDocument()->x.map[i][j]!=NULL)
{
x=GetDocument()->x.map[i][j]->x;
y=GetDocument()->x.map[i][j]->y;
img->Load(GetDocument()->x.map[i][j]->imgPath);
img->Draw(pDC->m_hDC,40*y,40*x, 40, 40);
img->Destroy();
}
}
}
}
if (firstRun)
{
pDC->FillSolidRect( 640, 0, 10,640, RGB(0,0,0));
img->Load(L"C:\\Users\\Ad33l's\\Documents\\Visual Studio 2012\\Projects\\block mania\\block mania\\res\\score.png");
img->Draw(pDC->m_hDC,655,25,150,30);
img->Destroy();
}
for (int i=0;i<16;i++)
{
updateInfo[i]=false;
}
}