📄 wis_dlg.h
字号:
#ifndef _WIZ_DLG_H
#define _WIZ_DLG_H
#include "utils.h"
#include "enumchild.h"
#include "label.h"
template<class T>
class wiz_dlg: public T
{
typedef T baseclass;
public:
wiz_dlg( UINT nID, CWnd *pParent = NULL ): baseclass( nID, pParent )
{
set_default();
}
wiz_dlg( CWnd *pParent = NULL ): baseclass( pParent )
{
set_default();
}
void set_height( int h )
{
h = h;
}
void set_title( LPCTSTR t, COLORREF cl = -1 )
{
title = t;
if( utils::is_window(&lb_title) )
lb_title.SetText( t, cl );
}
void set_caption( LPCTSTR c, COLORREF cl = -1 )
{
m_strCaption = c;
if( utils::is_window(&caption) )
caption.SetText( c, cl );
}
void SetBmp( UINT bmpid )
{
idbmp = bmpid;
}
protected:
virtual BOOL OnInitDialog()
{
baseclass::OnInitDialog();
USING_UTILS;
if( !IsWindow() )
return FALSE;
if( is_window(&lb_title) )
return FALSE;
//ASSERT( idbmp );
ASSERT( h );
//////////////////////////////////////////////////////////////////////////
GrowWindowSize( this, 0, h );
MoveControls( this, CPoint( 0, h ) );
//////////////////////////////////////////////////////////////////////////
// 白板
window_client_rect rc(this,this);
rc.OffsetRect( -rc.left, -rc.top );
rc.bottom = rc.top + h;
// 分隔线
CRect rcBevel(rc);
rcBevel.top = rcBevel.bottom - 2;
rcBevel.OffsetRect( 0, 2 );
// 标题(加粗)
CRect rcTitle(rc);
int h = 20;
int l = 20;
rcTitle.top = rc.Height()/2 + rc.top - h;
rcTitle.bottom = rcTitle.top + h;
rcTitle.left = l;
// 描述
CRect rcCaption(rcTitle);
rcCaption.OffsetRect( h, h );
create( &m_stWhitePanel, NULL, SS_WHITERECT, rc, this );
create( &m_stBevel, NULL, SS_ETCHEDFRAME, rcBevel, this );
create( &lb_title, title, SS_LEFT, rcTitle, this );
CFont *font = GetFont();
LOGFONT lf;
font->GetLogFont( &lf );
lf.lfWeight = FW_BOLD;
lb_title.SetFont( lf );
lb_title.SetTransparent(TRUE);
create( &caption, m_strCaption, SS_LEFT, rcCaption, this );
lf.lfWeight = FW_NORMAL;
caption.SetFont( lf );
caption.SetTransparent(TRUE);
if( idbmp )
{
if( m_bmp.LoadBitmap( idbmp ) )
{
BITMAP bitmap;
m_bmp.GetBitmap( &bitmap );
CRect rcBmp(rc.left,rc.top,rc.right,rc.top+bitmap.bmHeight);
utils::VCenterRect( rc, rcBmp );
rcBmp.right = rc.right - ( rc.Height() - bitmap.bmHeight )/2;
rcBmp.left = rcBmp.right - bitmap.bmWidth;
create( &m_stBmp, NULL, SS_BITMAP, rcBmp, this );
m_stBmp.SetBitmap( m_bmp );
}
}
CenterWindow();
return TRUE;
}
private:
class MoveChild
{
public:
bool operator()( CWnd *from, const CPoint& pt, CWnd *p )
{
utils::window_client_rect rc(p,from);
p->SetWindowPos(NULL,rc.left+pt.x, rc.top+pt.y, 0, 0,
SWP_NOSIZE | SWP_NOZORDER );
return true;
}
};
void MoveControls( CWnd *from, const CPoint& pt )
{
enum_children( from, MoveChild(), pt );
}
void set_default()
{
h = 80;
title = "正在处理, 请稍候...";
m_strCaption = "这个操作根据您的计算机速度需要几分钟到几十分钟...";
idbmp = 0;
}
void create( CStatic *This, LPCTSTR lpszText, DWORD dwStyle, const RECT& rc, CWnd *parent )
{
This->Create( lpszText, dwStyle, rc, parent );
This->ShowWindow( SW_SHOW );
This->UpdateWindow();
}
CStatic m_stWhitePanel;
CLabel lb_title;
CLabel caption;
CStatic m_stBmp;
CStatic m_stBevel;
CBitmap m_bmp;
UINT idbmp;
int h;
CString title;
CString m_strCaption;
};
#endif // _WIZ_DLG_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -