VC程序中定制对话框中的回车键(5)
//////////// frame window
class CMainFrame : public CFrameWnd {
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
CMainFrame();
~CMainFrame();
};
//////////////////// Typical dialog
class CMyDlg : public CDlgWithAccelerators {
public:
CMyDlg(CWnd* pParent = NULL); // standard constructor
protected:
HICON m_hIcon;
void NextInTabOrder();
// MFC overrides
virtual BOOL OnInitDialog();
afx_msg void OnMyEnter();
afx_msg LRESULT OnGetDefID(WPARAM wp, LPARAM lp);
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
END_MESSAGE_MAP()
CMyApp::CMyApp()
{
// nothing to do
}
CMyApp::~CMyApp()
{
// nothing to do
}
//////////////////// InitInstance: create dialog as child
BOOL CMyApp::InitInstance()
{
// create frame window and load it
CMainFrame* pFrame = new CMainFrame;
m_pMainWnd = pFrame;
pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPED, NULL, NULL);
CMyDlg dlg(pFrame); // create dialog and run it
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{}
else if (nResponse == IDCANCEL)
{}
return FALSE; // quit
}
CMainFrame::CMainFrame()
{
// nothing to do
}
CMainFrame::~CMainFrame()
{
// nothing to do
}
///////////// Pre-create window: set WS_EX_TOOLWINDOW style to hide dialog from task bar
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if (CFrameWnd::PreCreateWindow(cs)) {
cs.dwExStyle |= WS_EX_TOOLWINDOW;
return TRUE;
}
return FALSE;
}
- 上一篇:VC通过HTTP方式获取网页
- 下一篇:VC++实现Windows回收站的文件存取