Example of rewriting Wndproc:
Static bool flag = false;
Protected override void WndProc (ref Message m)
{
Switch (m. Msg ){
Case 0x0200: // WM_MOUSEMOVE
If (flag)
{
PostMessage (this. Handle, 0x00A1, new IntPtr (2), m. LParam); // import user32.dll
}
Break; www.2cto.com
Case 0x201: // WM_LBUTTONDOWN
Flag = true;
Break;
Case 0x202: // WM_LBUTTONUP
Flag = false;
Break;
Default:
Base. WndProc (ref m );
Break;
}
[DllImport ("user32.dll", CharSet = CharSet. Unicode)]
Public static extern IntPtr PostMessage (IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam );
The hexadecimal key of the virtual keyboard code.
VK_LBUTTON 01 left mouse button
VK_RBUTTON 02 right-click
VK_CANCEL 03 is used to execute Ctrl + C or Ctrl + Break
VK_MBUTTON 04
VK_BACK 08 Backspace key
VK_TAB 09 Tab key
VK_CLEAR 0C Clear key
VK_RETURN 0D Enter
VK_SHIFT 10 Shift key
VK_CONTROL 11 Ctrl
VK_MENU 12 Arl key
VK_PAUSE 13 Pause key
VK_CAPITAL 14 Capslock key
VK_ESCAPE 1B Ese key
VK_SPACE 20 SpaceBar key
VK_PRIOR 21 PgUp key
VK_NEXT 22 PgDn key
VK_END 23 End key
VK_HOME 24 Home Key
VK_LEFT 25 Left Arrow
VK_UP 26 Up Arrow key
VK_RIGHT 27 Right Arrow key
VK_DOWN 28 Down Arrow key
VK_SELECT 29 Select key
VK_EXECUTE 2B Execute key
VK_SNAPSHOT 2C PrintScreen key
VK_INSERT 2D Ins key
VK_DELECT 2E Del key
VK_HELP 2F Help key
VK_0 30 0 Key
... ... ...
VK_9 39 9 Key
VK_A 41 A key
... ... ...
VK_Z 5A Z key
VK_NUMAPD0 60 number board 0 Key
... ... ...
VK_NUMAPD9 69 dashboard 9 Key
VK_MULTIPY 6A multiplication key
VK_ADD 6B plus key
VK_SEPARATOR 6C Separator key
VK_SUBSTRACT 6D minus key
VK_DECIMAL 6E decimal key
VK_DIVIDE 6F Division key
VK_F1 70 F1 key
... ... ...
VK_F24 87 F24 key
VK_NUMLOCK 90 NumLock key
VK_SCROLL 91 ScrollLock key
VK_CAPITAL Caps Lock
VK_ESCAPE Esc
VK_SPACE Space
VK_PRIOR Page Up
VK_NEXT Page Down
VK_END
VK_HOME Home
VK_LEFT left direction key
VK_UP
VK_RIGHT
VK_DOWN
VK_DELETE Delete
VK_INSERT Inser
VK_NUMPAD0 ~ The 0-9 key on the VK_NUMPAD9 keypad
VK_F1-VK_f12 F1-F12 keys
Check Caps Lock key:
Var
KeyStates: TKeyboardState;
Begin
GetKeyboardState (KeyStates );
If Odd (KeyStates [VK_CAPITAL]) then
SpBtnA. Caption: = 'A'
Else
SpBtnA. Caption: = 'a ';
End;