📄 modaldlg.cpp
字号:
// ModalDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SMI.h"
#include "ModalDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CModalDlg dialog
CModalDlg::CModalDlg(CWnd* pParent /*=NULL*/)
: CDialog(CModalDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CModalDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CModalDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModalDlg)
DDX_Control(pDX, IDC_TREE_TEST, m_Tree);
DDX_Control(pDX, IDC_STATIC_MAINFRAME, m_Frame);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModalDlg, CDialog)
//{{AFX_MSG_MAP(CModalDlg)
ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
ON_BN_CLICKED(IDC_BTN_SCALE, OnBtnScale)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModalDlg message handlers
void CModalDlg::OnBtnAdd()
{
// TODO: Add your control notification handler code here
if (!m_btn.m_hWnd)
{
m_btn.Create(_T("Test-Button"),/*BS_AUTOCHECKBOX | */WS_VISIBLE | BS_3STATE,CRect(25,75,120,100),this,123);
}
else
{
m_btn.DestroyWindow();
}
}
void CModalDlg::OnBtnScale()
{
// TODO: Add your control notification handler code here
CString strText;
GetDlgItem(IDC_BTN_SCALE)->GetWindowText(strText);
if ( strText == _T("收缩<<"))
{
GetDlgItem(IDC_BTN_SCALE)->SetWindowText(_T("扩展>>"));
}
else if (strText == _T("扩展>>"))
{
GetDlgItem(IDC_BTN_SCALE)->SetWindowText(_T("收缩<<"));
}
static CRect rectOrgin;
static CRect rectLater;
if (rectOrgin.IsRectNull())
{
CRect rectSeperator;
GetWindowRect(&rectOrgin);
GetDlgItem(IDC_SEPERATOR)->GetWindowRect(&rectSeperator);
rectLater.left = rectOrgin.left;
rectLater.top = rectOrgin.top;
rectLater.right = rectOrgin.right;
rectLater.bottom = rectSeperator.bottom;
}
if (strText == _T("收缩<<"))
{
SetWindowPos(NULL,rectLater.left,rectLater.top,rectLater.Width(),rectLater.Height(),SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE);
}
else if (strText == _T("扩展>>"))
{
SetWindowPos(NULL,0,0,rectOrgin.Width(),rectOrgin.Height(),SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
}
}
void CModalDlg::OnOK()
{
// TODO: Add extra validation here
GetNextDlgTabItem(GetFocus())->SetFocus();
/*CDialog::OnOK();*/
}
WNDPROC prevProc;
LRESULT CALLBACK NewEditProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
if (uMsg == WM_CHAR && wParam == 0x0d)
{
::SetFocus(::GetNextWindow(hwnd,GW_HWNDNEXT));
return 1;
}
else
{
return prevProc(hwnd,uMsg,wParam,lParam);
}
}
BOOL CModalDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
/* prevProc = (WNDPROC)SetWindowLong(GetDlgItem(IDC_EDIT1)->m_hWnd,GWL_WNDPROC,(LONG)NewEditProc);*/
m_ImageCtrl.Create(31,31,ILC_COLOR32,0,2);
m_ImageCtrl.Add(AfxGetApp()->LoadIcon(IDI_ICON_A));
m_ImageCtrl.Add(AfxGetApp()->LoadIcon(IDI_ICON_B));
m_Tree.SetImageList(&m_ImageCtrl,TVSIL_NORMAL);
CString strItem = _T("");
CString strItemFS = _T("");
HTREEITEM ITEM = NULL;
for (int i = 0;i<20;i++)
{
strItem.Format(_T("A单元%d房"),i);
strItemFS.Format(_T("%s附属"),strItem);
ITEM = m_Tree.InsertItem(strItem,0,1);
m_Tree.InsertItem(strItemFS,0,0,ITEM);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -