📄 +
字号:
CStartUpDlg dlg;
m_pMainWnd=&dlg;
int nResponse=d1gdlg.DoModal();
if (nResponse==IDOK)
{}
else if (nResponse==IDCANCEL)
{}
return FALSE;
CStartUpDlg::CStartUpDlg(CWnd* pParent /*=NULL*/)
:CDialog(CStartUpDlg::IDD, pParent)
{
m_hIcon=AfxGetApp()->Loadlcon(IDR_MAINFRAME);
p_Bitmap=new CBitmap;
p_MemoryDC=new CDC;
b_BitmapLoaded=FALSE;
}
BOOL CStartUpdlg::OnInitDialog()
{
CDialog::OnInitDialog();
CPaintDC dc(this);
p_MemoryDC->CreateCompatibleDC(&dc);
p_Bitmap->LoadBitmap(IDB_BACKGROUND);
BITMAP m_Bitmap;
p_Bitmap->GetBitmap(&m_ Bitmap);
p_Bitmap->SetBitmapDimension(m_Bitmap.bmWidth, m_Bitmap.bmHeight);
p_MemoryDC->SelectObject(p_Bitmap);
b_BitmapLoaded = TRUE;
SetWindowPos(&wndTopMost,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
SWP_SHOWWINDOW);
//生成两个按钮
p_0K_Button = new CMyBtn(RGB(255, 255, 255));
p_Exit_Button = new CMyBtn(RGB(255, 255, 255));
CRect m_bPos;
int height, width;
height = GetSystemMetrics(SM_CYSCREEN) / 15;
width = GetSystemMetrics(SM_CXSCREEN) / 8;
height *= 2;
width *= 2;
//设置确定按钮的位置
m_bPos.SetRect((GetSystemMetrics(SMes CXSCREEN) - width) / 3,
GetSystemMetrics(SMes CYSCREEN) - height * 3 / 2,
(GetSystemMetrics(SM_CXSCREEN) - width) / 3+width / 2,
GetSystemMetrics(SMee CYSCREEN) - height);
p_OK_Button->Create("确定", BS_OWNERDRAW | WS_CHILD | WS_VISIBLE
| WS_TABSTOP, m_bPos, this, MY_OK_BUTTON);
p_OK_Button->ShowWindow(SW_SHOW);
//设置退出按钮的位置
m_Pos.SetRect((GetSystemMetrics(SM_CXSCREEN) - width) *2 / 3
+width / 2, GetSystemMetrics(SM_CYSCREEN) - height * 3 / 2,
(GetSystemMetrics(SM_CXSCREEN) - width) *2 / 3+width,
GetSystemMetrics(SM_CYSCREEN) - height);
p_Exit_Button->Create("退出", BS_OWNERDRAW | WS_CHILD |
WS_VISIBLE | WS_TABSTOP, m_bPos, this, MY_EXIT_BUTTON);
p_Exit_Button->ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
}
CSize m_SrcSize;
m_SrcSize = p_itmap->GetBitmapDimension();
RECT m_DestRect;
GetClientRect(&m_DestRect);
if (b_BitmapLoaded)
{
CPaintDC dc(this);
dc.StretchBlt
(
m_DestRect.left,
m_DestRect.top,
m_DestRect.right - m_DestRect.left,
m_DestRect.bottom - m_DestRect.top,
p_MemoryDC,
0,
0,
m_SrcSize.cx,
m_SrcSize.cy,
SRCCOPY
);
}
void CStartUpDlg::OnOK()
{}
void CStartUpDlg::OnCancel()
{}
void CStartUpDlg::OnOKButton()
{
HWND hWnd = GetSafeHwnd();
ShellExecute(hWnd, "open", "e:\\debug\\commtest.exe", NULL, NULL,
SW_SHOWNORMAL);
DestroyWindow();
}
void CStartUpDlg::OnExitButton()
{
if (MessageBox("确定退出该应用程序吗?", "确认框",
MB_ICONQUESTION | MB_OKCANCEL) == 2)
return ;
CDialog::OnCancel();
}
if (pMsg->message == WM_ KEYDOWN)
{
char StringOut[128];
sprintf(StringOut, "the key value is %d\n", pMsg->wParam);
OutputDebugString(StringOut);
switch (pMsg->wParam) //the key value
{
case 13:
//Enter
if (GetFocus() == GetDlgItem(MY_OK_BUTTON))
{
OnOKButton();
return TRUE;
}
else if (GetFocus() == GetDlgltem(MY_EXIT_BUTTON))
{
OnExitButton();
return true;
}
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -