home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / videotlk.zip / SAMPLES / DIVE / DIALOG.C next >
Text File  |  1997-01-10  |  6KB  |  174 lines

  1. #define DIVE_ENABLED
  2. #define VCAI_ENABLED
  3. #define VCAI_MONITOR
  4.  
  5. #define INCL_DOS
  6. #define INCL_PM
  7. #define INCL_OS2MM
  8. #define INCL_SW
  9. #define INCL_GPI
  10. #define INCL_WIN
  11. #define INCL_32
  12.  
  13. #include <os2.h>
  14. #include <os2me.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17.  
  18. #define  _MEERROR_H_
  19. #include <mmioos2.h>                   /* It is from MMPM toolkit           */
  20. #include <dive.h>
  21. #include <fourcc.h>
  22. #include <vcadd.h>
  23. #include <vcai.h>
  24.  
  25. #include "wtv.h"
  26.  
  27. /* External variables                                                       */
  28. extern HWND HwndNBFrame;                /* Notebook frame handle            */
  29. extern BOOL NotebookOpen;               /* Is notebook open?                */
  30.  
  31. static HWND                 hwndNotebook;       /* handle to the window     */
  32.  
  33. /* This function handles the call to the mmos2 setup notebook               */
  34. MRESULT EXPENTRY NotebookDlgProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  35. {
  36. static BOOL                 start;
  37. static PWINDATA             win_data = NULL;    /* Pointer to window data   */
  38. MCI_DEVICESETTINGS_PARMS    mci;                /* The notebook thru' MCI   */
  39. HPS                         hps;
  40. RECTL                       rcl;
  41. ULONG                       id, result;
  42. HWND                        hwndPage;
  43. LONG                        bx, by, cx, cy, ty, x, y;
  44. SWP                         swp;
  45. char                        txt[100];
  46.  
  47.     /* Get the pointer to window data                                       */
  48.     if (win_data == NULL)
  49.     {
  50.         if ((win_data = (PWINDATA)WinQueryWindowULong (hwnd, 0)) == NULL)
  51.             return WinDefWindowProc (hwnd, msg, mp1, mp2);
  52.     }
  53.  
  54.     switch (msg)
  55.     {
  56.     case WM_INITDLG:
  57.         /* Set the notebook in the correct colours etc.                     */
  58.         hwndNotebook = WinWindowFromID (hwnd, IDD_NOTE_BOOK);
  59.         WinSendMsg (hwndNotebook,
  60.                     BKM_SETNOTEBOOKCOLORS, MPFROMLONG (CLR_PALEGRAY),
  61.                     MPFROMSHORT (BKA_BACKGROUNDPAGECOLORINDEX));
  62.         WinSendMsg (hwndNotebook,
  63.                     BKM_SETNOTEBOOKCOLORS, MPFROMLONG (CLR_PALEGRAY),
  64.                     MPFROMSHORT (BKA_BACKGROUNDMAJORCOLORINDEX));
  65.         WinSendMsg (hwndNotebook,
  66.                     BKM_SETNOTEBOOKCOLORS, MPFROMLONG (CLR_PALEGRAY),
  67.                     MPFROMSHORT (BKA_BACKGROUNDMINORCOLORINDEX));
  68.         cy = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
  69.         if (cy <= 480)
  70.         {
  71.             WinSendMsg (hwndNotebook, BKM_SETDIMENSIONS,
  72.                         MPFROM2SHORT (100, 24),
  73.                         MPFROMSHORT (BKA_MAJORTAB));
  74.             WinSendMsg (hwndNotebook, BKM_SETDIMENSIONS,
  75.                         MPFROM2SHORT (75, 24),
  76.                         MPFROMSHORT (BKA_MINORTAB));
  77.         }
  78.         else
  79.         {
  80.             WinSendMsg (hwndNotebook, BKM_SETDIMENSIONS,
  81.                         MPFROM2SHORT (150, 24),
  82.                         MPFROMSHORT (BKA_MAJORTAB));
  83.             WinSendMsg (hwndNotebook, BKM_SETDIMENSIONS,
  84.                         MPFROM2SHORT (100, 24),
  85.                         MPFROMSHORT (BKA_MINORTAB));
  86.         }
  87.         mci.hwndCallback = HwndNBFrame;
  88.         mci.hwndNotebook = hwndNotebook;
  89.         mci.usDeviceType = 12;
  90.         sprintf (txt, "TV0%ld", win_data->win_vcai_no);
  91.         mci.pszDeviceName = txt;
  92.         hwndPage = (HWND)InsertAddr (&mci);
  93.         if (!hwndPage)
  94.         {
  95.             WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  96.                            (PSZ)"Unable to load setup pages",
  97.                            (PSZ)WTV_NAME,
  98.                            0, MB_OK | MB_ERROR);
  99.             return 0;
  100.         }
  101.         NotebookOpen = TRUE;
  102.         start = TRUE;
  103.         WinPostMsg (hwnd, WM_PAINT, NULL, NULL);
  104.         break;
  105.  
  106.     case WM_PAINT :
  107.         if (start)
  108.         {
  109.             cx = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
  110.             cy = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
  111.             x = cx / 8L;
  112.             y = 0L;
  113.             if (cy <= 480)
  114.             {
  115.                 cx = 480;
  116.                 cy = 480;
  117.             }
  118.             else
  119.             {
  120.                 cx = 640;
  121.                 cy = 600;
  122.             }
  123.             WinSetWindowPos (HwndNBFrame, HWND_TOP, x, y, cx, cy,
  124.                              SWP_SIZE | SWP_MOVE | SWP_SHOW);
  125.             WinQueryWindowRect (HwndNBFrame, &rcl);
  126.             bx = WinQuerySysValue (HWND_DESKTOP,
  127.                                    SV_CXSIZEBORDER);
  128.             by = WinQuerySysValue (HWND_DESKTOP,
  129.                                    SV_CYSIZEBORDER);
  130.             ty = WinQuerySysValue (HWND_DESKTOP, SV_CYTITLEBAR);
  131.             WinSetWindowPos (hwndNotebook, HWND_TOP,
  132.                              bx, by, rcl.xRight - (bx * 2),
  133.                              rcl.yTop - ty - (by * 2),
  134.                              SWP_SIZE | SWP_MOVE | SWP_SHOW);
  135.             start = FALSE;
  136.         }
  137.         hps = WinBeginPaint (hwnd, NULLHANDLE, &rcl);
  138.         WinQueryWindowRect (hwnd, &rcl);
  139.         WinFillRect (hps, &rcl, CLR_PALEGRAY);
  140.         WinEndPaint (hps);
  141.         break;
  142.  
  143.     case WM_ADJUSTWINDOWPOS :
  144.     case WM_MOVE :
  145.     case WM_SIZE :
  146.     case WM_WINDOWPOSCHANGED :
  147.         WinQueryWindowRect (HwndNBFrame, &rcl);
  148.         bx = WinQuerySysValue (HWND_DESKTOP, SV_CXSIZEBORDER);
  149.         by = WinQuerySysValue (HWND_DESKTOP, SV_CYSIZEBORDER);
  150.         ty = WinQuerySysValue (HWND_DESKTOP, SV_CYTITLEBAR);
  151.         WinSetWindowPos (hwndNotebook, HWND_TOP,
  152.                          bx, by, rcl.xRight - (bx * 2),
  153.                          rcl.yTop - ty - (by * 2),
  154.                          SWP_SIZE | SWP_MOVE | SWP_SHOW);
  155.         break;
  156.  
  157.     case WM_COMMAND :
  158.         return ((MRESULT)FALSE);
  159.  
  160.     case WM_CLOSE :
  161.         WinDestroySecondaryWindow (HwndNBFrame);
  162.         return ((MRESULT)FALSE);
  163.  
  164.     case WM_DESTROY :
  165.         WinPostMsg (win_data->win_hwnd_frame, WM_SIZE, NULL, NULL);
  166.         NotebookOpen = FALSE;
  167.         break;
  168.  
  169.     default :
  170.         break;
  171.     }
  172.     return WinDefSecondaryWindowProc (hwnd, msg, mp1, mp2);
  173. }
  174.