Leaked source code of windows server 2003
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.

388 lines
12 KiB

  1. #include "hwxobj.h"
  2. #include "const.h"
  3. #include "../lib/ptt/ptt.h"
  4. #include "cexres.h"
  5. #include "dbg.h"
  6. #include "cmnhdr.h"
  7. // HWX Window procedures
  8. LRESULT WINAPI HWXWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
  9. {
  10. //990716:ToshiaK for Win64
  11. //CHwxInkWindow * app = (CHwxInkWindow *)GetWindowLong(hwnd,0);
  12. CHwxInkWindow * app = (CHwxInkWindow *)WinGetPtr(hwnd,0);
  13. switch(msg)
  14. {
  15. case WM_CREATE:
  16. app = (CHwxInkWindow *)((LPCREATESTRUCT)lp)->lpCreateParams;
  17. //990810:ToshiaK for Win64
  18. //SetWindowLong(hwnd,0,(LONG)app);
  19. WinSetPtr(hwnd, 0, (LPVOID)app);
  20. if ( !app->HandleCreate(hwnd) )
  21. {
  22. return -1;
  23. }
  24. return 0;
  25. case WM_NOTIFY:
  26. if ( ((LPNMHDR)lp)->code == TTN_NEEDTEXTW )
  27. {
  28. app->SetTooltipText(lp);
  29. }
  30. return 0;
  31. case WM_PAINT:
  32. app->HandlePaint(hwnd);
  33. return 0;
  34. case WM_COMMAND:
  35. return app->HandleCommand(hwnd, msg, wp, lp);
  36. case WM_SIZE:
  37. if ( SIZE_RESTORED == wp )
  38. app->HandleSize(wp,lp);
  39. return 0;
  40. case WM_SETTINGCHANGE:
  41. if(app) {
  42. return app->HandleSettingChange(hwnd,msg,wp,lp);
  43. }
  44. return 0;
  45. #ifdef UNDER_CE // Windows CE specific
  46. case WM_WINDOWPOSCHANGED:
  47. return 0;
  48. #endif // UNDER_CE
  49. case WM_ERASEBKGND:
  50. return 0;
  51. #ifndef UNDER_CE // Windows CE does not support WinHelp
  52. case WM_CONTEXTMENU:
  53. case WM_HELP:
  54. app->HandleHelp(hwnd,msg,wp,lp);
  55. return 0;
  56. #endif // UNDER_CE
  57. #ifndef UNDER_CE // Windows CE does not support WM_ENTERIDLE
  58. case WM_ENTERIDLE:
  59. Dbg(("WM_ENTERIDLE for HWXWndPrc\n"));
  60. if((::GetKeyState(VK_CONTROL) & 0x8000) &&
  61. ((::GetKeyState(VK_SHIFT) & 0x8000) || (::GetKeyState(VK_SPACE) & 0x8000))) {
  62. Dbg(("VK_CONTROL & SHIFT or VK_CONTROL & SPACE COME\n"));
  63. ::SendMessage(hwnd, WM_CANCELMODE, 0, 0L);
  64. return 0;
  65. }
  66. return DefWindowProc(hwnd, msg, wp, lp);
  67. #endif // UNDER_CE
  68. default:
  69. return DefWindowProc(hwnd, msg, wp, lp);
  70. }
  71. }
  72. LRESULT WINAPI MBWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
  73. {
  74. //990810:ToshiaK for Win64
  75. //CHwxMB * app = (CHwxMB *)GetWindowLong(hwnd,0);
  76. CHwxMB * app = (CHwxMB *)WinGetPtr(hwnd,0);
  77. switch (msg)
  78. {
  79. case WM_CREATE:
  80. {
  81. app = (CHwxMB *)((LPCREATESTRUCT)lp)->lpCreateParams;
  82. //990810:ToshiaK for Win64
  83. //SetWindowLong(hwnd,0,(LONG)app);
  84. WinSetPtr(hwnd, 0, (LPVOID)app);
  85. return 0;
  86. }
  87. // case WM_DESTROY:
  88. //970729: by ToshiaK temporarily, comment out
  89. // PostThreadMessage((app->GetMBThread())->GetID(), THRDMSG_EXIT, 0, 0);
  90. // PostQuitMessage(0);
  91. // return 0;
  92. case WM_PAINT:
  93. app->HandlePaint(hwnd);
  94. return 0;
  95. case WM_LBUTTONDOWN:
  96. case WM_LBUTTONDBLCLK:
  97. case WM_LBUTTONUP:
  98. case WM_MOUSEMOVE:
  99. case WM_RBUTTONUP:
  100. case WM_RBUTTONDOWN:
  101. if(!app) { //toshiaK:980324
  102. break;
  103. }
  104. if( app->HandleMouseEvent(hwnd, msg, wp,lp) )
  105. return 0;
  106. else
  107. break;
  108. case WM_TIMER:
  109. KillTimer(hwnd, TIMER_ID);
  110. if(!app) { //toshiaK:980324
  111. break;
  112. }
  113. app->SetTimerStarted(FALSE);
  114. app->HandleUserMessage(hwnd, MB_WM_DETERMINE,wp,lp);
  115. return 0;
  116. case WM_COMMAND:
  117. if(!app) { //toshiaK:980324
  118. break;
  119. }
  120. return app->HandleCommand(hwnd,msg,wp,lp);
  121. // User defined window messages
  122. case MB_WM_ERASE:
  123. case MB_WM_DETERMINE:
  124. case MB_WM_HWXCHAR:
  125. // case MB_WM_COMCHAR:
  126. case MB_WM_COPYINK:
  127. if(!app) { //toshiaK:980324
  128. break;
  129. }
  130. return app->HandleUserMessage(hwnd, msg,wp,lp);
  131. case WM_ERASEBKGND:
  132. return 0;
  133. #ifndef UNDER_CE // Windows CE does not support WM_ENTERIDLE
  134. case WM_ENTERIDLE:
  135. if((::GetKeyState(VK_CONTROL) & 0x8000) &&
  136. ((::GetKeyState(VK_SHIFT) & 0x8000) || (::GetKeyState(VK_SPACE) & 0x8000))) {
  137. Dbg(("VK_CONTROL & SHIFT or VK_CONTROL & SPACE COME\n"));
  138. Dbg(("WM_ENTERIDLE for MBWndProc\n"));
  139. ::SendMessage(hwnd, WM_CANCELMODE, 0, 0L);
  140. return 0;
  141. }
  142. return 0;
  143. #endif // UNDER_CE
  144. default:
  145. return DefWindowProc(hwnd, msg, wp, lp);
  146. }
  147. return 1;
  148. }
  149. LRESULT WINAPI CACWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
  150. {
  151. //990810:toshiaK for Win64
  152. //CHwxCAC * app = (CHwxCAC *)GetWindowLong(hwnd,0);
  153. CHwxCAC * app = (CHwxCAC *)WinGetPtr(hwnd,0);
  154. switch (msg)
  155. {
  156. case WM_CREATE:
  157. app = (CHwxCAC *)((LPCREATESTRUCT)lp)->lpCreateParams;
  158. //990716:ToshiaK for Win64
  159. //SetWindowLong(hwnd,0,(LONG)app);
  160. WinSetPtr(hwnd, 0, (LPVOID)app);
  161. PostMessage(hwnd,CAC_WM_DRAWSAMPLE,0,0);
  162. return 0;
  163. // case WM_DESTROY:
  164. //970729: by ToshiaK, temporarily comment out
  165. // PostQuitMessage(0);
  166. // break;
  167. case WM_PAINT:
  168. app->HandlePaint(hwnd);
  169. break;
  170. case WM_RBUTTONUP:
  171. case WM_RBUTTONDOWN:
  172. case WM_LBUTTONDBLCLK:
  173. case WM_LBUTTONDOWN:
  174. case WM_LBUTTONUP:
  175. case WM_MOUSEMOVE:
  176. app->HandleMouseEvent(hwnd,msg,wp,lp);
  177. break;
  178. case WM_NOTIFY:
  179. if ( ((LPNMHDR)lp)->code == TTN_NEEDTEXT_WITHUSERINFO )
  180. {
  181. app->SetToolTipText(lp);
  182. }
  183. break;
  184. case WM_COMMAND:
  185. return app->HandleCommand(hwnd,msg,wp,lp);
  186. case CAC_WM_RESULT:
  187. app->HandleRecogResult(hwnd,wp,lp);
  188. break;
  189. case CAC_WM_SHOWRESULT:
  190. app->HandleShowRecogResult(hwnd,wp,lp);
  191. break;
  192. case CAC_WM_SENDRESULT:
  193. app->HandleSendResult(hwnd,wp,lp);
  194. break;
  195. case CAC_WM_DRAWSAMPLE:
  196. app->HandleDrawSample();
  197. break;
  198. //990618:ToshiaK for Kotae# 1329
  199. case WM_ERASEBKGND:
  200. break;
  201. #ifndef UNDER_CE // Windows CE does not support WM_ENTERIDLE
  202. case WM_ENTERIDLE:
  203. Dbg(("WM_ENTERIDLE for CACWndProc\n"));
  204. if((::GetKeyState(VK_CONTROL) & 0x8000) &&
  205. ((::GetKeyState(VK_SHIFT) & 0x8000) || (::GetKeyState(VK_SPACE) & 0x8000))) {
  206. Dbg(("VK_CONTROL & SHIFT or VK_CONTROL & SPACE COME\n"));
  207. Dbg(("WM_ENTERIDLE for MBWndProc\n"));
  208. ::SendMessage(hwnd, WM_CANCELMODE, 0, 0L);
  209. return 0;
  210. }
  211. break;
  212. #endif // UNDER_CE
  213. default:
  214. return DefWindowProc(hwnd, msg, wp, lp);
  215. }
  216. return 0;
  217. }
  218. //----------------------------------------------------------------
  219. //980805:ToshiaK. PRC merge
  220. //----------------------------------------------------------------
  221. LRESULT CALLBACK IMELockWndProc(
  222. HWND hWnd,
  223. UINT uMsg,
  224. WPARAM wParam,
  225. LPARAM lParam)
  226. {
  227. WNDPROC wcOrgComboProc;
  228. //990810:ToshiaK for Win64
  229. //wcOrgComboProc = (WNDPROC)GetWindowLong(hWnd, GWL_USERDATA);
  230. wcOrgComboProc = (WNDPROC)WinGetUserPtr(hWnd);
  231. switch (uMsg) {
  232. #ifndef UNDER_CE // Windows CE does not support WM_INPUTLANGCHANGEREQUEST
  233. case WM_INPUTLANGCHANGEREQUEST:
  234. MessageBeep((UINT)-1);
  235. return 0;
  236. #endif // UNDER_CE
  237. case WM_DESTROY:
  238. //990716:ToshiaK for Win64
  239. //SetWindowLong(hWnd, GWL_WNDPROC, (LONG)wcOrgComboProc);
  240. //SetWindowLong(hWnd, GWL_USERDATA, 0);
  241. WinSetWndProc(hWnd, (WNDPROC)wcOrgComboProc);
  242. WinSetUserPtr(hWnd, (LPVOID)0);
  243. break;
  244. default:
  245. break;
  246. }
  247. return CallWindowProc((WNDPROC)wcOrgComboProc, hWnd, uMsg, wParam, lParam);
  248. }
  249. BOOL CALLBACK SubclassChildProc(
  250. HWND hWnd, // handle to child window
  251. LPARAM lParam) // application-defined value
  252. {
  253. WNDPROC wpOldComboProc;
  254. // Subclass child window to IME-UnSwitchable
  255. //990716:ToshiaK for Win64
  256. //wpOldComboProc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC);
  257. //SetWindowLong(hWnd, GWL_WNDPROC, (LONG)IMELockWndProc);
  258. //SetWindowLong(hWnd, GWL_USERDATA, (LONG)wpOldComboProc);
  259. wpOldComboProc = (WNDPROC)WinGetWndProc(hWnd);
  260. WinSetWndProc(hWnd, (WNDPROC)IMELockWndProc);
  261. WinSetUserPtr(hWnd, (LPVOID)wpOldComboProc);
  262. return TRUE;
  263. Unref(lParam);
  264. }
  265. void SubclassChildWindowAll(HWND hWndParent)
  266. {
  267. #ifndef UNDER_CE // Windows CE does not support WM_INPUTLANGCHANGEREQUEST
  268. EnumChildWindows(hWndParent, (WNDENUMPROC)SubclassChildProc, 0);
  269. #endif // UNDER_CE
  270. return;
  271. }
  272. INT_PTR CALLBACK CACMBPropDlgProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
  273. {
  274. CHwxInkWindow * pInk;
  275. switch (msg)
  276. {
  277. case WM_INITDIALOG:
  278. {
  279. pInk = (CHwxInkWindow *)lp;
  280. #ifndef UNDER_CE // Windows CE does not support SetProp
  281. //SetPropW(hdlg,TEXT("CMPROP"),(HANDLE)lp);
  282. if(::IsWindowUnicode(hdlg)) {
  283. ::SetPropW(hdlg,L"CMPROP",(HANDLE)lp);
  284. }
  285. else {
  286. ::SetPropA(hdlg,"CMPROP",(HANDLE)lp);
  287. }
  288. //::SetPropW(hdlg,TEXT("CMPROP"),(HANDLE)lp);
  289. #else // UNDER_CE
  290. ::SetWindowLong(hdlg, GWL_USERDATA, (LONG)lp);
  291. #endif // UNDER_CE
  292. if ( pInk )
  293. pInk->HandleDlgMsg(hdlg,TRUE);
  294. CExres::SetDefaultGUIFont(hdlg); //971117: ToshiaK
  295. //----------------------------------------------------------------
  296. //980805:ToshiaK. PRC merge.
  297. //----------------------------------------------------------------
  298. SubclassChildWindowAll(hdlg);
  299. }
  300. return TRUE;
  301. case WM_COMMAND:
  302. if ( LOWORD(wp) == IDOK )
  303. {
  304. #ifndef UNDER_CE // Windows CE does not support GetProp
  305. //pInk = (CHwxInkWindow *)GetProp(hdlg,TEXT("CMPROP"));
  306. if(::IsWindowUnicode(hdlg)) {
  307. pInk = (CHwxInkWindow *)GetPropW(hdlg, L"CMPROP");
  308. }
  309. else {
  310. pInk = (CHwxInkWindow *)GetPropA(hdlg,"CMPROP");
  311. }
  312. #else // UNDER_CE
  313. pInk = (CHwxInkWindow *)GetWindowLong(hdlg, GWL_USERDATA);
  314. #endif // UNDER_CE
  315. if ( pInk )
  316. pInk->HandleDlgMsg(hdlg,FALSE);
  317. #ifndef UNDER_CE // Windows CE does not support RemoveProp
  318. //RemoveProp(hdlg,TEXT("CMPROP"));
  319. if(::IsWindowUnicode(hdlg)) {
  320. ::RemovePropW(hdlg, L"CMPROP");
  321. }
  322. else {
  323. ::RemovePropA(hdlg, "CMPROP");
  324. }
  325. #endif // UNDER_CE
  326. EndDialog(hdlg,TRUE);
  327. return TRUE;
  328. }
  329. else if ( LOWORD(wp) == IDCANCEL )
  330. {
  331. #ifndef UNDER_CE // Windows CE does not support RemoveProp
  332. //RemoveProp(hdlg,TEXT("CMPROP"));
  333. if(::IsWindowUnicode(hdlg)) {
  334. ::RemovePropW(hdlg, L"CMPROP");
  335. }
  336. else {
  337. ::RemovePropA(hdlg, "CMPROP");
  338. }
  339. #endif // UNDER_CE
  340. EndDialog(hdlg,FALSE);
  341. return TRUE;
  342. }
  343. default:
  344. return FALSE;
  345. }
  346. }
  347. LRESULT WINAPI CACMBBtnWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
  348. {
  349. //990810:ToshiaK for Win64
  350. //CHwxInkWindow * app = (CHwxInkWindow *)GetWindowLong(hwnd,GWL_USERDATA);
  351. CHwxInkWindow * app = (CHwxInkWindow *)WinGetUserPtr(hwnd);
  352. if ( !app )
  353. return 0;
  354. return app->HandleBtnSubWnd(hwnd,msg,wp,lp);
  355. }