home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / WINPROPM.ZIP / EXAMDLG.C next >
Text File  |  1989-06-19  |  15KB  |  494 lines

  1. /* file : Examdlg.c
  2.  
  3.  
  4.         Created: 21:55:51 Mon Jun 19 1989
  5.  
  6.         Description:  Dialog processing functions for ExamplPM
  7.  
  8.         Skeleton by:  WINPRO/PM, a product from Louis J. Cutrona, Jr.
  9.                       Skeleton.pm (Revision 2.5)  
  10.  
  11. */
  12.  
  13. /* Activate standard window management definitions and typedefs */
  14. #define  INCL_WIN       1
  15.  
  16. #include <os2.h>
  17.  
  18. #include "Examrc.h"
  19. #include "Examgbl.h"
  20.  
  21. /* ----------------- ExamplPM Dialog Window Procdeures ------------------- */
  22.  
  23.  
  24.  
  25.  
  26. /* The dialog below is invoked in the following situations */
  27.  
  28. /* Action bar item: ~File */
  29. /* WM_COMMAND message: Pulldown item: A~bout ExamplPM... */
  30.  
  31. MRESULT EXPENTRY ABOUTDlgWndProc( hDlg, msg, mp1, mp2 )
  32. HWND      hDlg;
  33. USHORT    msg;
  34. MPARAM    mp1;
  35. MPARAM    mp2;
  36. {
  37.    USHORT NotificationCode;
  38.    PVOID  pControlData;
  39.  
  40.    gbl_hDlg = hDlg;
  41.  
  42.    NotificationCode = SHORT2FROMMP( mp1 ) ;
  43.    pControlData = PVOIDFROMMP( mp2 ) ;
  44.  
  45.    switch( msg )
  46.    {
  47.    case WM_COMMAND:
  48.    case WM_CONTROL:
  49.       switch( SHORT1FROMMP( mp1 ) )
  50.       {
  51.       case DID_OK:
  52.  
  53.       /* DID_CANCEL is not specified for this dialog, but */
  54.       /* code is included here to handle a message from   */
  55.       /* the Esc key to terminate the dialog.  If this is */
  56.       /* not correct, remove the case statement below.    */
  57.  
  58.       case DID_CANCEL:
  59.          /* Return control id to routine that invoked */
  60.          /* the dialog, so it knows how dialog ended  */
  61.          WinDismissDlg( hDlg, SHORT1FROMMP( mp1 ) ) ;
  62.          break;
  63.       default:
  64.          break;
  65.       }  /* end of switch on control id from WM_COMMAND or WM_CONTROL msg */
  66.       break;
  67.    case WM_INITDLG:
  68.       /* Dialog initialization code */
  69.  
  70.       return( FALSE ) ;    /* (FALSE means give us the focus ) */
  71.       break;
  72.    default:
  73.       /* We did not process the message */
  74.       return( WinDefDlgProc( hDlg, msg, mp1, mp2 ) ) ;
  75.    }
  76.    return 0L;
  77. }
  78.  
  79.  
  80. /* The dialog below is invoked in the following situations */
  81.  
  82. /* Action bar item: ~File */
  83. /* WM_COMMAND message: Pulldown item: ~Open... */
  84.  
  85. MRESULT EXPENTRY midFILEOPENDlgWndProc( hDlg, msg, mp1, mp2 )
  86. HWND      hDlg;
  87. USHORT    msg;
  88. MPARAM    mp1;
  89. MPARAM    mp2;
  90. {
  91.    USHORT NotificationCode;
  92.    PVOID  pControlData;
  93.  
  94.    gbl_hDlg = hDlg;
  95.  
  96.    NotificationCode = SHORT2FROMMP( mp1 ) ;
  97.    pControlData = PVOIDFROMMP( mp2 ) ;
  98.  
  99.    switch( msg )
  100.    {
  101.    case WM_COMMAND:
  102.    case WM_CONTROL:
  103.       switch( SHORT1FROMMP( mp1 ) )
  104.       {
  105.       case IDD_PATH:
  106.          if( NotificationCode == EN_KILLFOCUS )
  107.          /* User moved on to next control */
  108.          {
  109.             /* This is a nice place to do validation */
  110.             /* of whatever the user entered.         */
  111.          }
  112.          break;
  113.       case IDD_FILEEDIT:
  114.          if( NotificationCode == EN_KILLFOCUS )
  115.          /* User moved on to next control */
  116.          {
  117.             /* This is a nice place to do validation */
  118.             /* of whatever the user entered.         */
  119.          }
  120.          break;
  121.       case IDD_DIRLIST:
  122.          /* Your code to handle this LISTBOX control goes here */
  123.          break;
  124.       case IDD_FILELIST:
  125.          /* Your code to handle this LISTBOX control goes here */
  126.          break;
  127.       case DID_OK:
  128.          /* Copy current dialog control */
  129.          /* settings data into globals  */
  130.          WinQueryDlgItemText( hDlg, IDD_PATH,
  131.             sizeof( gbl_szIDD_PATH ),
  132.             (PSZ) gbl_szIDD_PATH ) ;
  133.          WinQueryDlgItemText( hDlg, IDD_FILEEDIT,
  134.             sizeof( gbl_szIDD_FILEEDIT ),
  135.             (PSZ) gbl_szIDD_FILEEDIT ) ;
  136.          /* Need to save state of LISTBOX IDD_DIRLIST?  Do it here */
  137.          /* Need to save state of LISTBOX IDD_FILELIST?  Do it here */
  138.  
  139.          /* Fall through to DID_CANCEL for DID_OK */
  140.       case DID_CANCEL:
  141.          /* Return control id to routine that invoked */
  142.          /* the dialog, so it knows how dialog ended  */
  143.          WinDismissDlg( hDlg, SHORT1FROMMP( mp1 ) ) ;
  144.          break;
  145.       default:
  146.          break;
  147.       }  /* end of switch on control id from WM_COMMAND or WM_CONTROL msg */
  148.       break;
  149.    case WM_INITDLG:
  150.       /* Dialog initialization code */
  151.  
  152.       /* Initialize controls from contents of globals */
  153.  
  154.       /* Tell control how many characters it should hold */
  155.       WinSendDlgItemMsg( hDlg, IDD_PATH,
  156.          EM_SETTEXTLIMIT,
  157.          (MPARAM) sizeof( gbl_szIDD_PATH ),
  158.          0L
  159.          ) ;
  160.       /* Fill in current value from global */
  161.       WinSetDlgItemText( hDlg, IDD_PATH,
  162.          (PSZ) gbl_szIDD_PATH
  163.          ) ;
  164.       /* Tell control how many characters it should hold */
  165.       WinSendDlgItemMsg( hDlg, IDD_FILEEDIT,
  166.          EM_SETTEXTLIMIT,
  167.          (MPARAM) sizeof( gbl_szIDD_FILEEDIT ),
  168.          0L
  169.          ) ;
  170.       /* Fill in current value from global */
  171.       WinSetDlgItemText( hDlg, IDD_FILEEDIT,
  172.          (PSZ) gbl_szIDD_FILEEDIT
  173.          ) ;
  174.       /* Initialize LISTBOX IDD_DIRLIST here */
  175.       /* Initialize LISTBOX IDD_FILELIST here */
  176.  
  177.       return( FALSE ) ;    /* (FALSE means give us the focus ) */
  178.       break;
  179.    default:
  180.       /* We did not process the message */
  181.       return( WinDefDlgProc( hDlg, msg, mp1, mp2 ) ) ;
  182.    }
  183.    return 0L;
  184. }
  185.  
  186.  
  187. /* The dialog below is invoked in the following situations */
  188.  
  189. /* Action bar item: ~Create */
  190. /* WM_COMMAND message: Pulldown item: ~Process... */
  191.  
  192. MRESULT EXPENTRY midCREATEPROCESSDlgWndProc( hDlg, msg, mp1, mp2 )
  193. HWND      hDlg;
  194. USHORT    msg;
  195. MPARAM    mp1;
  196. MPARAM    mp2;
  197. {
  198.    USHORT NotificationCode;
  199.    PVOID  pControlData;
  200.  
  201.    gbl_hDlg = hDlg;
  202.  
  203.    NotificationCode = SHORT2FROMMP( mp1 ) ;
  204.    pControlData = PVOIDFROMMP( mp2 ) ;
  205.  
  206.    switch( msg )
  207.    {
  208.    case WM_COMMAND:
  209.    case WM_CONTROL:
  210.       switch( SHORT1FROMMP( mp1 ) )
  211.       {
  212.       case GP_SIFNAME:
  213.          if( NotificationCode == EN_KILLFOCUS )
  214.          /* User moved on to next control */
  215.          {
  216.             /* This is a nice place to do validation */
  217.             /* of whatever the user entered.         */
  218.          }
  219.          break;
  220.       case GP_LOFFSET:
  221.          if( NotificationCode == EN_KILLFOCUS )
  222.          /* User moved on to next control */
  223.          {
  224.             /* This is a nice place to do validation */
  225.             /* of whatever the user entered.         */
  226.          }
  227.          break;
  228.       case GP_TOFFSET:
  229.          if( NotificationCode == EN_KILLFOCUS )
  230.          /* User moved on to next control */
  231.          {
  232.             /* This is a nice place to do validation */
  233.             /* of whatever the user entered.         */
  234.          }
  235.          break;
  236.       case GP_WIDTH:
  237.          if( NotificationCode == EN_KILLFOCUS )
  238.          /* User moved on to next control */
  239.          {
  240.             /* This is a nice place to do validation */
  241.             /* of whatever the user entered.         */
  242.          }
  243.          break;
  244.       case GP_HEIGHT:
  245.          if( NotificationCode == EN_KILLFOCUS )
  246.          /* User moved on to next control */
  247.          {
  248.             /* This is a nice place to do validation */
  249.             /* of whatever the user entered.         */
  250.          }
  251.          break;
  252.       case GP_HSCALE:
  253.          if( NotificationCode == EN_KILLFOCUS )
  254.          /* User moved on to next control */
  255.          {
  256.             /* This is a nice place to do validation */
  257.             /* of whatever the user entered.         */
  258.          }
  259.          break;
  260.       case GP_VSCALE:
  261.          if( NotificationCode == EN_KILLFOCUS )
  262.          /* User moved on to next control */
  263.          {
  264.             /* This is a nice place to do validation */
  265.             /* of whatever the user entered.         */
  266.          }
  267.          break;
  268.       case GP_FORSCREEN:
  269.       case GP_FORPRINTER:
  270.       case GP_PRINT:
  271.          /* AUTORADIOBUTTON. Automatically checks itself    */
  272.          /* when clicked and unchecks any other auto radio  */
  273.          /* buttons in the same group.  If that's all you   */
  274.          /* want to happen, you don't have to do anything   */
  275.          /* here at all.                                    */
  276.          break;
  277.       case GP_FAVORWHITE:
  278.          /* BS_AUTOCHECKBOX toggles itself when user clicks it */
  279.          /* State has already changed at this point */
  280.          break;
  281.       case GP_FAVORBLACK:
  282.          /* BS_AUTO3STATE cycles itself each time user clicks it */
  283.          /* Sequence: unchecked, checked, greyed, unchecked, ... */
  284.          /* State has already changed at this point */
  285.          break;
  286.       case GP_DEFAULTS:
  287.          /* PUSHBUTTON was clicked or double clicked */
  288.          break;
  289.       case DID_OK:
  290.          /* Copy current dialog control */
  291.          /* settings data into globals  */
  292.          WinQueryDlgItemText( hDlg, GP_SIFNAME,
  293.             sizeof( gbl_szGP_SIFNAME ),
  294.             (PSZ) gbl_szGP_SIFNAME ) ;
  295.          WinQueryDlgItemText( hDlg, GP_LOFFSET,
  296.             sizeof( gbl_szGP_LOFFSET ),
  297.             (PSZ) gbl_szGP_LOFFSET ) ;
  298.          WinQueryDlgItemText( hDlg, GP_TOFFSET,
  299.             sizeof( gbl_szGP_TOFFSET ),
  300.             (PSZ) gbl_szGP_TOFFSET ) ;
  301.          WinQueryDlgItemText( hDlg, GP_WIDTH,
  302.             sizeof( gbl_szGP_WIDTH ),
  303.             (PSZ) gbl_szGP_WIDTH ) ;
  304.          WinQueryDlgItemText( hDlg, GP_HEIGHT,
  305.             sizeof( gbl_szGP_HEIGHT ),
  306.             (PSZ) gbl_szGP_HEIGHT ) ;
  307.          WinQueryDlgItemText( hDlg, GP_HSCALE,
  308.             sizeof( gbl_szGP_HSCALE ),
  309.             (PSZ) gbl_szGP_HSCALE ) ;
  310.          WinQueryDlgItemText( hDlg, GP_VSCALE,
  311.             sizeof( gbl_szGP_VSCALE ),
  312.             (PSZ) gbl_szGP_VSCALE ) ;
  313.          {
  314.             SHORT i ;
  315.  
  316.             for( i = GP_FORSCREEN; i <= GP_PRINT; i++ )
  317.             {
  318.                if( (MRESULT) 1 == WinSendDlgItemMsg( hDlg, i,
  319.                   BM_QUERYCHECK, NULL, NULL ) )
  320.                {
  321.                   gbl_sGP_FORSCREEN_to_GP_PRINT = i;
  322.                   break;
  323.                }
  324.             }
  325.          }
  326.          gbl_sGP_FAVORWHITE =
  327.             SHORT1FROMMR( WinSendDlgItemMsg( hDlg, GP_FAVORWHITE,
  328.                BM_QUERYCHECK, NULL, NULL ) ) ;
  329.          gbl_sGP_FAVORBLACK =
  330.             SHORT1FROMMR( WinSendDlgItemMsg( hDlg, GP_FAVORBLACK,
  331.                BM_QUERYCHECK, NULL, NULL ) ) ;
  332.  
  333.          /* Fall through to DID_CANCEL for DID_OK */
  334.       case DID_CANCEL:
  335.          /* Return control id to routine that invoked */
  336.          /* the dialog, so it knows how dialog ended  */
  337.          WinDismissDlg( hDlg, SHORT1FROMMP( mp1 ) ) ;
  338.          break;
  339.       default:
  340.          break;
  341.       }  /* end of switch on control id from WM_COMMAND or WM_CONTROL msg */
  342.       break;
  343.    case WM_INITDLG:
  344.       /* Dialog initialization code */
  345.  
  346.       /* Initialize controls from contents of globals */
  347.  
  348.       /* Tell control how many characters it should hold */
  349.       WinSendDlgItemMsg( hDlg, GP_SIFNAME,
  350.          EM_SETTEXTLIMIT,
  351.          (MPARAM) sizeof( gbl_szGP_SIFNAME ),
  352.          0L
  353.          ) ;
  354.       /* Fill in current value from global */
  355.       WinSetDlgItemText( hDlg, GP_SIFNAME,
  356.          (PSZ) gbl_szGP_SIFNAME
  357.          ) ;
  358.       /* Tell control how many characters it should hold */
  359.       WinSendDlgItemMsg( hDlg, GP_LOFFSET,
  360.          EM_SETTEXTLIMIT,
  361.          (MPARAM) sizeof( gbl_szGP_LOFFSET ),
  362.          0L
  363.          ) ;
  364.       /* Fill in current value from global */
  365.       WinSetDlgItemText( hDlg, GP_LOFFSET,
  366.          (PSZ) gbl_szGP_LOFFSET
  367.          ) ;
  368.       /* Tell control how many characters it should hold */
  369.       WinSendDlgItemMsg( hDlg, GP_TOFFSET,
  370.          EM_SETTEXTLIMIT,
  371.          (MPARAM) sizeof( gbl_szGP_TOFFSET ),
  372.          0L
  373.          ) ;
  374.       /* Fill in current value from global */
  375.       WinSetDlgItemText( hDlg, GP_TOFFSET,
  376.          (PSZ) gbl_szGP_TOFFSET
  377.          ) ;
  378.       /* Tell control how many characters it should hold */
  379.       WinSendDlgItemMsg( hDlg, GP_WIDTH,
  380.          EM_SETTEXTLIMIT,
  381.          (MPARAM) sizeof( gbl_szGP_WIDTH ),
  382.          0L
  383.          ) ;
  384.       /* Fill in current value from global */
  385.       WinSetDlgItemText( hDlg, GP_WIDTH,
  386.          (PSZ) gbl_szGP_WIDTH
  387.          ) ;
  388.       /* Tell control how many characters it should hold */
  389.       WinSendDlgItemMsg( hDlg, GP_HEIGHT,
  390.          EM_SETTEXTLIMIT,
  391.          (MPARAM) sizeof( gbl_szGP_HEIGHT ),
  392.          0L
  393.          ) ;
  394.       /* Fill in current value from global */
  395.       WinSetDlgItemText( hDlg, GP_HEIGHT,
  396.          (PSZ) gbl_szGP_HEIGHT
  397.          ) ;
  398.       /* Tell control how many characters it should hold */
  399.       WinSendDlgItemMsg( hDlg, GP_HSCALE,
  400.          EM_SETTEXTLIMIT,
  401.          (MPARAM) sizeof( gbl_szGP_HSCALE ),
  402.          0L
  403.          ) ;
  404.       /* Fill in current value from global */
  405.       WinSetDlgItemText( hDlg, GP_HSCALE,
  406.          (PSZ) gbl_szGP_HSCALE
  407.          ) ;
  408.       /* Tell control how many characters it should hold */
  409.       WinSendDlgItemMsg( hDlg, GP_VSCALE,
  410.          EM_SETTEXTLIMIT,
  411.          (MPARAM) sizeof( gbl_szGP_VSCALE ),
  412.          0L
  413.          ) ;
  414.       /* Fill in current value from global */
  415.       WinSetDlgItemText( hDlg, GP_VSCALE,
  416.          (PSZ) gbl_szGP_VSCALE
  417.          ) ;
  418.       /* Activate currently selected radio button */
  419.       {
  420.          SHORT i ;
  421.  
  422.          for( i = GP_FORSCREEN; i <= GP_PRINT; i++ )
  423.             WinSendDlgItemMsg( hDlg, i,
  424.                BM_SETCHECK,
  425.                (MPARAM) ( i == gbl_sGP_FORSCREEN_to_GP_PRINT ),
  426.                NULL
  427.                ) ;
  428.       }
  429.       WinSendDlgItemMsg( hDlg, GP_FAVORWHITE,
  430.          BM_SETCHECK,
  431.          (MPARAM) gbl_sGP_FAVORWHITE,
  432.          NULL
  433.          ) ;
  434.       WinSendDlgItemMsg( hDlg, GP_FAVORBLACK,
  435.          BM_SETCHECK,
  436.          (MPARAM) gbl_sGP_FAVORBLACK,
  437.          NULL
  438.          ) ;
  439.  
  440.       return( FALSE ) ;    /* (FALSE means give us the focus ) */
  441.       break;
  442.    default:
  443.       /* We did not process the message */
  444.       return( WinDefDlgProc( hDlg, msg, mp1, mp2 ) ) ;
  445.    }
  446.    return 0L;
  447. }
  448.  
  449.  
  450. MRESULT EXPENTRY PRINTERABORTDlgWndProc( hDlg, msg, mp1, mp2 )
  451. HWND      hDlg;
  452. USHORT    msg;
  453. MPARAM    mp1;
  454. MPARAM    mp2;
  455. {
  456.    USHORT NotificationCode;
  457.    PVOID  pControlData;
  458.  
  459.    gbl_hDlg = hDlg;
  460.  
  461.    NotificationCode = SHORT2FROMMP( mp1 ) ;
  462.    pControlData = PVOIDFROMMP( mp2 ) ;
  463.  
  464.    switch( msg )
  465.    {
  466.    case WM_COMMAND:
  467.    case WM_CONTROL:
  468.       switch( SHORT1FROMMP( mp1 ) )
  469.       {
  470.       case DID_CANCEL:
  471.          /* Return control id to routine that invoked */
  472.          /* the dialog, so it knows how dialog ended  */
  473.          WinDismissDlg( hDlg, SHORT1FROMMP( mp1 ) ) ;
  474.          break;
  475.       default:
  476.          break;
  477.       }  /* end of switch on control id from WM_COMMAND or WM_CONTROL msg */
  478.       break;
  479.    case WM_INITDLG:
  480.       /* Dialog initialization code */
  481.  
  482.       return( FALSE ) ;    /* (FALSE means give us the focus ) */
  483.       break;
  484.    default:
  485.       /* We did not process the message */
  486.       return( WinDefDlgProc( hDlg, msg, mp1, mp2 ) ) ;
  487.    }
  488.    return 0L;
  489. }
  490.  
  491.  
  492.  
  493. /*   E N D   O F   E X A M D L G . C   */
  494.