0
点赞
收藏
分享

微信扫一扫

在mfc中使用gdiplus调用皮肤组件

在觉 2022-07-18 阅读 38


李国帅 2011.12.8

在vc中为了界面美观经常使用皮肤,而皮肤控件很多,这里介绍一种曾经使用的皮肤插件。

头文件

#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
#include "GdiManger.h"
#include "GdipButton.h"
#include "ReportCtrl.h"
#include "TransparentStatic.h"
#include "TGroupBox.h"

声明和初始化

ULONG_PTR m_gdiplusToken;//
GdiplusStartupInput gdiplusStartupInput;//初始化BOOL CdemoApp::InitInstance()
GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);

Gdiplus::GdiplusShutdown(m_gdiplusToken);//去初始化 Gdiplus::GdiplusShutdown(m_gdiplusToken);


对话框头文件中定义对象

CGdiManger            m_oGdiManager;
CGdipButton m_btnCIFD1;

DDX_Control(pDX, IDC_BTN_D1, m_btnCIFD1);


初始化函数中

m_btnCIFD1.EnableWindow(bEnable);
m_btnCIFD1.LoadStdImage(IDR_D1_BTN, "PNG");
m_btnCIFD1.MoveWindow(230+28+10, 7, 28, 27);
strText.LoadString(IDS_TOOLBAR_STR_2);
m_btnCIFD1.SetToolTipText(strText);
m_btnCIFD1.ShowWindow(SW_HIDE);

刷新背景

BOOL CDeviceListDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
char szmoduleDir[1024]; // module path without '\' at the end

memset(szmoduleDir, 0, 1024);
strcpy(szmoduleDir, GetModuleFileDirectory().c_str());
CString strFilePath;
strFilePath.Format("%sImages\\DevlistBk.png", szmoduleDir);
CRect rect;
GetClientRect(&rect);
m_oGdiManager.DrawBitMap(strFilePath, rect, pDC);

m_btnCIFD1.SetBkGnd(pDC);

return TRUE;

//return CDialog::OnEraseBkgnd(pDC);

举报

相关推荐

0 条评论