?? em_dlg.h
字號:
/*
* History: added "can_leave" 2003-9-3, nodman
*/
#ifndef _EM_DLG_H
#define _EM_DLG_H
#include "rect.h"
#include "utils.h"
/// 嵌入式對話框
template<class T>
class em_dlg: public T
{
protected:
typedef em_dlg<T> baseclass;
UINT iddlg;
public:
em_dlg(UINT idd, CWnd* parent = NULL): T(idd, parent), iddlg(idd)
{
iddlg = idd;
}
void create(CWnd* owner)
{
Create(iddlg, owner);
}
void join(CWnd* owner, UINT id_site)
{
CWnd* site = owner->GetDlgItem(id_site);
if( !site )
return;
if( !is_window(this) )
create(owner);
ModifyStyle(WS_POPUP, WS_CHILD, 0);
SetParent(owner);
SetOwner(owner);
window_rect rc(site);
owner->ScreenToClient(rc);
SetWindowPos(NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE);
site->ShowWindow(SW_HIDE);
ShowWindow(SW_SHOW);
on_join();
owner->SetFocus();
}
void leave()
{
if( !IsWindow(m_hWnd) )
return;
ShowWindow(SW_HIDE);
//DestroyWindow();
on_leave();
}
virtual bool can_leave()
{
return true;
}
virtual void OnOK()
{
if(GetParent())
GetParent()->SendMessage(WM_COMMAND, IDOK, 0);
}
virtual void OnCancel()
{
if(GetParent())
GetParent()->SendMessage(WM_COMMAND, IDCANCEL, 0);
}
virtual int DoModal() {return IDCANCEL;}
virtual bool visible()
{
if( !IsWindow(m_hWnd) )
return false;
return FALSE != IsWindowVisible();
}
protected:
virtual void PreSubclassWindow()
{
ModifyStyle(0, WS_EX_CONTROLPARENT, 0);
T::PreSubclassWindow();
}
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
// if( pMsg->message == WM_ERASEBKGND )
// return TRUE;
return T::PreTranslateMessage(pMsg);
}
virtual LRESULT DefWindowProc(UINT msg, WPARAM w, LPARAM l)
{
if( msg == WM_ERASEBKGND )
//return TRUE;
return FALSE;
return T::DefWindowProc(msg, w, l);
}
virtual void on_join()
{
}
virtual void on_leave()
{
}
};
#endif // _EM_DLG_H
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -