home *** CD-ROM | disk | FTP | other *** search
/ The Mother of All Windows Books / CD-MOM.iso / cd_mom / newsletr / winprogj / wpjv1n2 / lib2a.c < prev    next >
C/C++ Source or Header  |  1993-01-28  |  2KB  |  100 lines

  1. //*************************************************
  2. //*
  3. //* lib2a.c:  demonstrates a dialog box function
  4. //*               inside a DLL.
  5. //*
  6. //**************************************************
  7.  
  8. #define    NOCOMM
  9. #define    _WINDOWS
  10. #define    _WINDLL
  11.  
  12. #include    <windows.h>
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include "dlls.h"
  16.  
  17.  
  18. int FAR PASCAL WEP(int doNothing)
  19. {
  20.     return(1);
  21.  
  22. }    /* WEP */
  23.  
  24. //*************************************************************************>
  25.  
  26. void FAR PASCAL testVars(HWND hWnd, short far *num1, short far *num2)
  27. {
  28.     /* local variable */
  29.     static char string[30];        //scope in DLLs DS
  30.     short val;                        //scope in calling Apps SS
  31.  
  32.     MessageBox(hWnd, "In testVars!", "testVars", MB_OK);
  33.  
  34.     /* note that 'string' is declared static, thus it can be used in a */
  35.     /* Standard C library routine. 'string' is in the DLLs DS and not */
  36.     /* on the calling Apps SS. Also, pointers num1 and num2 scope is  */
  37.     /* in TESTLIB.DLL SS, which is RODSAPP DS. */
  38.     val= *num1 + *num2;
  39.     itoa(val, string, 10);
  40.     MessageBox(hWnd, string, "debug", MB_OK);
  41.  
  42.     /* demonstrates a near call inside the library */
  43.     nearCall(hWnd);
  44.  
  45. } /* testVars */
  46.  
  47. //**************************************************************************>
  48.  
  49. void NEAR nearCall(HWND hWnd)
  50. {
  51.     /* local variables */
  52.     char string[20];        //scope in calling Apps SS
  53.  
  54.     string[0]= 'G';
  55.     string[1]= 'r';
  56.     string[2]= 'e';
  57.     string[3]= 'a';
  58.     string[4]= 't';
  59.     string[5]= '\0';
  60.  
  61.     /* demonstrates */
  62.     testRoutine(hWnd, string);
  63.  
  64. } /* nearCall */
  65.  
  66. //*************************************************************************>
  67.  
  68. void FAR PASCAL testRoutine(HWND hWnd, char far *string)
  69. {
  70.  
  71.     MessageBox(hWnd, string, "testRoutine", MB_OK);
  72.  
  73. } /* testRoutine */
  74.  
  75. //*************************************************************************>
  76.  
  77. BOOL FAR PASCAL About(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
  78. {
  79.     switch (message) {
  80.  
  81.         case WM_INITDIALOG:
  82.             return(TRUE);
  83.  
  84.         case WM_COMMAND:
  85.  
  86.             if(wParam == IDOK || wParam == IDCANCEL) {
  87.  
  88.                 EndDialog(hDlg, TRUE);
  89.                 return(TRUE);
  90.  
  91.             }
  92.  
  93.             break;
  94.     }
  95.  
  96.     return(FALSE);
  97.  
  98. } /* About */
  99.  
  100.