home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR9 / WDOS0793.ZIP / BONNEAU.ZIP / DLGSERVR.C next >
C/C++ Source or Header  |  1993-05-05  |  1KB  |  49 lines

  1. /*****************************************************/
  2. /* dlgservr.c                                        */
  3. /* -- Modeless common dialog server.                 */
  4. /* -- To compile:                                    */
  5. /*    cc dlgservr.c commdlg.lib                      */
  6. /*****************************************************/
  7.  
  8. #include <windows.h>
  9. #include <windowsx.h>
  10. #include <commdlg.h>
  11.  
  12. UINT CALLBACK __export WHook(HWND, UINT, WPARAM, LPARAM);
  13.  
  14. #ifdef __BORLANDC__
  15.     #pragma argsused
  16. #endif
  17. int PASCAL WinMain(HINSTANCE hins, HINSTANCE hinsPrev,
  18.                                        LPSTR lsz, int wShow)
  19.     {
  20.     MSG msg;
  21.  
  22.     while (GetMessage(&msg, NULL, 0, 0))
  23.         if (msg.message == WM_USER)
  24.             {
  25.             ((LPCHOOSEFONT)msg.lParam)->lpfnHook =
  26.               WHook;
  27.             ChooseFont((LPCHOOSEFONT)msg.lParam);
  28.             GlobalFreePtr(msg.lParam);
  29.             break;
  30.             }
  31.     return 0;
  32.     }
  33.  
  34. UINT CALLBACK __export WHook(HWND hwnd, UINT wm,
  35.                                WPARAM wParam, LPARAM lParam)
  36. /*****************************************************/
  37. /* -- Relay messages to client's hook function.      */
  38. /*****************************************************/
  39.     {
  40.     MSG msg;
  41.  
  42.     msg.hwnd = hwnd;
  43.     msg.message = wm;
  44.     msg.wParam = wParam;
  45.     msg.lParam = lParam;
  46.     return (UINT)SendMessage(GetWindowOwner(hwnd),
  47.       WM_USER, 0, (LPARAM)(LPMSG)&msg);
  48.     }
  49.