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.

171 lines
6.0 KiB

  1. #include "stdafx.h"
  2. #include "resource.h"
  3. #include "wiaregme.h"
  4. #include "msgwrap.h"
  5. CMessageWrapper g_MsgWrapper;
  6. //////////////////////////////////////////////////////////////////////////
  7. //
  8. // Function: WinMain()
  9. // Details: This function is WinMain... enough said. ;) It creates a Modal
  10. // dialog as the main application window.
  11. //
  12. // hInstance - instance of this application
  13. // hPrevInstance - Previous instance of this applcation (already running)
  14. // lpCmdLine - command line arguments
  15. // nCmdShow - show state, specifies how the window should be shown
  16. //
  17. //////////////////////////////////////////////////////////////////////////
  18. INT APIENTRY WinMain(HINSTANCE hInstance,
  19. HINSTANCE hPrevInstance,
  20. LPSTR lpCmdLine,
  21. int nCmdShow)
  22. {
  23. CoInitialize(NULL);
  24. g_MsgWrapper.Initialize(hInstance);
  25. DialogBox(hInstance, (LPCTSTR)IDD_MAIN_DIALOG, NULL, (DLGPROC)MainDlg);
  26. CoUninitialize();
  27. return 0;
  28. }
  29. //////////////////////////////////////////////////////////////////////////
  30. //
  31. // Function: MainDlg()
  32. // Details: This function is the Window Proc for this dialog. It
  33. // dispatches messages to their correct handlers. If there is
  34. // handler, we let Windows handle the message for us.
  35. //
  36. // hDlg - handle to the dialog's window
  37. // message - windows message (incoming from system)
  38. // wParam - WPARAM parameter (used for windows data/argument passing)
  39. // lParam - LPARAM parameter (used for windows data/argument passing)
  40. //
  41. //////////////////////////////////////////////////////////////////////////
  42. LRESULT CALLBACK MainDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  43. {
  44. INT wmId = 0;
  45. INT wmEvent = 0;
  46. TCHAR szApplicationFilePath[1024];
  47. HWND hApplicationPathEditBox = NULL;
  48. switch (message)
  49. {
  50. //
  51. // We want first crack at processing any messages
  52. //
  53. case WM_INITDIALOG:
  54. return g_MsgWrapper.OnInitDialog(hDlg);
  55. break;
  56. case WM_COMMAND:
  57. wmId = LOWORD(wParam);
  58. wmEvent = HIWORD(wParam);
  59. switch(wmId)
  60. {
  61. //
  62. // Trap Button IDs, and Menu IDs
  63. //
  64. case IDC_WIA_DEVICE_LIST:
  65. if(wmEvent == LBN_SELCHANGE){
  66. if(!g_MsgWrapper.OnRefreshEventListBox(hDlg)){
  67. g_MsgWrapper.EnableAllControls(hDlg, FALSE);
  68. } else {
  69. g_MsgWrapper.EnableAllControls(hDlg, TRUE);
  70. }
  71. }
  72. break;
  73. case IDC_BROWSE_BUTTON: // BROWSE (Button)
  74. if(g_MsgWrapper.OnBrowse(hDlg,szApplicationFilePath)){
  75. //
  76. // register this Application Path
  77. //
  78. hApplicationPathEditBox = GetDlgItem(hDlg,IDC_APPLICATION_LAUNCH_PATH_EDITBOX);
  79. SetWindowText(hApplicationPathEditBox,szApplicationFilePath);
  80. }
  81. break;
  82. case IDC_REGISTER_BUTTON: // REGISTER (Button)
  83. if(g_MsgWrapper.Register(hDlg,WIA_REGISTER_EVENT_CALLBACK)){
  84. }
  85. break;
  86. case IDC_UNREGISTER_BUTTON: // UNREGISTER (Button)
  87. if(g_MsgWrapper.Register(hDlg,WIA_UNREGISTER_EVENT_CALLBACK)){
  88. }
  89. break;
  90. case IDCANCEL: // CANCEL (Button)
  91. case IDM_EXIT: // FILE | EXIT (Menu)
  92. return g_MsgWrapper.OnExit(hDlg,wParam);
  93. break;
  94. case IDM_ABOUT: // HELP | ABOUT (Menu)
  95. g_MsgWrapper.OnAbout(hDlg);
  96. break;
  97. default:
  98. break;
  99. }
  100. break;
  101. default:
  102. //
  103. // Let windows take care of it (DefWindowProc(hDlg,message,wParam,lParam))
  104. //
  105. break;
  106. }
  107. return FALSE;
  108. }
  109. #ifdef _OVERRIDE_LIST_BOXES
  110. //////////////////////////////////////////////////////////////////////////
  111. //
  112. // Function: DeviceListBox()
  113. // Details: This function is the Window Proc for the Device ListBox. It
  114. // dispatches messages to their correct handlers. If there is
  115. // handler, we let Windows handle the message for us.
  116. //
  117. // hDlg - handle to the dialog's window
  118. // message - windows message (incoming from system)
  119. // wParam - WPARAM parameter (used for windows data/argument passing)
  120. // lParam - LPARAM parameter (used for windows data/argument passing)
  121. //
  122. //////////////////////////////////////////////////////////////////////////
  123. LRESULT CALLBACK DeviceListBox(HWND hListBox, UINT message, WPARAM wParam, LPARAM lParam)
  124. {
  125. INT wmId = 0;
  126. INT wmEvent = 0;
  127. return DefDeviceListBox(hListBox,message,wParam,lParam);
  128. }
  129. //////////////////////////////////////////////////////////////////////////
  130. //
  131. // Function: EventListBox()
  132. // Details: This function is the Window Proc for the Event ListBox. It
  133. // dispatches messages to their correct handlers. If there is
  134. // handler, we let Windows handle the message for us.
  135. //
  136. // hDlg - handle to the dialog's window
  137. // message - windows message (incoming from system)
  138. // wParam - WPARAM parameter (used for windows data/argument passing)
  139. // lParam - LPARAM parameter (used for windows data/argument passing)
  140. //
  141. //////////////////////////////////////////////////////////////////////////
  142. LRESULT CALLBACK EventListBox(HWND hListBox, UINT message, WPARAM wParam, LPARAM lParam)
  143. {
  144. INT wmId = 0;
  145. INT wmEvent = 0;
  146. return DefEventListBox(hListBox,message,wParam,lParam);
  147. }
  148. #endif