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

📄 detail_dlg.h

📁 实时监控
💻 H
字号:
/*
 *	File:		detail_dlg.h
 *	Function:	make a dialog can extend and shrine
 *	Usage:		create a dialog derive from this, like:
				class CTestDlg: detail_dlg<CDialog>
				{
					...
				};
				and place a separator line in the dialog, named "ID_SEP"
				then in the dialog constructor:
				CTestDlg::CTestDlg(CWnd* parent = NULL ):
				base(ID_SEP, CTestDlg::IDD, parent)
				{
					...
				}
				ok, now use "simple()" and "detail()" freely. isnt it wonderful?
 *	Author:		nodman
 *	History:	2003-2-x created, nodman
 *				2003-9-3 modified, nodman
 */
#ifndef _DETAILDLG_H
#define _DETAILDLG_H

#include "utils.h"
#include "rect.h"

template<class T>
class detail_dlg: public T
{
	typedef T baseclass;
public:
	typedef detail_dlg<baseclass> base;

	detail_dlg( UINT idDlg, CWnd *pParent = NULL):
	baseclass(idDlg, pParent), nID(0)
	{
	}

protected:
	virtual BOOL OnInitDialog()
	{
		baseclass::OnInitDialog();
		on_init();
		return TRUE;
	}
	void on_init()
	{
		CenterWindow();
		GetWindowRect( rcOrig );
		CWnd *p = GetDlgItem( nID );
		if( !p )
			return;

		window_rect rc(p);
		nSepY = rc.top - rcOrig.top;
	}

	bool detailed()
	{
		CWnd* p = GetDlgItem(nID);
		if( !p )
			return true;

		return FALSE != p->IsWindowVisible();
	}

	void detail()
	{
		if( detailed() )
			return;

		window_rect rc(this);
		
		rc.bottom = rc.top + rcOrig.Height();
		SetWindowPos( NULL, 0, 0, rc.Width(), rc.Height(), SWP_NOMOVE | SWP_NOZORDER );
		
		GetDlgItem(nID)->ShowWindow(SW_SHOW);
	}

	void simple()
	{
		//if( !detailed() )
		//	return;

		window_rect rc(this);
		
		rc.bottom = rc.top + nSepY;
		SetWindowPos( NULL, 0, 0, rc.Width(), rc.Height(), SWP_NOMOVE | SWP_NOZORDER );

		GetDlgItem(nID)->ShowWindow(SW_HIDE);
	}
	void set_sepid(UINT sepid)
	{
		nID = sepid;
	}
private:
	CRect rcOrig;
	UINT nID;
	UINT nSepY;
};
#endif // _DETAILDLG_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -