home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / FILESYS.PAK / FILESYS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  5.3 KB  |  205 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995 Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   filesys.c
  9. //
  10. //  PURPOSE:  Implements the window procedure for the main application
  11. //            window.  
  12. //
  13. //  FUNCTIONS:
  14. //    WndProc      - Processes messages for the main window.
  15. //    MsgCommand   - Handle the WM_COMMAND messages for the main window.
  16. //    MsgDestroy   - Handles the WM_DESTROY message by calling 
  17. //                   PostQuitMessage().
  18. //    CmdExit      - Handles the file exit command by calling destory 
  19. //                   window on the main window.
  20. //    CmdDemo      - Displays the "Demo" dialog box
  21. //
  22. //  COMMENTS:
  23. //
  24.  
  25. #include <windows.h>          // required for all Windows applications
  26. #include "globals.h"          // prototypes specific to this application
  27. #include "demo.h"
  28. #include "resource.h"
  29.  
  30.  
  31. // Main window message table definition.
  32. MSD rgmsd[] =
  33. {
  34.     {WM_COMMAND, MsgCommand},
  35.     {WM_DESTROY, MsgDestroy}
  36. };
  37.  
  38. MSDI msdiMain =
  39. {
  40.     sizeof(rgmsd) / sizeof(MSD),
  41.     rgmsd,
  42.     edwpWindow
  43. };
  44.  
  45. // Main window command table definition.
  46. CMD rgcmd[] =
  47. {
  48.     {IDM_DEMOFILESYS, CmdDemo},
  49.     {IDM_EXIT,        CmdExit},
  50.     {IDM_ABOUT,       CmdAbout}
  51. };
  52.  
  53. CMDI cmdiMain =
  54. {
  55.     sizeof(rgcmd) / sizeof(CMD),
  56.     rgcmd,
  57.     edwpWindow
  58. };
  59.  
  60.  
  61. //
  62. //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  63. //
  64. //  PURPOSE:  Processes messages for the main window.
  65. //
  66. //  PARAMETERS:
  67. //    hwnd     - window handle
  68. //    uMessage - message number
  69. //    wparam   - additional information (dependant on message number)
  70. //    lparam   - additional information (dependant on message number)
  71. //
  72. //  RETURN VALUE:
  73. //    The return value depends on the message number.  If the message
  74. //    is implemented in the message dispatch table, the return value is
  75. //    the value returned by the message handling function.  Otherwise,
  76. //    the return value is the value returned by the default window procedure.
  77. //
  78. //  COMMENTS:
  79. //    Call the DispMessage() function with the main window's message dispatch
  80. //    information (msdiMain) and the message specific information.
  81. //
  82.  
  83. LRESULT CALLBACK WndProc(HWND   hwnd, 
  84.                          UINT   uMessage, 
  85.                          WPARAM wparam, 
  86.                          LPARAM lparam)
  87. {
  88.  
  89.     return DispMessage(&msdiMain, hwnd, uMessage, wparam, lparam);
  90.  
  91. }
  92.  
  93.  
  94. //
  95. //  FUNCTION: MsgCommand(HWND, UINT, WPARAM, LPARAM)
  96. //
  97. //  PURPOSE: Handle the WM_COMMAND messages for the main window.
  98. //
  99. //  PARAMETERS:
  100. //    hwnd     - window handle
  101. //    uMessage - WM_COMMAND (Unused)
  102. //    GET_WM_COMMAND_ID(wparam, lparam)   - Command identifier
  103. //    GET_WM_COMMAND_HWND(wparam, lparam) - Control handle
  104. //
  105. //  RETURN VALUE:
  106. //    The return value depends on the message number.  If the message
  107. //    is implemented in the message dispatch table, the return value is
  108. //    the value returned by the message handling function.  Otherwise,
  109. //    the return value is the value returned by the default window procedure.
  110. //
  111. //  COMMENTS:
  112. //    Call the DispCommand() function with the main window's command dispatch
  113. //    information (cmdiMain) and the command specific information.
  114. //
  115.  
  116. #pragma argsused
  117. LRESULT MsgCommand(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  118. {
  119.     return DispCommand(&cmdiMain, hwnd, wparam, lparam);
  120. }
  121.  
  122.  
  123. //
  124. //  FUNCTION: MsgDestroy(HWND, UINT, WPARAM, LPARAM)
  125. //
  126. //  PURPOSE: Calls PostQuitMessage().
  127. //
  128. //  PARAMETERS:
  129. //
  130. //    hwnd      - Window handle  (Unused)
  131. //    uMessage  - Message number (Unused)
  132. //    wparam    - Extra data     (Unused)
  133. //    lparam    - Extra data     (Unused)
  134. //
  135. //  RETURN VALUE:
  136. //
  137. //    Always returns 0 - Message handled
  138. //
  139. //  COMMENTS:
  140. //
  141. //
  142.  
  143. #pragma argsused
  144. LRESULT MsgDestroy(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  145. {
  146.     PostQuitMessage(0);
  147.     return 0;
  148. }
  149.  
  150.  
  151. //
  152. //  FUNCTION: CmdExit(HWND, WORD, WORD, HWND)
  153. //
  154. //  PURPOSE: Exit the application.
  155. //
  156. //  PARAMETERS:
  157. //    hwnd     - The window.
  158. //    wCommand - IDM_EXIT (unused)
  159. //    wNotify  - Notification number (unused)
  160. //    hwndCtrl - NULL (unused)
  161. //
  162. //  RETURN VALUE:
  163. //    Always returns 0 - command handled.
  164. //
  165. //  COMMENTS:
  166. //
  167. //
  168.  
  169. #pragma argsused
  170. LRESULT CmdExit(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
  171. {
  172.     DestroyWindow(hwnd);
  173.     return 0;
  174. }
  175.  
  176.  
  177. //
  178. //  FUNCTION: CmdDemo(HWND, WORD, WORD, HWND)
  179. //
  180. //  PURPOSE: Displays the "Demo" dialog box
  181. //
  182. //  PARAMETERS:
  183. //    hwnd      - Window handle
  184. //    wCommand  - IDM_DEMOTABCTRL     (unused)
  185. //    wNotify   - Notification number (unused)
  186. //    hwndCtrl  - NULL (unused)
  187. //
  188. //  RETURN VALUE:
  189. //
  190. //    Always returns 0 - Message handled
  191. //
  192. //  COMMENTS:
  193. //    To process the IDM_DEMOFILESYS message, call DialogBox which
  194. //    will create the box according to the information in your resource
  195. //    script file and turn control over to the Demo() function.
  196. //
  197. //
  198.  
  199. #pragma argsused
  200. LRESULT CmdDemo(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
  201. {
  202.     DialogBox(hInst, "FILESYSTEM", hwnd, (DLGPROC) DemoDlgProc);
  203.     return 0;
  204. }
  205.