home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / edctl1.zip / driver.c < prev    next >
C/C++ Source or Header  |  1994-03-12  |  6KB  |  214 lines

  1. #pragma    title("Prominare Designer  --  Version 2.10 -- (Colours.C)")
  2. #pragma    subtitle("   Prominare Designer - Interface Definitions")
  3.  
  4. #define    INCL_DOS           /* Include OS/2 DOS Kernal        */
  5. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  6. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  7. #define    INCL_WINSTDSPIN           /* Include OS/2 PM Spin Buttons    */
  8. #define    INCL_NLS           /* Include OS/2 PM NLS        */
  9. #define    INCL_SW               /* Include OS/2 MultiMedia Support    */
  10.  
  11. #pragma    info(nopar)
  12.  
  13. static char *MODID = "@(#)driver.c:1.07";
  14.  
  15. #include <os2.h>
  16. #include <string.h>
  17. #include <stdio.h>
  18.  
  19. #include "entryfld.h"
  20.  
  21. /* The application is created using the    following options in Prominare    */
  22. /* Builder:                                */
  23. /*                                    */
  24. /* Option           Value                        */
  25. /* ------           -----                        */
  26. /* Memory Model           Small                        */
  27. /* Op Sys           OS/2 2.x    PM Normal                */
  28. /* Optimization           Maximize                        */
  29. /* Compile Type           Compile Only                    */
  30. /*               Error Trap                    */
  31. /*               ExePack                        */
  32. /*               Link                        */
  33. /* CPU               80386                        */
  34. /* Warning Level       3                        */    
  35. /*                                    */
  36. /* Equivalent command line invocation of each module using the        */
  37. /* IBM C Set/2 Compiler    Version    1.0 is:                    */
  38. /*                                    */
  39. /*     Icc -G3s- -O+ -Sm -C -W3    -Fofilename filename.C            */
  40.  
  41. /* Filename:   Driver.C                            */
  42.  
  43. /*  Version:   2.10                            */
  44. /*  Created:   1990-12-29                        */
  45. /*  Revised:   1994-01-05                        */
  46.  
  47.  
  48. /* --------------------------------------------------------------------    */
  49.  
  50. /* --- Module Definitions ---------------------------------------------    */
  51.  
  52. #define    USER_RESERVED       8       /* Control Reserved Memory Size    */
  53.  
  54. PSZ pszDriverClassName = "Entryfield.Desktop";
  55.  
  56. HPOINTER hptrWait;
  57. HPOINTER hptrArrow;
  58. HWND     hwndDriver;           /* Program Window Handle        */
  59. HWND     hwndDriverFrame;       /* Program Frame Handle        */
  60. HAB     hAB;               /* Program Anchor Block Handle    */
  61. HMQ     hmqDriver;           /* Program Message Queue Handle    */
  62.  
  63. HWND     hwndList1;
  64.  
  65. HWND     hwndListA;
  66.  
  67. #define    RGBCLR_DIALOGBACKGROUND    0x00ccccccL
  68.  
  69. INT main(INT, CHAR *[ ]);
  70. MRESULT    EXPENTRY EntryWndProc(HWND hWnd, ULONG msg, MPARAM mp1,    MPARAM mp2);
  71. MRESULT    EXPENTRY DriverWndProc(HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2);
  72.  
  73.  
  74. #pragma    subtitle("   Client Window - Client Window Procedure")
  75. #pragma    page( )
  76.  
  77. /* --- DriverWndProc --------------------------------------------------    */
  78. /*                                    */
  79. /*     This function is    used to    process    the messages for the main    */
  80. /*     Client Window.                            */
  81. /*                                    */
  82. /*     Upon Entry:                            */
  83. /*                                    */
  84. /*     HWND   hWnd; = Window Handle                    */
  85. /*     ULONG  msg;  = PM Message                    */
  86. /*     MPARAM mp1;  = Message Parameter    1                */
  87. /*     MPARAM mp2;  = Message Parameter    2                */
  88. /*                                    */
  89. /*     Upon Exit:                            */
  90. /*                                    */
  91. /*     DriverWndProc = Message Handling    Result                */
  92. /*                                    */
  93. /* --------------------------------------------------------------------    */
  94.  
  95. MRESULT    EXPENTRY DriverWndProc(HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2)
  96.  
  97. {
  98. HPS         hPS;           /* Presentation Space Handle        */
  99. RECTL         rcl;           /* Client Window Rectangle        */
  100.  
  101. switch ( msg )
  102.    {
  103.                /* Perform window initialization            */
  104.    case    WM_CREATE :
  105.        hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,    FALSE);
  106.        WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  107.  
  108.        hwndList1 = WinCreateWindow(hWnd, "EntryFieldWindow", "Text Text Text",
  109.                    ES_MARGIN | ES_AUTOSCROLL | WS_VISIBLE,
  110.                    10L,    10L, 100L, 30L,    hWnd,
  111.                    HWND_TOP, 1024UL, (PVOID)NULL, (PVOID)NULL);
  112.  
  113.        hwndListA = WinCreateWindow(hWnd, WC_ENTRYFIELD,    "Text Text Text Text Text Text",
  114.                    ES_MARGIN | ES_AUTOSCROLL | WS_VISIBLE,
  115.                    115L, 10L, 150L, 25L, hWnd,
  116.                    HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL);
  117.        break;
  118.                /* Erase    background                */
  119.  
  120.    case    WM_ERASEBACKGROUND :
  121.        WinQueryWindowRect(hWnd,    &rcl);
  122.        WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND);
  123.        break;
  124.                /* Paint    the main client    window            */
  125.    case    WM_PAINT :
  126.        WinSetPointer(HWND_DESKTOP, hptrWait);
  127.  
  128.        WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL,    &rcl), &rcl, SYSCLR_DIALOGBACKGROUND);
  129.  
  130.        WinEndPaint(hPS);
  131.        WinSetPointer(HWND_DESKTOP, hptrArrow);
  132.        break;
  133.                /* Close    Down                    */
  134.    case    WM_CLOSE :
  135.  
  136.        WinPostMsg(hWnd,    WM_QUIT, 0L, 0L);
  137.        break;
  138.  
  139.    case    WM_DESTROY :
  140.        WinDestroyPointer(hptrArrow);
  141.        WinDestroyPointer(hptrWait);
  142.        break;
  143.                /* Default message processing            */
  144.    default:
  145.        return(WinDefWindowProc(hWnd, msg, mp1, mp2));
  146.    }
  147. return(0L);
  148. }
  149. #pragma    subtitle("   Program Controller")
  150. #pragma    page( )
  151.  
  152. /* --- Main Program Controller ----------------------------------------    */
  153.  
  154. INT main(INT argc, CHAR    *argv[ ])
  155.  
  156. {
  157. QMSG       qmsg;           /* PM Message Queue Holder        */
  158. ULONG       flCreateFlags;       /* Window Creation Flags        */
  159.  
  160. #ifdef INCL_VALAPI
  161.  
  162. HVAL hval;
  163.  
  164. hval = ValInitialize("Entry Field Driver", (PSZ)NULL, VL_VIEWPORT);
  165.  
  166. #endif
  167.                /* Initialize the program for PM    and create the    */
  168.                /* message queue                    */
  169.  
  170. WinSetCp(hmqDriver = WinCreateMsgQueue(hAB = WinInitialize(0), 0), 850);
  171.  
  172.                /* Register the main program window class    */
  173.  
  174. if ( !WinRegisterClass(hAB, pszDriverClassName,    (PFNWP)DriverWndProc,
  175.                CS_CLIPCHILDREN | CS_SYNCPAINT |    CS_SIZEREDRAW, 0) )
  176.    return(1);
  177.                /* Register the main program window class    */
  178.  
  179. if ( !fRegisterEntryField(hAB) )
  180.    return(1);
  181.                /* Create the main program window but do    not    */
  182.                /* show it yet                    */
  183.  
  184. flCreateFlags =    FCF_TITLEBAR | FCF_NOBYTEALIGN | FCF_SYSMENU | FCF_SIZEBORDER |    FCF_SHELLPOSITION;
  185. if ( !(hwndDriverFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,
  186.                           &flCreateFlags,
  187.                           pszDriverClassName, NULL,    0L,
  188.                          (HMODULE)0L, 0L,
  189.                           &hwndDriver)) )
  190.    {
  191.    return(1);
  192.    }
  193.                /* Retrieve and then dispatch messages        */
  194.  
  195. while (    WinGetMsg(hAB, &qmsg, (HWND)NULL, 0, 0)    )
  196.    WinDispatchMsg(hAB, &qmsg);
  197.  
  198. WinDestroyWindow(hwndDriverFrame);
  199.  
  200. WinDestroyMsgQueue(hmqDriver);
  201.  
  202.                /* Notify PM that main program thread not needed    */
  203.                /* any longer                    */
  204. WinTerminate(hAB);
  205.  
  206. #ifdef INCL_VALAPI
  207.  
  208. ValTerminate(hval);
  209.  
  210. #endif
  211.  
  212. return(0);
  213. }
  214.