Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.1 KiB

  1. // KBMAIN.H KEYBOARD MAIN HEADER FILE
  2. /**************************************************************************/
  3. /* GLOBAL DEFINES */
  4. /**************************************************************************/
  5. // WINDOW TYPES
  6. #define KB_MAIN_WND 1
  7. #define KB_KEY_WND 2
  8. #define KB_MODIFIER_WND 3
  9. #define KB_DEAD_WND 4
  10. #define KB_NUMBASE_WND 5
  11. #define KB_NUMKEY_WND 6
  12. #define DESKTOP_ACCESSDENIED 0
  13. #define DESKTOP_DEFAULT 1
  14. #define DESKTOP_SCREENSAVER 2
  15. #define DESKTOP_WINLOGON 3
  16. #define DESKTOP_TESTDISPLAY 4
  17. #define DESKTOP_OTHER 5
  18. // KEYBOARD MARGINS
  19. //The smallest width (pixel) you can get for KB
  20. //#define KB_SMALLRMARGIN 152//137 //for width(smallKB). 152 - Block, 137 - Actual (Moved to kbmain, WM_SIZE)
  21. #define KB_LARGERMARGIN 202 //for width
  22. #define KB_CHARBMARGIN 57 //for height
  23. #define KB_NUMRMARGIN
  24. #define KB_NUMBMARGIN
  25. // KEYBOARD NUMBERKEY
  26. #define KB_HOWMANYKEY 130 // IT HAS TO INCLUDE THE NUMERIC KEYBOARD
  27. // SOUND TYPES
  28. #define SND_UP 1
  29. #define SND_DOWN 2
  30. // TIMERS
  31. #define TIMER_HELPTOOLTIP 1014
  32. #include "door.h"
  33. LRESULT WINAPI kbMainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  34. LRESULT WINAPI kbKeyWndProc(HWND hwndKey, UINT message, WPARAM wParam, LPARAM lParam);
  35. LRESULT CALLBACK KeybdInputProc(WPARAM wParam, LPARAM lParam);
  36. void RelocateDialog(HWND hDlg);
  37. #define CAPLOCK_SCANCODE 0x3A
  38. #define LSHIFT_SCANCODE 0x2A
  39. #define RSHIFT_SCANCODE 0x36
  40. #define TAB_SCANCODE 0x0f
  41. #define BREAK_SCANCODE 0xE1
  42. #define LMENU_SCANCODE 0x38
  43. #define RMENU_SCANCODE 0x38 // extended 0xE0
  44. #define CONTROL_SCANCODE 0x1D
  45. #define RGB_KEYBGHIGHLIGHT COLOR_HIGHLIGHT /*RGB(0,0,0)*/
  46. #ifndef ARRAY_SIZE
  47. #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
  48. #endif
  49. /**************************************************************************/
  50. /* GLOBAL VARIABLES */
  51. /**************************************************************************/
  52. extern LPKBPREFINFO lpkbPref; // Pointer to KB structure
  53. extern LPKBPREFINFO lpkbDefault; // ditto Default
  54. extern HINSTANCE hInst; // iinstance of keyboard process
  55. extern HWND *lpkeyhwnd; // ptr to array of HWND
  56. extern HWND numBasehwnd; // HWND to the num base window
  57. extern HWND g_hwndOSK; // HWND to the kbmain window
  58. extern int lenKBkey; // How Many Keys?
  59. extern int scrCY; // Screen Height
  60. extern int scrCX; // Screen Width
  61. extern int captionCY; // Caption Bar Height
  62. extern HHOOK hkJRec; // HHOOK to the Journal Record
  63. extern int g_margin; // Margin between rows and columns
  64. extern BOOL smallKb; // TRUE when working with Small Keyboard
  65. extern COLORREF PrefTextKeyColor; // Prefered Color for text in keys
  66. extern COLORREF PrefCharKeyColor; // ditto normal key
  67. extern COLORREF PrefModifierKeyColor; // ditto modifier key
  68. extern COLORREF PrefDeadKeyColor; // ditto dead key
  69. extern COLORREF PrefBackgroundColor; // ditto Keyboard backgraund
  70. extern BOOL PrefAlwaysontop; // Always on Top control
  71. extern int PrefDeltakeysize; // Preference increment in key size
  72. extern BOOL PrefshowActivekey; // Show cap letters in keys
  73. extern int KBLayout; // 101, 102, 106, KB layout
  74. extern BOOL Prefusesound; // Use click sound
  75. extern BOOL newFont; // Font is changed
  76. extern LOGFONT *plf; // pointer to the actual char font
  77. extern HGDIOBJ oldFontHdle; // Old object handle
  78. extern COLORREF InvertTextColor; //Font color on inversion
  79. extern COLORREF InvertBKGColor; //BKG color on inversion
  80. extern BOOL Prefhilitekey; // True for hilite eky under cursor
  81. // Dwelling time control variables
  82. extern BOOL PrefDwellinkey; // use dwelling system
  83. extern UINT PrefDwellTime; // Dwell time preference
  84. extern BOOL PrefScanning; //use scanning
  85. extern UINT PrefScanTime; //Prefer scan time
  86. extern BOOL g_fShowWarningAgain; // Show initial warning dialog again
  87. extern HWND Dwellwindow; // dwelling window
  88. extern int stopPaint; // stop the bucket paint
  89. extern UINT_PTR timerK1; // timer id for keyboard
  90. extern UINT_PTR timerK2; // timer for print line on key
  91. /*****************************************************************************/
  92. extern BOOL g_fDrawCapital;
  93. extern BOOL g_fCapsLockOn;
  94. extern BOOL g_fShiftKeyDn;
  95. extern BOOL g_fRAltKey; // TRUE if the RALT key is down
  96. extern BOOL g_fLAltKey; // TRUE if the left ALT key is down
  97. extern BOOL g_fLCtlKey; // TRUE if the left CTRL key is donw
  98. extern HWND g_hwndInputFocus; // the window we are inputting to
  99. //
  100. // These are the different 'modified' states a key can have. Note that shifted,
  101. // caps-lock, and shifted-caps-lock are all different states, since alphabetic
  102. // numbers and symbols behave differently in these states.
  103. //
  104. typedef enum {
  105. KEYMOD_NORMAL,
  106. KEYMOD_SHIFTED,
  107. KEYMOD_CAPSLOCK,
  108. KEYMOD_SHIFTEDCAPSLOCK,
  109. KEYMOD_ALTGR,
  110. KEYMOD_STATES
  111. } KEYMODSTATE;
  112. __inline BOOL AltGrKeyPressed()
  113. {
  114. // this check is relaxed because the OS sets LCTRL toggled when LALT key is pressed
  115. return (g_fRAltKey || (g_fLAltKey && g_fLCtlKey))? TRUE:FALSE;
  116. }
  117. __inline BOOL CapsLockIsOn()
  118. {
  119. return (g_fCapsLockOn)?TRUE:FALSE;
  120. }
  121. __inline KEYMODSTATE GetModifierState()
  122. {
  123. // The order of keyboard state checking is important; ALTGR takes
  124. // precedence over the shift/capslock variants, which takes precedence
  125. // over normal.
  126. if( AltGrKeyPressed() )
  127. return KEYMOD_ALTGR;
  128. if( g_fCapsLockOn && g_fShiftKeyDn )
  129. return KEYMOD_SHIFTEDCAPSLOCK;
  130. if( g_fCapsLockOn )
  131. return KEYMOD_CAPSLOCK;
  132. if( g_fShiftKeyDn )
  133. return KEYMOD_SHIFTED;
  134. return KEYMOD_NORMAL;
  135. }
  136. __inline HWND OurInputTarget()
  137. {
  138. if (!IsWindow(g_hwndInputFocus))
  139. {
  140. g_hwndInputFocus = NULL;
  141. }
  142. return g_hwndInputFocus;
  143. }
  144. __inline HKL GetCurrentHKL()
  145. {
  146. DWORD dwProcessId;
  147. HWND hwnd = OurInputTarget();
  148. return GetKeyboardLayout(GetWindowThreadProcessId((hwnd)?hwnd:g_hwndOSK, &dwProcessId));
  149. }
  150. __inline void SetBackgroundColor(HWND hwnd, unsigned long ulColor)
  151. {
  152. SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)(ulColor+1));
  153. }
  154. BOOL OSKRunSecure();