Click here to Skip to main content
15,881,204 members
Articles / Desktop Programming / Windows Forms

Cool, Semi-transparent and Shaped Dialogs with Standard Controls for Windows 2000 and Above

Rate me:
Please Sign up or sign in to vote.
4.85/5 (95 votes)
28 Sep 2012CPOL3 min read 2.9M   32.8K   350  
This article tries to find a way to show Windows standard controls on layered windows. Provides both Native MFC and WinForms source code.
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Chinese (P.R.C.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#ifndef APSTUDIO_INVOKED\r\n"
    "#include ""targetver.h""\r\n"
    "#endif\r\n"
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
    "LANGUAGE 9, 1\r\n"
    "#pragma code_page(1252)\r\n"
    "#include ""res\\SemiTransparentDialogWithStandardCtrls.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
    "#include ""afxres.rc""     // Standard components\r\n"
    "#endif\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON                    "res\\SemiTransparentDialogWithStandardCtrls.ico"

/////////////////////////////////////////////////////////////////////////////
//
// PNG
//

IDB_PNG_DLG1            PNG                     "res\\bg.png"
IDB_PNG_DLG2            PNG                     "res\\bg2.png"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG_3 DIALOGEX 0, 0, 342, 240
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    CONTROL         "",IDC_LIST2,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,69,55,195,91
END

IDD_DIALOG1 DIALOGEX 0, 0, 374, 237
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    PUSHBUTTON      "Cancel",IDCANCEL,247,197,50,14
    CONTROL         "",IDC_TREE1,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_CHECKBOXES | TVS_TRACKSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,187,23,127,158,WS_EX_STATICEDGE
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO 
BEGIN
    IDD_DIALOG_3, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 335
        TOPMARGIN, 7
        BOTTOMMARGIN, 233
    END

    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 367
        TOPMARGIN, 7
        BOTTOMMARGIN, 230
    END
END
#endif    // APSTUDIO_INVOKED

#endif    // Chinese (P.R.C.) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_SEMITRANSPARENTDIALOGWITHSTANDARDCTRLS_DIALOG DIALOGEX 0, 0, 394, 240
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    PUSHBUTTON      "Cancel",IDCANCEL,322,202,50,14
    LTEXT           "This sample demonstrates how to show standard controls on the layered window.",IDC_STATIC,36,58,262,8
    LTEXT           "Author: Jerry.Wang  MSN/Email:sky-sea-earth@21cn.com",IDC_STATIC,37,218,187,8
    CONTROL         "Radio1",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,27,78,38,10
    CONTROL         "Check1",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,93,39,10
    EDITTEXT        IDC_EDIT1,27,109,81,12,ES_AUTOHSCROLL
    COMBOBOX        IDC_COMBO1,27,131,83,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
    LISTBOX         IDC_LIST1,127,78,58,112,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
    CONTROL         "",IDC_DATETIMEPICKER1,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,21,172,100,15
    CONTROL         "",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,53,150,11,14
    CONTROL         "",IDC_MONTHCALENDAR1,"SysMonthCal32",MCS_NOTODAY | MCS_NOTODAYCIRCLE | WS_TABSTOP,191,90,180,100
    PUSHBUTTON      "Demo dialog (Load image from external file)",IDC_BUTTON_DEMO2,19,201,152,14
    PUSHBUTTON      "Demo dialog(Load image from resource)",IDC_BUTTON2,177,201,139,14
END


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904e4"
        BEGIN
            VALUE "CompanyName", "TODO: <Company name>"
            VALUE "FileDescription", "TODO: <File description>"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", "SemiTransparentDialogWithStandardCtrls.exe"
            VALUE "LegalCopyright", "TODO: (c) <Company name>.  All rights reserved."
            VALUE "OriginalFilename", "SemiTransparentDialogWithStandardCtrls.exe"
            VALUE "ProductName", "TODO: <Product name>"
            VALUE "ProductVersion", "1.0.0.1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO 
BEGIN
    IDD_SEMITRANSPARENTDIALOGWITHSTANDARDCTRLS_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 386
        TOPMARGIN, 7
        BOTTOMMARGIN, 232
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//

IDD_SEMITRANSPARENTDIALOGWITHSTANDARDCTRLS_DIALOG DLGINIT
BEGIN
    IDC_COMBO1, 0x403, 6, 0
0x7449, 0x6d65, 0x0031, 
    IDC_COMBO1, 0x403, 6, 0
0x7449, 0x6d65, 0x0032, 
    IDC_COMBO1, 0x403, 6, 0
0x7449, 0x6d65, 0x0033, 
    IDC_COMBO1, 0x403, 6, 0
0x7449, 0x6d65, 0x0034, 
    IDC_COMBO1, 0x403, 6, 0
0x7449, 0x6d65, 0x0035, 
    0
END


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE 
BEGIN
    IDS_ABOUTBOX            "&About SemiTransparentDialogWithStandardCtrls..."
END

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\SemiTransparentDialogWithStandardCtrls.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"     // Standard components
#endif

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
China China
Jerry is from China. He was captivated by computer programming since 13 years old when first time played with Q-Basic.



  • Windows / Linux & C++
  • iOS & Obj-C
  • .Net & C#
  • Flex/Flash & ActionScript
  • HTML / CSS / Javascript
  • Gaming Server programming / video, audio processing / image & graphics


Contact: vcer(at)qq.com
Chinese Blog: http://blog.csdn.net/wangjia184

Comments and Discussions