home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cell06d.zip / samples / simple.c < prev    next >
C/C++ Source or Header  |  1999-01-24  |  4KB  |  212 lines

  1. /*
  2. ** Module   :SIMPLE.C
  3. ** Abstract :
  4. **
  5. ** Copyright (C) Sergey I. Yevtushenko
  6. ** Log: Sun  14/02/1998     Created
  7. **
  8. */
  9.  
  10. #define INCL_WIN
  11. #define INCL_NLS
  12. #define INCL_DOS
  13. #define INCL_GPI
  14.  
  15. #include <os2.h>
  16. #include <multibar.h>
  17. #include <cell.h>
  18. #include <string.h>
  19.  
  20. /* Local procedures */
  21.  
  22. MRESULT EXPENTRY MainClientProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  23.  
  24. /* Static Variables */
  25.  
  26. CellDef cdLeftPane =
  27. {
  28.     CELL_WINDOW,
  29.     WC_LISTBOX,
  30.     "List",
  31.     LS_NOADJUSTPOS | WS_VISIBLE,
  32.     ID_LIST
  33. };
  34.  
  35. CellDef cdRightPane =
  36. {
  37.     CELL_WINDOW,
  38.     WC_MLE,
  39.     "SampleText",
  40.     MLS_BORDER | WS_VISIBLE,
  41.     ID_MLE
  42. };
  43.  
  44. CellDef mainClient =
  45. {
  46.     CELL_VSPLIT | CELL_SPLITBAR | CELL_SPLIT30x70,
  47.     0,
  48.     "Simple",
  49.     FCF_TITLEBAR | FCF_SYSMENU  | FCF_MENU |
  50.     FCF_MINMAX   | FCF_TASKLIST | FCF_SIZEBORDER |
  51.     0,
  52.     MAIN_FRAME,
  53.     &cdLeftPane,
  54.     &cdRightPane,
  55.     0,
  56.     MainClientProc
  57. };
  58.  
  59. ULONG mainItems[]=
  60. {
  61.     IDB_FILENEW ,
  62.     IDB_FILEOPEN,
  63.     IDB_FILESAVE,
  64.     IDB_FILSAVAS,
  65.     TB_SEPARATOR,
  66.     IDB_EXIT    ,
  67.     TB_SEPARATOR,
  68.     IDB_EDITCOPY,
  69.     IDB_EDITCUT ,
  70.     IDB_EDITPAST,
  71.     IDB_EDITUNDO,
  72.     TB_SEPARATOR,
  73.     IDB_EDITFIND,
  74.     IDB_EDITFNNX,
  75.     IDB_EDITREPL,
  76.     TB_SEPARATOR,
  77.     IDB_HELP    ,
  78.     IDB_ABOUT   ,
  79.     0
  80. };
  81.  
  82. TbDef mainTb =
  83. {
  84.     TB_ATTACHED_TP | TB_BUBBLE,
  85.     ID_TOOLBAR,
  86.     mainItems
  87. };
  88.  
  89. MRESULT EXPENTRY MainClientProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  90. {
  91.     WindowCellCtlData *pWCtlData = 0;
  92.  
  93.     pWCtlData = (WindowCellCtlData *)WinQueryWindowULong(hwnd, QWL_USER);
  94.  
  95.     switch(msg)
  96.     {
  97.         case WM_COMMAND:
  98.             switch(SHORT1FROMMP(mp1))
  99.             {
  100.                 case IDB_EXIT:
  101.                     WinPostMsg(hwnd, WM_QUIT, 0L, 0L);
  102.                     return ((MRESULT) NULL);
  103.             }
  104.             break;
  105.  
  106.         case WM_CLOSE:
  107.             WinPostMsg(hwnd, WM_QUIT, 0L, 0L);
  108.             return ((MRESULT) NULL);
  109.     }
  110.     if(pWCtlData)
  111.         return pWCtlData->pOldProc(hwnd, msg, mp1, mp2);
  112.  
  113.     return WinDefWindowProc(hwnd, msg, mp1, mp2);
  114. }
  115.  
  116. INT main(VOID)
  117. {
  118.     HAB hab;
  119.     HMQ hmq;
  120.     QMSG qmsg;
  121.     HWND hwndFrame;
  122.     HWND hwndTb;
  123.     HWND hwndTmp;
  124.     LONG lColor = CLR_PALEGRAY;
  125.     SWP swp;
  126.  
  127.     hab = WinInitialize(0);
  128.  
  129.     if(!hab)
  130.     {
  131.         return -1;
  132.     }
  133.  
  134.     hmq = WinCreateMsgQueue(hab, 0);
  135.  
  136.     if(!hmq)
  137.     {
  138.         WinTerminate(hab);
  139.         return -2;
  140.     }
  141.  
  142.     ToolkitInit(hab);
  143.  
  144.     WinQueryWindowPos(HWND_DESKTOP, &swp);
  145.  
  146.     hwndFrame = CreateCell(&mainClient, HWND_DESKTOP, 0);
  147.     if(hwndFrame)
  148.     {
  149.         HWND hwndList;
  150.  
  151.         hwndList = CellWindowFromID(hwndFrame, ID_LPANE);
  152.  
  153.         if(hwndList)
  154.         {
  155.             CHAR cText[256];
  156.             static char cListItem[] = "List item ";
  157.             int i;
  158.  
  159.             strcpy(cText, cListItem);
  160.  
  161.             for(i = 0; i < 15; i++)
  162.             {
  163.                 GenResIDStr(cText + sizeof(cListItem) - 1, i);
  164.                 WinSendMsg(hwndList,
  165.                            LM_INSERTITEM,
  166.                            MPFROMSHORT(LIT_END),
  167.                            MPFROMP(cText));
  168.             }
  169.         }
  170.  
  171.         WinSetWindowPos(hwndFrame, NULLHANDLE,
  172.                         swp.x + swp.cx / 8,
  173.                         swp.y + swp.cy / 8,
  174.                         (swp.cx / 4) * 3,
  175.                         (swp.cy / 4) * 3,
  176.                         SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW);
  177.  
  178.  
  179.         CreateToolbar(hwndFrame, &mainTb);
  180.  
  181.         /* Set MLE color */
  182.  
  183.         hwndTmp = CellWindowFromID(hwndFrame, ID_MLE);
  184.  
  185.         WinSendMsg(hwndTmp,
  186.                    MLM_SETBACKCOLOR,
  187.                    MPFROMLONG(CLR_PALEGRAY),
  188.                    MPFROMLONG(MLE_INDEX));
  189.  
  190.         /* Set list color */
  191.  
  192.         hwndTmp = CellWindowFromID(hwndFrame, ID_LIST);
  193.  
  194.         WinSetPresParam(hwndTmp,
  195.                         PP_BACKGROUNDCOLORINDEX,
  196.                         sizeof(lColor),
  197.                         &lColor);
  198.  
  199.         while (WinGetMsg(hab, &qmsg, 0, 0, 0))
  200.             WinDispatchMsg(hab, &qmsg);
  201.  
  202.         WinDestroyWindow(hwndFrame);
  203.     }
  204.  
  205.     WinDestroyMsgQueue(hmq);
  206.     WinTerminate(hab);
  207.  
  208.     return 0;
  209. }
  210.  
  211.  
  212.