home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / SAMPLES / PM / PORTING / IMG_DLG.C < prev    next >
C/C++ Source or Header  |  1995-08-24  |  5KB  |  139 lines

  1. /*static char *SCCSID = "@(#)img_dlg.c    6.6 92/02/10";*/
  2. /**************************************************************************
  3.  *  File name  :  img_dlg.c
  4.  *
  5.  *  Description:  This module contains the code for handling the
  6.  *                Product information dialog box.
  7.  *                This source file contains the following functions:
  8.  *
  9.  *                ProductInfoDlgProc(hwnd, msg, mp1, mp2)
  10.  *                SetSysMenu(hwnd)
  11.  *
  12.  *  Concepts   :  This is used only to allow deletion of certain
  13.  *                System Menu items when the dialog is started.
  14.  *
  15.  *  API's      :  WinDefDlgProc
  16.  *                WinSendMsg
  17.  *                WinWindowFromID
  18.  *
  19.  *  Required
  20.  *    Files    :  OS2.H, STRING.H, IMG_MAIN.H, IMG_XTRN.H, IMG_DLG.H
  21.  *
  22.  *  Copyright (C) 1991 IBM Corporation
  23.  *
  24.  *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  25.  *      sample code created by IBM Corporation. This sample code is not
  26.  *      part of any standard or IBM product and is provided to you solely
  27.  *      for  the purpose of assisting you in the development of your
  28.  *      applications.  The code is provided "AS IS", without
  29.  *      warranty of any kind.  IBM shall not be liable for any damages
  30.  *      arising out of your use of the sample code, even if they have been
  31.  *      advised of the possibility of such damages.                                                    *
  32.  *************************************************************************/
  33. /*
  34.  *  Include files, macros, defined constants, and externs
  35.  */
  36. #define INCL_WINMENUS
  37. #define INCL_WINFRAMEMGR
  38. #define INCL_WINSTDFILE
  39. #include <os2.h>
  40. #include <string.h>
  41.  
  42. #include "img_main.h"
  43. #include "img_xtrn.h"
  44. #include "img_dlg.h"
  45.  
  46. /**************************************************************************
  47.  *
  48.  *  Name       : ProductInfoDlgProc(hwnd, msg, mp1, mp2)
  49.  *
  50.  *  Description: Processes messages sent to the Product information dialog
  51.  *
  52.  *  Concepts   : the Product information dialog has only a button control,
  53.  *               so this routine processes only WM_COMMAND messages.  Any
  54.  *               WM_COMMAND posted must have come from the OK
  55.  *               button, so we dismiss the dialog upon receiving it.
  56.  *
  57.  *  API's      : WinDefDlgProc
  58.  *
  59.  *  Parameters : hwnd = the dialog box handle
  60.  *               msg = the message sent to the Product information dialog
  61.  *               mp1 = the first message parameter
  62.  *               mp2 = the second message parameter
  63.  *
  64.  *  Return     : Dependent upon message sent;  NULL = successful
  65.  *
  66. \*************************************************************************/
  67. #ifdef PORT_16
  68. MRESULT EXPENTRY ProductInfoDlgProc(HWND hwnd, USHORT msg, MPARAM mp1,MPARAM mp2)
  69. #endif
  70. #ifdef PORT_32
  71. MRESULT EXPENTRY ProductInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,MPARAM mp2)
  72. #endif
  73. {
  74.     switch (msg)
  75.     {
  76.         case WM_INITDLG:
  77.             SetSysMenu(hwnd);       /* system menu for this dialog  */
  78.             return MRFROMSHORT(FALSE);
  79.  
  80.         default:
  81.             return WinDefDlgProc(hwnd, msg, mp1, mp2);
  82.     }
  83.     return MRFROMSHORT(0);
  84. } /* End of ProductInfoDlgProc  */
  85.  
  86. /**************************************************************************
  87.  *
  88.  *  Name       : SetSysMenu(HWND hDlg)
  89.  *
  90.  *  Description: This sets only Move and Close menu items for any dialog.
  91.  *
  92.  *  Concepts   : Unless particular menu items are deleted, the System Menu
  93.  *               will show disabled items.
  94.  *
  95.  *  API's      : WinSendMsg
  96.  *               WinWindowFromID
  97.  *
  98.  *  Parameters : hDlg = the dialog box handle
  99.  *
  100.  *  Return     : [none]
  101.  *
  102.  *************************************************************************/
  103. VOID SetSysMenu(HWND hDlg)
  104. {
  105.     HWND     hSysMenu;
  106.     MENUITEM Mi;
  107.     SHORT    Pos;
  108.     ULONG    Id;
  109.     SHORT    cItems;
  110.  
  111.     /*
  112.      *  We only want Move and Close in the system menu.
  113.      */
  114.  
  115.     hSysMenu = WinWindowFromID(hDlg, FID_SYSMENU);
  116.     WinSendMsg( hSysMenu, MM_QUERYITEM
  117.               , MPFROM2SHORT(SC_SYSMENU, FALSE), MPFROMP((PCH) & Mi));
  118.     Pos = 0;
  119.     cItems = SHORT1FROMMR(WinSendMsg(Mi.hwndSubMenu, MM_QUERYITEMCOUNT,
  120.                                 (MPARAM)NULL, (MPARAM)NULL));
  121.     while (cItems--)
  122.     {
  123.         Id = (ULONG) WinSendMsg( Mi.hwndSubMenu, MM_ITEMIDFROMPOSITION
  124.                           , MPFROM2SHORT(Pos, TRUE), (MPARAM)NULL);
  125.         switch (SHORT1FROMMP(Id))
  126.         {
  127.         case SC_MOVE:
  128.         case SC_CLOSE:
  129.             Pos++;              /* Don't delete that one. */
  130.             break;
  131.         default:
  132.             WinSendMsg( Mi.hwndSubMenu, MM_DELETEITEM
  133.                       , MPFROM2SHORT(Id, TRUE), (MPARAM)NULL);
  134.         }
  135.     }
  136. } /* End of SetSysMenu  */
  137. /***************************  End of img_dlg.c   *************************/
  138.  
  139.