Krzysztof Mossakowski
Windows Programming
2005 - Tasks
Modal dialog boxes
Version A
Transparency of Window
Demonstration
The main window:
background color - can be changed in settings dialog (default: black)
transparency - can be changed in settings dialog (default: 255 - opaque)
menu:
Exit
Settings - accelerators: Ctrl+S and Alt+S
Settings dialog box:
modal
buttons:
Apply - applies new settings without closing the dialog box
OK - closes the dialog box and applies new settings
Cancel - closes the dialog box without applying new settings
'...' - opens common dialog box for choosing color
preview of chosen color
horizontal scroll bar - sets opacity of the main window
Hints:
transparency:
#define _WIN32_WINNT 0x0500
before
#include <windows.h>
WS_EX_LAYERED
SetLayeredWindowAttributes
preview of chosen color
static control with SS_BITMAP type (choose Picture Control from Visual Studio's Toolbox and change Type property to Bitmap)
create bitmap and set it for the control:
SendMessage( hCtrl, (UINT)STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmp );
DialogBox(), GetDlgItem()
ChooseColor(), #include "commdlg.h"
Approximate points:
menu and accelerators: 1.0
changing background color of the main window: 1.5
changing transparency of the main window: 1.5
modal dialog box: 0.5
OK, Apply, Cancel buttons functionality: 1.5
common dialog for choosing color: 1.0
preview of chosen color: 1.5
horizontal scroll bar for changing opacity: 1.5