上一篇 | 下一篇

一个模仿windows中的桌面背景预览的控件

发布: 2008-6-26 14:28 | 作者: admin | 来源: | 查看: 38次

下载本文所附源代码

程序运行效果截图:

这个控件是模仿微软windows操作系统中的显示属性对话框的控件。我作的这个custom控件具有和微软控件一样的功能。

这个控件通过在一个MFC标准Dll工程中的CMonitor类实现,CMonitor类继承于CWnd。当然这个类可以被扩展,直接加入到你的MFCexe工程中。你可以做一个基于对话框的程序,联机到dll工程,来看控件效果的演示。

我做了一个TestMonitor演示程序,你可以看到此控件的功能。

主要代码:

// SOURCE CODE HINTS

// a public static member function used for registering the

// control window class

static BOOL CMonitor::RegisterWndClass(HINSTANCE hInstance);

// a global function defined and used for transparently

// displaying the monitor

extern "C" __declspec(dllexport)

BOOL MaskImage(HDC hDC, int nXDest, int nYDest, int nWidth,

int nHeight, HB99vMAP hbmImage, int nXSrc,

int nYSrc, HB99vMAP hbmMask);

// the global control window procedure function

LRESULT CALLBACK AFX_EXPORT

CMonitorWndProc(HWND hWnd, UINT message, WPARAM wParam,

LPARAM lParam);

// a set of user defined Windows control messages to

// communicate with the control

#define MM_SETIMAGE WM_USER + 0

#define MM_GETIMAGE WM_USER + 1

#define MM_SETDISPLAYSTYLE WM_USER + 2

#define MM_GETDISPLAYSTYLE WM_USER + 3

#define MM_SETREF WM_USER + 4

#define MM_GETREF WM_USER + 5

// a dummy function is used to be called from the client program

// to ensure the dll loading

extern "C" __declspec(dllexport)

void MonitorDllEntry() {} // dummy function

字号: | 推荐给好友

评分:0

我来说两句