Krzysztof Mossakowski
Windows Programming
2009 - Tasks
The mouse & The keyboard
On-screen keyboard
Demonstration
Functionality:
On-screen keyboard
Only keys corresponding to letters 'A' - 'Z' are included
Keys layout is similar to QWERTY keyboards
3 rows
the 1st row fills the screen horizontally
the 2nd row is shifted right about half of the key's size
the 3rd row is shifted right about key's size
All keys are square and have the same size
Key spacing is 2px
The on-screen keyboard is vertically centered
All keys have blue background color and have a default transparency level set to 50%
Features of the keyboard:
Opacity is set when corresponding key is pressed
Background color is set to red when mouse cursor is over the key's window
Transparency level of the currently pressed keys could be change
both "+" keys (on alphanumeric and numeric keyboard) smoothly increase the transparency level, no more up to 80%
both "-" keys (on alphanumeric and numeric keyboard) smoothly decrease the transparency level, no less than 20%
a new transparency level is applied while +/- key is pressed, opacity is set when key is released
Left mouse button double-click on a key's window sets the transparency level to the default value (50%)
Only one window is visible on the task bar and in the task switch window (Alt+Tab)
Hints:
SetClassLongPtr(), GCLP_HBRBACKGROUND, InvalidateRect()
HBRUSH h1 = CreateSolidBrush(RGB(255,0,0));
HBRUSH h2 = CreateSolidBrush(RGB(0,0,255));
//...
SetClassLongPtr(hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)h1);
InvalidateRect(hWnd, NULL, TRUE);
TrackMouseEvent(), TRACKMOUSEEVENT, WM_MOUSELEAVE
WS_EX_LAYERED, SetLayeredWindowAttributes()
GetSystemMetrics(), SM_CXSCREEN, SM_CYSCREEN
Approximate points:
windows layout: 3.0
increase/decrease transparency level: 2.5
default transparency setting (doubleclick): 1.0
setting opacity at key pressing: 1.0
changing color at mouse enter: 1.0
changing color at mouse leave: 1.5
Links for uploading:
Solutions
Corrections