图片效果地址: http://links.imgup.cn/201111/3/12/81494_1320295494b4g9.jpeg
// 对话框非客户区自绘Dlg.h : header file
//
#if !defined(AFX_DLG_H__29895C86_9D01_4C17_B374_289E36621F88__INCLUDED_)
#define AFX_DLG_H__29895C86_9D01_4C17_B374_289E36621F88__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
class CMyDlg : public CDialog
{
// Construction
public:
void GetAreasOfRect();
CRect NCClientToScreen(CRect* lpRtSrc);
void DrawNCButtons(CDC *pDC);
BOOL InitInfo();
BOOL DrawBitmapInRect(CRect rt, CBitmap *cbmp, CDC *pDC);
void DrawNC(CDC* pDC);
LONG GetBitmapWidth(CString strBmpName);
LONG GetBitmapHeight(CString strBmpName);
BOOL LoadBitmapFromFile(CString strBmpName, CBitmap* cbmp);
CMyDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CMyDlg)
enum { IDD = IDD_MY_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PreSubclassWindow();
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
protected:
int m_nCaptionHeight; //标题栏高度.
CString m_strCaptionText; //标题栏
BOOL m_bNCActive; //窗口活动状态
BOOL m_bButtonMinOver; //最小化按钮,鼠标在上面
BOOL m_bButtonMaxOver; //最大化按钮,鼠标在上面
BOOL m_bButtonExitOver; //关闭按钮,鼠标在上面
CRect m_rtWnd; //整个窗体Rect.
CRect m_rtTitleBar; //Title bar
CRect m_rtClient; //客户区
CRect m_rtIcon; //图标.
CRect m_rtCaption; //标题栏
CRect m_rtButtons; //最大,最小,关闭按钮.
CRect m_rtButtonMin; //最小.
CRect m_rtButtonMax; //最大.
CRect m_rtButtonExit; //关闭.
CRect m_rtBorderLeft; //边框左边.
CRect m_rtBorderRight; //边框右边.
CRect m_rtBorderBottom; //边框底边.
CRect m_rtBorderBottom2; //边框底边.
CBitmap m_bmpCaption; //标题栏
CBitmap m_bmpButtonMin; //最小.
CBitmap m_bmpButtonMax; //最大.
CBitmap m_bmpButtonExit; //关闭.
CBitmap m_bmpButtons; //系统按钮.
CBitmap m_bmpBorderLeft; //边框左边.
CBitmap m_bmpBorderRight; //边框右边.
CBitmap m_bmpBorderBottom; //边框底边.
CBitmap m_bmpBorderBottom2; //边框底边.
CBitmap m_bmpCaptionOver; //标题栏,鼠标在上边
CBitmap m_bmpButtonMinOver; //最小.鼠标在上边
CBitmap m_bmpButtonMaxOver; //最大.鼠标在上边
CBitmap m_bmpButtonMaxZoomed;//最大.最大化了
CBitmap m_bmpButtonExitOver;//关闭.鼠标在上边
COLORREF m_rgbBackGround; //背景颜色
COLORREF m_rgbFrontGroun; //前景颜色
CBrush m_brBackGround; //背景画刷
HICON m_hIcon; //系统图标
// Generated message map functions
//{{AFX_MSG(CMyDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnNcPaint();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
afx_msg BOOL OnNcActivate(BOOL bActive);
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
afx_msg void OnMove(int x, int y);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLG_H__29895C86_9D01_4C17_B374_289E36621F88__INCLUDED_)
本文介绍了如何在VC中进行对话框的自定义绘制,通过详细的步骤和示例,展示了如何实现一个美观的对话框界面。文章附带了图片效果链接,展示了自绘后的对话框界面。

905

被折叠的 条评论
为什么被折叠?



