sttodaydialog.cpp
来自「windows ce开发技巧与实例光盘代码」· C++ 代码 · 共 127 行
CPP
127 行
// STTodayDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "STTodayDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// STTodayDialog dialog
CSTTodayDialog::CSTTodayDialog(UINT nIDTemplate, CWnd* pParentWnd)
: CDialog(nIDTemplate, pParentWnd)
{
}
BEGIN_MESSAGE_MAP(CSTTodayDialog, CDialog)
//{{AFX_MSG_MAP(CSTTodayDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// STTodayDialog message handlers
int CSTTodayDialog::DoModal()
{
CString strParentClass;
CWnd objParentWindow;
strParentClass = AfxRegisterWndClass(0);
objParentWindow.CreateEx(0, strParentClass, ::AfxGetAppName(), WS_VISIBLE, -1, -1, 0, 0, 0, 0);
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
// load resource as necessary
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle();
if (m_lpszTemplateName != NULL)
{
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
hDialogTemplate = LoadResource(hInst, hResource);
}
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
return -1;
// disable parent (before creating dialog)
HWND hWndParent = PreModal();
// This line should not be commented but I cannot compile otherwise
// AfxUnhookWindowCreate();
BOOL bEnableParent = FALSE;
if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))
{
::EnableWindow(hWndParent, FALSE);
bEnableParent = TRUE;
}
TRY
{
// create modeless dialog
// This line should not be commented but I cannot compile otherwise
// AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
&objParentWindow, hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
// enter modal loop
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
// hide the window before enabling the parent, etc.
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
}
CATCH_ALL(e)
{
// This line should not be commented but I cannot compile otherwise
// DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL
#if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 300)
if(m_pWndEmptyCB != NULL)
{
m_pWndEmptyCB->DestroyWindow();
delete m_pWndEmptyCB;
m_pWndEmptyCB = NULL;
}
#endif // _WIN32_WCE_PSPC
if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent);
// destroy modal window
DestroyWindow();
PostModal();
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
return m_nModalResult;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?