15,978
社区成员
发帖
与我相关
我的任务
分享
void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
int nCxBorder = ::GetSystemMetrics(SM_CXFRAME);
int nCyBorder = ::GetSystemMetrics(SM_CYFRAME);
lpncsp->rgrc[0].left -= nCxBorder;
lpncsp->rgrc[0].right += nCxBorder;
lpncsp->rgrc[0].top -= nCyBorder;
lpncsp->rgrc[0].bottom += nCyBorder;
CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
}
BOOL CMyOwnerDrawApp::InitInstance()
{
CWinApp::InitInstance();
CMainFrame* pMainFrame = new CMainFrame();
pMainFrame->CreateEx(0,
_T("MAINFRAME"),
_T("自绘程序"),
WS_POPUPWINDOW | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL);
m_pMainWnd = pMainFrame;
pMainFrame->CenterWindow();
pMainFrame->ShowWindow(SW_SHOW);
pMainFrame->UpdateWindow();
return TRUE;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
HINSTANCE hInstance = (HINSTANCE)AfxGetInstanceHandle();
ASSERT(hInstance);
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
BOOL bRet = GetClassInfoEx( hInstance, cs.lpszClass, &wcex);
if (bRet)
{
return TRUE;
}
wcex.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wcex.lpfnWndProc = AfxWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = (HICON)::LoadIcon(hInstance, MAKEINTRESOURCE(IDR_MAINFRAME));
wcex.hIconSm = (HICON)::LoadIcon(hInstance, MAKEINTRESOURCE(IDR_MAINFRAME));
wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = cs.lpszClass;
bRet = RegisterClassEx(&wcex);
return bRet;
}