⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 em_dlg.h

📁 实时监控
💻 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 + -