CDialogSK, A Skinnable Dialog Class
来源:互联网 发布:java内存泄漏 编辑:程序博客网 时间:2024/05/16 04:44
CDialogSK, A Skinnable Dialog Class
Environment: VC6 SP4, Windows 2000, WindowsXP
Introduction
This class is derived from the MFC CDialog. It supports the following features:
- If running on Windows2000 or Windows XP, makes any one color transparent so that you can see through regions of the dialog.
- If running on Windows2000 or Windows XP, makes the whole dialog translucent.
- Adds a bitmap to the background. The bitmap can be a resource, a BMP file, or a HBITMAP.
- Set style for background: Tile, Center, Stretch; resize dialog to the size of the bitmap.
- Can enable/disable moving the dialog by clicking anywhere in it.
Usage
The class can be used by using the following steps:
- Add the CDialogSK.h and CDialogSK.cpp files to your project.
- Include CDialogSK.h in the .h file for your dialog class.
- Replace all occurrences of "CDialog" with "CDialogSK" in the .h and .cpp files for your dialog class.
- If you plan to use a background image (bitmap) go to the dialog Properties, Styles tab and make it Style=Popup, Border=None, and uncheck the "Title Bar" check box.
- At the end of OnInitDialog of your dialog class, add calls to the appropriate methods in CDialogSK:
BOOL CSkinDialog_DemoDlg::OnInitDialog(){ ... EnableEasyMove(); // enable moving of // the dialog by // clicking // anywhere in // the dialog SetBitmap (IDB_BACKGROUND); // set background // bitmap SetStyle (LO_RESIZE); // resize dialog to // the size of // the bitmap SetTransparentColor(RGB(0, 255, 0)); // set green as // the transparent // color return TRUE;}
- If, for example, you want to make a circular dialog, create a image that has a blue circle on a green background. Then, call SetBitmap with the path to the image and call SetTransparentColor, passing the color of the background (green). This will remove the background from view and you will get a circular window.
Methods
The following methods are present in CDialogSK class:
- DWORD SetBitmap (HBITMAP hBitmap);
Sets a background bitmap based on a HBITMAP - DWORD SetBitmap (int nBitmap);
Sets a background bitmap based on a resource ID - DWORD SetBitmap (LPCTSTR lpszFileName);
Sets a background bitmap based on a Windows bitmap (.bmp) file. - void SetStyle (LayOutStyle style);
Sets the bitmap layout style. Can be any of the following: LO_DEFAULT, LO_TILE (tile image), LO_CENTER (center image), LO_STRETCH (stretch image to fit dialog), or LO_RESIZE (resize dialog to fit the image). - void EnableEasyMove (BOOL pEnable = TRUE);
If called with TRUE, you can move the dialog by clicking anywhere in the client area of the dialog - BOOL SetTransparent (BYTE bAlpha);
Make the dialog as a whole transparent. Range is 0(transparent) - 255 (opaque). This works only on Windows2000 and above (WinXP). - BOOL SetTransparentColor (COLORREF col, BOOL bTrans = TRUE);
Make a particular color transparent. This works only on Windows2000 and above (WinXP). This can be used to create a dialog in which you can see through parts of the dialog.
Downloads
Download demo project - 33 KbDownload source - 4 Kb
About the Author
Abhinaba loves coding for the sheer fun of it. He started programming in 1995 with BASIC and then moved through Cobol, Pascal, Prolog, C, C++, VisualBasic and VC++. He received a Bachelor of Technology degree from University of Calcutta in 2001. Abhinaba is originally from the City of Joy, Kolkata in India, but now codes and lives in Noida close to Delhi. His hobby is coding which also happens to be his job. Besides coding he loves traveling.
- CDialogSK, A Skinnable Dialog Class
- CDialogSK, A Skinnable Dialog Class
- Qt4 Dialog Class (C++)
- EasyUI 通过Class设置Dialog
- 通过Class方式设置Dialog
- 修改MFC Dialog 的 class name
- vector<class A> 与 vector<class *A>
- a.class与a .class的区别
- A complete zenity dialog examples
- A complete zenity dialog examples
- Create a View in a MFC Dialog
- Creating a View on a Dialog
- A DelegateQueue Class
- A non-inheritable class
- A simple perl class
- declare a class uncopyable
- Rewriting a Model Class
- A better iterable class
- MP3文件格式解析
- FLV文件格式解析
- 格式化日期输出
- AMR音频编码器概述及文件格式分析
- [转载]我的博后申请经历从陶瓷到Offer过程
- CDialogSK, A Skinnable Dialog Class
- 字符计数
- MP3文件格式解析
- 字符串匹配
- Ubuntu vnc4server安装配置
- 编写一个程序,输出一个字符串中的大写英文字母数,小写英文字母数以及非英文字母数。
- [经验总结]std::string的警告信息不能消除的解决办法
- 有重复字母的全排列的java程序
- LESSON 9 E-MAIL SECURITY part VIII