ラーニング:ウィンドウ操作の共通レコード
1677 ワード
ウィンドウの最大/小/正規化:
メッセージ:
ウィンドウを閉じる
どちらの方法でもいいです
ウィンドウサイズの場所の移動:
2つの方法:
ps:位置が中央にある場合は
アプリケーションアイコンのロード:
OnInitDialogで作成:
メッセージ:
WM_SYSCOMMAND
/*
D:\Visual_Studio_repos\MFC\8\
*/
SC_MAXIMIZE (or SC_ZOOM) Maximize the CWnd object.
SC_MINIMIZE (or SC_ICON) Minimize the CWnd object.
SC_RESTORE Restore window to normal position and size.
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE,0); //
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); //
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); //
ウィンドウを閉じる
SC_CLOSE Close the CWnd object
afx_msg void OnClose( );
どちらの方法でもいいです
void CMy8Dlg::OnBnClickedButton4()
{
SendMessage(WM_SYSCOMMAND,SC_CLOSE, 0);
}
void CMy8Dlg::OnClose()
{
// TODO: /
if (AfxMessageBox(_T(" ?"), MB_YESNO,NULL) == IDYES) {
CDialogEx::OnClose();
}
}
ウィンドウサイズの場所の移動:
SetWindowPos
MoveWindow
2つの方法:
SetWindowPos(NULL, 10, 10, 0, 0, SWP_NOSIZE); //
MoveWindow(10, 10, 100, 100);
ps:位置が中央にある場合は
CenterWindow()
ウィンドウのトップ:void CMy8Dlg::OnBnClickedCheck1()
{
CButton* cb = (CButton *)GetDlgItem(IDC_CHECK1);
if (cb->GetCheck()) {
//
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
else {
::SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
}
アプリケーションアイコンのロード:
OnInitDialogで作成:
HICON icon = AfxGetApp()->LoadIcon(IDI_ICON1); // theApp LoadIcon
SetIcon(icon,FALSE);