home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / tema / eroiica / EROICA16 / DDE_TEST.C_ / DDE_TEST.C
C/C++ Source or Header  |  1998-01-15  |  45KB  |  1,531 lines

  1. /*-------------------------- Parallax Standard C_File ----------------------------
  2.       C_File: dde_test.c
  3.       
  4.       Purpose: This file contains the source code for the main
  5.                window procedure for the Eroica unit test program.
  6.               
  7.       $nokeywords$
  8.  
  9. --------------------------------------------------------------------------------
  10.           Copyright (c)1996 Parallax Software , All rights reserved.            
  11. ------------------------------------------------------------------------------*/
  12.  
  13. #include "dde_test.h"
  14. #include "utdlg.h"
  15. #include "utdde.h"
  16. #include "testcase.h"
  17.  
  18. #include <memory.h>
  19. #include <string.h>
  20. #include <dos.h>
  21. #include <stdlib.h>
  22. #include <commdlg.h>
  23. #include <stdio.h>
  24. #include <math.h>
  25.  
  26. #ifdef _WIN32
  27. #include <time.h>
  28. #endif
  29.  
  30. /* global variables */
  31. HANDLE ghInst      = NULL;           /* handle to this instance      */
  32. HWND   ghWndMain   = NULL;           /* handle to main window        */
  33. HWND   ghListBox   = NULL;           /* handle to main's listbox     */
  34. HWND   ghListBox2  = NULL;           /* handle to main's 2nd listbox */
  35.  
  36. char   szMainMenu[]             = "MainMenu";
  37. char   szMainClass[]            = "Dde_TestClass";
  38. char   szStatusBarClass[]       = "IMG_StatusBarClass(PDM)";
  39. char   szStatusBarTextClass[]   = "IMG_StatusBarTextClass(PDM)";
  40.  
  41. DWORD  idInst = 0L;                  /* instance identifier */
  42. HSZ    ghszTopic, ghszItem;                                           
  43. HSZ    ghszServer;
  44. HSZ    hszServerBase = NULL;         /* Service name */
  45. HSZ    hszServerInst;
  46.  
  47. UINT   old_tool = 0;
  48. UINT   ribbon_width = 0;
  49. UINT   StatusBarSize;
  50.  
  51. /* local functions */
  52. void SaveAs(HWND hWnd, LPSTR RasterFormatList);
  53. void STS_Message(HWND hWnd, LPSTR msg);
  54.  
  55. static HCONV _dupatom_IMG_Connect(HWND hWnd, DWORD idInst, HSZ ghszServer, HSZ ghszTopic)
  56. {
  57.   /* need to create atoms that can be destroyed by the server */
  58.   char buf[256];
  59.   HSZ  srv, topic;
  60.  
  61.   if (DdeQueryString(idInst, ghszServer, buf, sizeof(buf), CP_WINANSI))
  62.   {
  63.     srv = DdeCreateStringHandle(idInst, buf, CP_WINANSI);
  64.  
  65.     if (DdeQueryString(idInst, ghszTopic, buf, sizeof(buf), CP_WINANSI))
  66.     {
  67.       topic = DdeCreateStringHandle(idInst, buf, CP_WINANSI);
  68.  
  69.       return (IMG_Connect(hWnd, idInst, srv, topic));
  70.     } /* if (DdeQueryString(idInst, ghszTopic, buf, sizeof(buf), CP_WINANSI)) */
  71.   } /* if (DdeQueryString(idInst, ghszServer, buf, sizeof(buf), CP_WINANSI)) */
  72.  
  73.   return(NULL);
  74. } /* _dupatom_IMG_Connect */
  75.  
  76. #define _DDE_CONNECT(ghConv)    ghConv = _dupatom_IMG_Connect( hWnd, idInst, ghszServer, ghszTopic )
  77. #define _DDE_DISCONNECT(ghConv) { DdeDisconnect(ghConv); ghConv=0; }
  78.  
  79. static   HCONV apiConv = NULL;
  80. static   HCONV hotspotActivationConv = NULL;
  81. static   HCONV hotspotPlacementConv = NULL;
  82. static   HCONV hotspotHighlightConv = NULL;
  83.  
  84. #define MID_SIZE        4
  85. #define HALF_MID_SIZE   2
  86.  
  87. double  ratio = 0.6;         /* Percentage of screen real estate to give to 1st listbox */
  88.  
  89.  
  90. /* 970224 jk add to cover missing function in WIN32 API */
  91. #ifdef _WIN32
  92. static POINT MoveTo(HDC hDC, int x, int y)
  93. {
  94.   POINT oldpos ;
  95.   MoveToEx(hDC, x, y, &oldpos) ;
  96.   return oldpos ;
  97. }
  98. #endif
  99. /* 970224 jk end */
  100.  
  101.  
  102. /* ========================================= Parallax C Function ==================
  103.  
  104.    @Name: MainWndProc
  105.    @Desc:
  106.  
  107. ============================================================================== */
  108.  
  109. long FAR PASCAL MainWndProc(HWND hWnd, unsigned msg, WORD wParam, LONG lParam)
  110. {
  111.   static FARPROC    lpProc;
  112.   RECT              ClientRect;
  113.   RECT              *lpClientRect = &ClientRect;
  114.   RECT              Rect;
  115.   RECT              *lpRect = &Rect;
  116.   static            FARPROC  lpfnDdeCallBack;
  117.   int               xpos;
  118.   int               ypos;
  119.   int               xsize;
  120.   int               prevxsize;
  121.   int               ysize;
  122.   int               y_size;
  123.   HDC               hDC;
  124.   TEXTMETRIC        tm;
  125.   TEXTMETRIC FAR    *lptm = &tm;
  126.   HWND              hWndStatus = NULL;
  127.   HFONT             hFont;
  128.   HFONT             hFontOld = (HFONT)0;
  129.   char              szTmp[132];
  130.   char              szBuffer[1024];
  131.   WORD              fwMenu;
  132.   static POINT      pt;
  133.   static int        capture = FALSE;
  134.  
  135.   switch (msg)
  136.   {
  137.  
  138.     case WM_CREATE:
  139.     {
  140.       /* Ddeml initialization */
  141.       lpfnDdeCallBack = MakeProcInstance((FARPROC)DdeCallBack, ghInst);
  142.  
  143.       if (DdeInitialize(&idInst, (PFNCALLBACK)lpfnDdeCallBack, APPCMD_CLIENTONLY, 0L))
  144.       {
  145.         return FALSE;
  146.       } /* if (DdeInitialize(&idInst, (PFNCALLBACK)lpfnDdeCallBack, APPCMD_CLIENTONLY, 0L)) */
  147.  
  148.       /* Topic Name.... */
  149.       ghszTopic = DdeCreateStringHandle(idInst, (LPSTR)"imaging", CP_WINANSI);
  150.  
  151.       /* Server Name..... */
  152.       ghszServer = DdeCreateStringHandle(idInst, (LPSTR)"Eroica", CP_WINANSI);
  153.  
  154.       GetClientRect(hWnd, lpClientRect);
  155.       xsize = lpClientRect->right - lpClientRect->left;
  156.       hDC = GetDC(hWnd);
  157.       GetTextMetrics(hDC,  lptm);
  158.       StatusBarSize = ysize = lptm->tmHeight * 2;
  159.       ReleaseDC(hWnd, hDC);
  160.       xpos = 0;
  161.       ypos = lpClientRect->bottom - ysize;
  162.       hWndStatus = CreateWindow(szStatusBarClass,
  163.                                 NULL,
  164.                                 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | WS_BORDER,
  165.                                 xpos,
  166.                                 ypos,
  167.                                 xsize,
  168.                                 ysize,
  169.                                 hWnd, NULL, ghInst, NULL);
  170.       if (hWndStatus)
  171.       {
  172.         SetProp(hWnd, "Status Window Handle", hWndStatus);
  173.         ShowWindow(hWndStatus, SW_SHOW);
  174.         GetClientRect(hWndStatus, lpClientRect);
  175.         InvalidateRect(hWndStatus, lpClientRect, TRUE);
  176.         UpdateWindow(hWndStatus);
  177.  
  178.         GetClientRect(hWnd, lpClientRect);
  179.         xsize = lpClientRect->right - lpClientRect->left;
  180.  
  181.         hDC = GetDC(hWnd);
  182.         GetTextMetrics(hDC,  lptm);
  183.         ysize = lptm->tmHeight * 2;
  184.         ReleaseDC(hWnd, hDC);
  185.  
  186.       } else /* if (hWndStatus) */
  187.       {
  188.         MessageBox(ghWndMain, "Unable to Create Window", "Error", MB_OK);
  189.       } /* fi (hWndStatus)) */
  190.  
  191.       GetClientRect(hWnd, lpRect);
  192.  
  193.       break; 
  194.     } /* case WM_CREATE */
  195.  
  196.     case WM_MOUSEMOVE:
  197.     {
  198.       SetCursor(LoadCursor(NULL, IDC_SIZEWE));
  199.       if (wParam & MK_LBUTTON)
  200.       {
  201.         HDC     hDC;
  202.         RECT    rect;
  203.         HPEN    hPen;
  204.         HPEN    hOldPen;
  205.         int     oRop;
  206.  
  207.         if (capture == TRUE)
  208.         {
  209.           hDC = GetDC(hWnd);
  210.           if (hDC)
  211.           {
  212.             SetCapture(hWnd);
  213.             GetClientRect(hWnd, &rect);
  214.             hPen = CreatePen(PS_SOLID, 1, RGB(127, 127, 127));
  215.             hOldPen = SelectObject(hDC, hPen);
  216.             oRop = SetROP2(hDC, R2_NOTXORPEN);
  217.             MoveTo(hDC, pt.x, ribbon_width);
  218.             LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
  219.             pt.x = LOWORD(lParam);
  220.             pt.y = HIWORD(lParam);
  221.             MoveTo(hDC, pt.x, ribbon_width);
  222.             LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
  223.             SelectObject(hDC, hOldPen);
  224.             DeleteObject(hPen);
  225.             SetROP2(hDC, oRop);
  226.             ReleaseDC(hWnd, hDC);
  227.           } /* if (hDC)) */
  228.         } /* if (capture == TRUE)) */
  229.       } /* if (wParam & MK_LBUTTON)) */
  230.  
  231.       break;
  232.     } /* case  WM_MOUSEMOVE */
  233.  
  234.     case WM_LBUTTONUP:
  235.     {
  236.       RECT    rect;
  237.       int     range;
  238.       HDC     hDC;
  239.       HPEN    hPen;
  240.       HPEN    hOldPen;
  241.       int     oRop;
  242.  
  243.       if (capture == TRUE)
  244.       {
  245.         pt.x = LOWORD(lParam);
  246.         pt.y = HIWORD(lParam);
  247.         GetClientRect(hWnd, &rect);
  248.  
  249.         range = rect.right - rect.left + 1;
  250.         ratio = (double)pt.x / (double)range;
  251.  
  252.         if (ratio > 0.95) ratio = 0.95;
  253.  
  254.         if (ratio < 0.05) ratio = 0.05;
  255.  
  256.         ReleaseCapture();
  257.         capture = FALSE;
  258.  
  259.         hDC = GetDC(hWnd);
  260.         if (hDC)
  261.         {
  262.           hPen = CreatePen(PS_SOLID, 1, RGB(127, 127, 127));
  263.           hOldPen = SelectObject(hDC, hPen);
  264.           oRop = SetROP2(hDC, R2_NOTXORPEN);
  265.           MoveTo(hDC, pt.x, ribbon_width);
  266.           LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
  267.           pt.x = 0;
  268.           pt.y = 0;
  269.           SelectObject(hDC, hOldPen);
  270.           DeleteObject(hPen);
  271.           SetROP2(hDC, oRop);
  272.           ReleaseDC(hWnd, hDC);
  273.         } /* fi (hDC)) */
  274.  
  275.         GetWindowRect(hWnd, &rect);
  276.         SendMessage(hWnd, WM_SIZE, SIZE_RESTORED, MAKELONG(rect.right - rect.left, rect.bottom - rect.top));
  277.       } /* if (capture == TRUE)) */
  278.  
  279.       break;
  280.     } /* case WM_LBUTTONUP */
  281.  
  282.     case WM_LBUTTONDOWN:
  283.     {
  284.       HDC     hDC;
  285.       RECT    rect;
  286.       HPEN    hPen;
  287.       HPEN    hOldPen;
  288.       int     oRop;
  289.  
  290.       hDC = GetDC(hWnd);
  291.       if (hDC)
  292.       {
  293.         SetCapture(hWnd);
  294.         GetClientRect(hWnd, &rect);
  295.         pt.x = LOWORD(lParam);
  296.         pt.y = HIWORD(lParam);
  297.         hPen = CreatePen(PS_SOLID, 1, RGB(127, 127, 127));
  298.         hOldPen = SelectObject(hDC, hPen);
  299.         oRop = SetROP2(hDC, R2_NOTXORPEN);
  300.         MoveTo(hDC, pt.x, ribbon_width);
  301.         LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
  302.         SelectObject(hDC, hOldPen);
  303.         DeleteObject(hPen);
  304.         SetROP2(hDC, oRop);
  305.         ReleaseDC(hWnd, hDC);
  306.         capture = TRUE;
  307.       } /* if (hDC)) */
  308.  
  309.       break;
  310.     } /* case WM_LBUTTONDOWN */
  311.  
  312.     case WM_MENUSELECT:
  313.     {
  314.       fwMenu = LOWORD(lParam);
  315.  
  316.       if (fwMenu & MF_POPUP)
  317.       {
  318.         ;
  319.       } else /* if (fwMenu & MF_POPUP)) */
  320.       {
  321.         if (LoadString(ghInst, wParam, (LPSTR)szBuffer, sizeof(szBuffer)))
  322.         {
  323.           STS_Message(ghWndMain, (LPSTR)szBuffer);
  324.         } /* LoadString(ghInst, wParam, (LPSTR)szBuffer, sizeof(szBuffer)) */
  325.       } /* if (fwMenu & MF_POPUP)) */
  326.  
  327.       break;
  328.     } /* case WM_MENUSELECT */
  329.  
  330.     case WM_COMMAND:
  331.     {
  332.       HCONV ghConv;
  333.  
  334.       /* try to serve not-DDE commands first */
  335.       switch (wParam)
  336.       {
  337.         case IDM_ABOUT: /* show about box */
  338.         {
  339.           lpProc = MakeProcInstance((int (pascal far*)())About, ghInst);
  340. #ifdef __TURBOC__
  341.           DialogBox(ghInst, "BorAbout", hWnd, lpProc);
  342. #else
  343.           DialogBox(ghInst, "About", hWnd, lpProc);
  344. #endif
  345.           FreeProcInstance(lpProc);
  346.           return( 0 );
  347.         } /* case IDM_ABOUT */
  348.  
  349.         case IDM_CLEAR: /* clear text box */
  350.         {
  351.           SendMessage(ghListBox, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
  352.           SendMessage(ghListBox2, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
  353.           return( 0 );
  354.         } /* case IDM_CLEAR */
  355.  
  356.         case IDM_EXIT:
  357.         {
  358.           PostMessage(hWnd, WM_CLOSE, 0, 0L);
  359.           return( 0 );
  360.          } /* case IDM_EXIT */
  361.       }
  362.  
  363.       /* if not served they are DDE, try to open communication */
  364.       _DDE_CONNECT(ghConv);
  365.       if ( !ghConv )
  366.           return( 0 );
  367.       
  368.       /* we can communicate, process command */
  369.       switch (wParam)
  370.       {
  371.         case IDM_STARTUP:
  372.         {
  373.           IMG_StartUp(ghConv);
  374.           break;
  375.         } /* case IDM_STARTUP */
  376.  
  377.         case IDM_MERGE:
  378.         {
  379.           IMG_Merge(ghConv, 0, MERGE_WHOLEDOC, NULL);
  380.           break;
  381.         } /* case IDM_MERGE */
  382.  
  383.         case IDM_CROP700:
  384.         {
  385.           IMG_SetShowStatusDialogs(ghConv, 0);
  386.           IMG_Crop(ghConv, 0, 50, 100, 750, 800);
  387.           break;
  388.         } /* case IDM_CROP700 */
  389.  
  390.         case IDM_DESKEW1:
  391.         {
  392.           IMG_SetShowStatusDialogs(ghConv, 0);
  393.           IMG_Deskew(ghConv, 0, (float)1.0);
  394.           break;
  395.         } /* case IDM_DESKEW1 */
  396.  
  397.         case IDM_DESPECKLE30:
  398.         {
  399.           IMG_Despeckle(ghConv, 0, 30);
  400.           break;
  401.         } /* case IDM_DESPECKLE30 */
  402.  
  403.         case IDM_DPITO200x100:
  404.         {
  405.           IMG_RasterDPIChange(ghConv, 200, 100);
  406.           break;
  407.         } /* case IDM_DPITO200x100 */
  408.  
  409.         case IDM_API_NOTIFY:
  410.         {
  411.           if (!apiConv)
  412.           {
  413.             _DDE_CONNECT(apiConv);
  414.             IMG_NotifyApi(apiConv);
  415.           } /* if (!apiConv)) */
  416.           break;
  417.         } /* case IDM_API_NOTIFY */
  418.  
  419.         case IDM_API_UNNOTIFY:
  420.         {
  421.           if (apiConv)
  422.           {
  423.             IMG_NotifyApiStop(apiConv);
  424.             _DDE_DISCONNECT(apiConv);
  425.           } /* if (apiConv)) */
  426.           break;
  427.         } /* case IDM_API_UNNOTIFY */
  428.  
  429.         case IDM_HOTSPOT_NOTIFY:
  430.         {
  431.           if (!hotspotActivationConv)
  432.           {
  433.             _DDE_CONNECT(hotspotActivationConv);
  434.             IMG_NotifyHotSpot(hotspotActivationConv);
  435.           } /* if (!hotspotActivationConv)) */
  436.           break;
  437.         } /* case IDM_HOTSPOT_NOTIFY */
  438.  
  439.         case IDM_HOTSPOT_UNNOTIFY:
  440.         {
  441.           if (hotspotActivationConv)
  442.           {
  443.             IMG_NotifyHotSpotStop(hotspotActivationConv);
  444.             _DDE_DISCONNECT(hotspotActivationConv);
  445.           } /* if (hotspotActivationConv)) */
  446.           break;
  447.         } /* case IDM_HOTSPOT_UNNOTIFY */
  448.  
  449.         case IDM_HOTSPOT_NOTIFY_PLACEMENT:
  450.         {
  451.           if (!hotspotPlacementConv)
  452.           {
  453.             _DDE_CONNECT(hotspotPlacementConv);
  454.             IMG_NotifyHotSpotPlaced(hotspotPlacementConv);
  455.           } /* if (!hotspotPlacementConv)) */
  456.           break;
  457.         } /* case IDM_HOTSPOT_NOTIFY_PLACEMENT */
  458.  
  459.         case IDM_HOTSPOT_UNNOTIFY_PLACEMENT:
  460.         {
  461.           if (hotspotPlacementConv)
  462.           {
  463.             IMG_NotifyHotSpotPlacedStop(hotspotPlacementConv);
  464.             _DDE_DISCONNECT(hotspotPlacementConv);
  465.           } /* if (hotspotPlacementConv)) */
  466.           break;
  467.         } /* case IDM_HOTSPOT_UNNOTIFY_PLACEMENT */
  468.  
  469.         case IDM_HOTSPOT_NOTIFY_HIGHLIGHT:
  470.         {
  471.           if (!hotspotHighlightConv)
  472.           {
  473.             _DDE_CONNECT(hotspotHighlightConv);
  474.             IMG_NotifyHotSpotHighlighted(hotspotHighlightConv);
  475.           } /* if (!hotspotPlacementConv)) */
  476.           break;
  477.         } /* case IDM_HOTSPOT_NOTIFY_HIGHLIGHT */
  478.  
  479.         case IDM_HOTSPOT_UNNOTIFY_HIGHLIGHT:
  480.         {
  481.             if (hotspotHighlightConv)
  482.             {
  483.               IMG_NotifyHotSpotHighlightedStop(hotspotHighlightConv);
  484.               _DDE_DISCONNECT(hotspotHighlightConv);
  485.             } /* if (hotspotPlacementConv)) */
  486.           break;
  487.         } /* case IDM_HOTSPOT_UNNOTIFY_HIGHLIGHT */
  488.  
  489.         case IDM_TESTDESKEW:
  490.         {
  491.           UT_TestDeskew(ghConv);
  492.           break;
  493.         } /* case IDM_TESTDESKEW */
  494.  
  495.         case IDM_TESTLOAD:
  496.         {
  497.           UT_TestLoad(ghConv);
  498.           break;
  499.         } /* TESTLOAD */
  500.  
  501.         case IDM_TESTSAVE:
  502.         {
  503.           UT_TestSave(ghConv);
  504.           break;
  505.         } /* TESTSAVE */
  506.  
  507.         case IDM_TESTMERGE:
  508.         {
  509.           UT_TestMerge(ghConv);
  510.           break;
  511.         } /* TESTMERGE */
  512.  
  513.         case IDM_TESTDISPLAYLAYER:
  514.         {
  515.           UT_TestDisplayLayer(ghConv);
  516.           break;
  517.         } /* case IDM_TESTDISPLAYLAYER */
  518.  
  519.         case IDM_TESTTOOLSET:
  520.         {
  521.           UT_TestToolSet(ghConv);
  522.           break;
  523.         } /* case IDM_TESTTOOLSET */
  524.  
  525.         case IDM_ARRANGETILE:
  526.         {
  527.           IMG_ArrangeDocWins(ghConv, ARRANGE_TILE);
  528.           break;
  529.         } /* case IDM_ARRANGETILE */
  530.  
  531.         case IDM_ARRANGECASCADE:
  532.         {
  533.           IMG_ArrangeDocWins(ghConv, ARRANGE_CASCADE);
  534.           break;
  535.         } /* case IDM_ARRANGECASCADE */
  536.  
  537.         case IDM_ARRANGEHSTRIP:
  538.         {
  539.           IMG_ArrangeDocWins(ghConv, ARRANGE_HORZSTRIP);
  540.           break;
  541.         } /* case IDM_ARRANGEHSTRIP */
  542.  
  543.         case IDM_ARRANGEVSTRIP:
  544.         {
  545.           IMG_ArrangeDocWins(ghConv, ARRANGE_VERTSTRIP);
  546.           break;
  547.         } /* case IDM_ARRANGEVSTRIP */
  548.  
  549.         case IDM_GETNUMBERDOCWINS:
  550.         {
  551.           IMG_GetNumberDocWins(ghConv, NULL);
  552.           break;
  553.         } /* case IDM_GETNUMBERDOCWINS */
  554.  
  555.         case IDM_GETNUMBERLAYERS:
  556.         {
  557.           IMG_GetNumberLayers(ghConv, 0, NULL);
  558.           break;
  559.         } /* case IDM_GETNUMBERLAYERS */
  560.  
  561.         case IDM_GETCURRENTDOCWIN:
  562.         {
  563.           IMG_GetDocWin(ghConv, NULL);
  564.           break;
  565.         } /* case IDM_GETCURRENTDOCWIN */
  566.  
  567.         case IDM_PRINTDOCWIN:
  568.         {
  569.           IMG_PrintDocWin(ghConv, 0, 3, 0, 0, 1, 0);
  570.           break;
  571.         } /* case IDM_PRINTDOCWIN */
  572.  
  573.         case IDM_GETACTIVERASTER:
  574.         {
  575.           IMG_GetActiveRasterLayer(ghConv, 0, NULL);
  576.           break;
  577.         } /* case IDM_GETACTIVERASTER */
  578.  
  579.         case IDM_GETACTIVEEDIT:
  580.         {
  581.           IMG_GetActiveEditLayer(ghConv, 0, NULL);
  582.           break;
  583.         } /* case IDM_GETACTIVEEDIT */
  584.  
  585.         case IDM_GETDOCDIRTYSTATUS:
  586.         {
  587.           IMG_GetDocumentDirtyStatus(ghConv, 0, NULL);
  588.           break;
  589.         } /* case IDM_GETDOCDIRTYSTATUS */
  590.  
  591.         case IDM_GETLAYERDIRTYSTATUS:
  592.         {
  593.           int     i,count;
  594.           LAYERID list[20];
  595.  
  596.           if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
  597.           {
  598.             if (count==0)
  599.             {
  600.               _MSG("**No layers in active document.");
  601.             } else /* fi (count == 0)) */
  602.             {
  603.               for (i=0; i<count; i++)
  604.               {
  605.                 IMG_GetLayerDirtyStatus(ghConv, 0, list[i], NULL);
  606.               } /* for (i = 0; i < count; i++)) */
  607.             } /* if (count == 0)) */
  608.           } /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
  609.           break;
  610.         } /* case IDM_GETLAYERDIRTYSTATUS */
  611.  
  612.         case IDM_GETLAYERDISPLAYSTATUS:
  613.         {
  614.           int     i,count;
  615.           LAYERID list[20];
  616.  
  617.           if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
  618.           {
  619.             if (count==0)
  620.             {
  621.               _MSG("**No layers in active document.");
  622.             } else /* if (count == 0)) */
  623.             {
  624.               for (i=0; i<count; i++)
  625.               {
  626.                 IMG_GetDisplayLayer(ghConv, 0, list[i], NULL);
  627.               } /* for (i = 0; i < count; i++)) */
  628.             } /* if (count == 0)) */
  629.           } /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
  630.           break;
  631.         } /* case IDM_GETLAYERDISPLAYSTATUS */
  632.  
  633.         case IDM_GETLAYERFORMATS:
  634.         {
  635.           int     i,count;
  636.           LAYERID list[20];
  637.  
  638.           if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
  639.           {
  640.             if (count==0)
  641.             {
  642.               _MSG("**No layers in active document.");
  643.             } else /* if (count == 0)) */
  644.             {
  645.               for (i=0; i<count; i++)
  646.               {
  647.                 IMG_GetLayerFormat(ghConv, 0, list[i], NULL);
  648.               } /* for (i = 0; i < count; i++)) */
  649.             } /* if (count == 0)) */
  650.           } /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
  651.           break;
  652.         } /* case IDM_GETLAYERFORMATS */
  653.  
  654.         case IDM_GETLAYERFORMATLIST:
  655.         {
  656.           IMG_GetLayerFormatList(ghConv);
  657.           break;
  658.         } /* GETLAYERFORMATLIST */
  659.  
  660.         case IDM_GETLAYERIDS:
  661.         {
  662.           int     i,count;
  663.           LAYERID list[20];
  664.  
  665.           if (IMG_GetLayerIDs(ghConv, 0, list, 20, &count))
  666.           {
  667.             if (count==0)
  668.             {
  669.               _MSG("**No layers in active document.");
  670.             } else /* if (count == 0)) */
  671.             {
  672.               _MSG("Layer IDs in active document.");
  673.                
  674.               for (i=0; i<count; i++)
  675.               {
  676.                 _FMTMSG2("   Position %d --> layerID %d.", i+1, list[i]);
  677.               } /* for (i = 0; i < count; i++)) */
  678.             } /* if (count == 0)) */
  679.           } /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, &count)) */
  680.           break;
  681.         } /* case IDM_GETLAYERIDS */
  682.  
  683.         case IDM_GETWINDOWTITLE:
  684.         {
  685.           char title[80];
  686.           
  687.           IMG_GetWindowTitle(ghConv, 0, (LPSTR)title);
  688.           break;
  689.         } /* case IDM_GETWINDOWTITLE */
  690.  
  691.         case IDM_GETDOCTITLE:
  692.         {
  693.           char title[80];
  694.           
  695.           IMG_GetDocumentTitle(ghConv, 0, (LPSTR)title);
  696.           break;
  697.         } /* case IDM_GETDOCTITLE */
  698.  
  699.         case IDM_GETLAYERTITLES:
  700.         {
  701.           int     i,count;
  702.           LAYERID list[20];
  703.  
  704.           if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
  705.           {
  706.             if (count==0)
  707.             {
  708.               _MSG("**No layers in active document.");
  709.             } else /* if (count == 0)) */
  710.             {
  711.               for (i=0; i<count; i++)
  712.               {
  713.                 IMG_GetLayerTitle(ghConv, 0, list[i], szTmp);
  714.               } /* for (i = 0; i < count; i++)) */
  715.             } /* if (count == 0)) */
  716.           } /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
  717.           break;
  718.         } /* case IDM_GETLAYERTITLES */
  719.  
  720.         case IDM_CLOSEALLDOCWIN:
  721.         {
  722.           IMG_CloseAllDocWin(ghConv, FALSE);
  723.           break;
  724.         } /* case IDM_CLOSEALLDOCWIN */
  725.  
  726.         case IDM_CLOSEDOCWIN:
  727.         {
  728.           IMG_CloseDocWin(ghConv, 0, FALSE);
  729.           break;
  730.         } /* case IDM_CLOSEDOCWIN */
  731.  
  732.         case IDM_ENDFRAME:
  733.         {
  734.           IMG_EndEroica(ghConv);
  735.           break;
  736.         } /* case IDM_ENDFRAME */
  737.  
  738.         case IDM_TERMINATE:
  739.         {
  740.           IMG_Terminate(ghConv);
  741.           break;
  742.         } /* case IDM_TERMINATE */
  743.  
  744.         case IDM_REFRESH:
  745.         {
  746.           IMG_Refresh(ghConv, 0);
  747.           break;
  748.         } /* case IDM_REFRESH */
  749.  
  750.         case IDM_NEXTDOCWIN:
  751.         {
  752.           DOCWINID docWinID;
  753.           
  754.           IMG_SetDocWin(ghConv, 0, TRUE, &docWinID);
  755.           break;
  756.         } /* case IDM_NEXTDOCWIN */
  757.  
  758.         case IDM_FOCUSONFRAME:
  759.         {
  760.           IMG_SetFocus(ghConv);
  761.           break;
  762.         } /* case IDM_FOCUSFRAME */
  763.  
  764.         case IDM_ZOOMIN:
  765.         {
  766.           IMG_SetZoom(ghConv, 0, ZOOM_IN, 0, 0, 0);
  767.           break;
  768.         } /* case IDM_ZOOMIN */
  769.  
  770.         case IDM_ZOOMOUT:
  771.         {
  772.           IMG_SetZoom(ghConv, 0, ZOOM_OUT, 0, 0, 0);
  773.           break;
  774.         } /* case IDM_ZOOMOUT */
  775.  
  776.         case IDM_ZOOMFIT:
  777.         {
  778.           IMG_SetZoom(ghConv, 0, ZOOM_FIT, 0, 0, 0);
  779.           break;
  780.         } /* case IDM_ZOOMFIT */
  781.  
  782.         case IDM_ZOOMVFIT:
  783.         {
  784.           IMG_SetZoom(ghConv, 0, ZOOM_VFIT, 0, 0, 0);
  785.           break;
  786.         } /* case IDM_ZOOMVFIT */
  787.  
  788.         case IDM_ZOOMHFIT:
  789.         {
  790.           IMG_SetZoom(ghConv, 0, ZOOM_HFIT, 0, 0, 0);
  791.           break;
  792.         } /* case IDM_ZOOMHFIT */
  793.  
  794.         case IDM_ZOOMACTUAL:
  795.         {
  796.           IMG_SetZoom(ghConv, 0, ZOOM_ACTUAL, 0, 0, 0);
  797.           break;
  798.         } /* case IDM_ZOOMACTUAL */
  799.  
  800.         case IDM_ZOOMONETOONE:
  801.         {
  802.           IMG_SetZoom(ghConv, 0, ZOOM_1TO1, 0, 0, 0);
  803.           break;
  804.         } /* case IDM_ZOOMTOONE */
  805.  
  806.         case IDM_SHOWMIN:
  807.         {
  808.           IMG_ShowDocWin(ghConv, 0, SHOW_MINIMIZE);
  809.           break;
  810.         } /* case IDM_SHOWMIN */
  811.  
  812.         case IDM_SHOWMAX:
  813.         {
  814.           IMG_ShowDocWin(ghConv, 0, SHOW_MAXIMIZE);
  815.           break;
  816.         } /* case IDM_SHOWMAX */
  817.  
  818.         case IDM_SHOWRESTORE:
  819.         {
  820.           IMG_ShowDocWin(ghConv, 0, SHOW_RESTORE);
  821.           break;
  822.         } /* case IDM_SHOWRESTORE */
  823.  
  824.         case IDM_SHOWHIDE:
  825.         {
  826.           IMG_ShowDocWin(ghConv, 0, SHOW_HIDE);
  827.           break;
  828.         } /* case IDM_SHOWHIDE */
  829.  
  830.         case IDM_SHOWUNHIDE:
  831.         {
  832.           IMG_ShowDocWin(ghConv, 0, SHOW_UNHIDE);
  833.           break;
  834.         } /* case IDM_SHOWUNHIDE */
  835.  
  836.         case IDM_SETTOOL_NONE:
  837.         {
  838.           IMG_SetTool(ghConv, 0, TOOL_NONE);
  839.           break;
  840.         } /* case IDM_SETTOOL_NONE */
  841.  
  842.         case IDM_SETTOOL_CUT:
  843.         {
  844.           IMG_SetTool(ghConv, 0, TOOL_CUT);
  845.           break;
  846.         } /* case IDM_SETTOOL_CUT */
  847.  
  848.         case IDM_SETTOOL_COPY:
  849.         {
  850.           IMG_SetTool(ghConv, 0, TOOL_COPY);
  851.           break;
  852.         } /* case IDM_SETTOOL_COPY */
  853.  
  854.         case IDM_SETTOOL_PASTE:
  855.         {
  856.           IMG_SetTool(ghConv, 0, TOOL_PASTE);
  857.           break;
  858.         } /* case IDM_SETTOOL_PASTE */
  859.  
  860.         case IDM_SETTOOL_LINE:
  861.         {
  862.           IMG_SetTool(ghConv, 0, TOOL_LINE);
  863.           break;
  864.         } /* case IDM_SETTOOL_LINE */
  865.  
  866.         case IDM_SETTOOL_BOX:
  867.         {
  868.           IMG_SetTool(ghConv, 0, TOOL_BOX);
  869.           break;
  870.         } /* case IDM_SETTOOL_BOX */
  871.  
  872.         case IDM_SETTOOL_CIRCLE:
  873.         {
  874.           IMG_SetTool(ghConv, 0, TOOL_CIRCLE);
  875.           break;
  876.         } /* case IDM_SETTOOL_CIRCLE */
  877.  
  878.         case IDM_SETTOOL_ELLIPSE:
  879.         {
  880.           IMG_SetTool(ghConv, 0, TOOL_ELLIPSE);
  881.           break;
  882.         } /* case IDM_SETTOOL_ELLIPSE */
  883.  
  884.         case IDM_SETTOOL_ARROW:
  885.         {
  886.           IMG_SetTool(ghConv, 0, TOOL_ARROW);
  887.           break;
  888.         } /* case IDM_SETTOOL_ARROW */
  889.  
  890.         case IDM_SETTOOL_SKETCH:
  891.         {
  892.           IMG_SetTool(ghConv, 0, TOOL_SKETCH);
  893.           break;
  894.         } /* case IDM_SETTOOL_SKETCH */
  895.  
  896.         case IDM_SETTOOL_POLYLINE:
  897.         {
  898.           IMG_SetTool(ghConv, 0, TOOL_POLYLINE);
  899.           break;
  900.         } /* case IDM_SETTOOL_POLYLINE */
  901.  
  902.         case IDM_SETTOOL_POLYGON:
  903.         {
  904.           IMG_SetTool(ghConv, 0, TOOL_POLYGON);
  905.           break;
  906.         } /* case IDM_SETTOOL_POLYGON */
  907.  
  908.         case IDM_SETTOOL_TEXT:
  909.         {
  910.           IMG_SetTool(ghConv, 0, TOOL_TEXT);
  911.           break;
  912.         } /* case IDM_SETTOOL_TEXT */
  913.  
  914.         case IDM_SETTOOL_ANNOTATION:
  915.         {
  916.           IMG_SetTool(ghConv, 0, TOOL_ANNOTATION);
  917.           break;
  918.         } /* case IDM_SETTOOL_ANNOTATION */
  919.  
  920.         case IDM_SETTOOL_DIMENSION:
  921.         {
  922.           IMG_SetTool(ghConv, 0, TOOL_DIMENSION);
  923.           break;
  924.         } /* case IDM_SETTOOL_DIMENSION */
  925.  
  926.         case IDM_SETTOOL_SYMBOL:
  927.         {
  928.           IMG_SetTool(ghConv, 0, TOOL_SYMBOL);
  929.           break;
  930.         } /* case IDM_SETTOOL_SYMBOL */
  931.  
  932.         case IDM_SETTOOL_HOTSPOT:
  933.         {
  934.           IMG_SetTool(ghConv, 0, TOOL_HOTSPOT);
  935.           break;
  936.         } /* case IDM_SETTOOL_HOTSPOT */
  937.  
  938.         case IDM_SETTOOL_RUBOUT:
  939.         {
  940.           IMG_SetTool(ghConv, 0, TOOL_RUBOUT);
  941.           break;
  942.         } /* case IDM_SETTOOL_RUBOUT */
  943.  
  944.         case IDM_SETTOOL_ERASER:
  945.         {
  946.           IMG_SetTool(ghConv, 0, TOOL_ERASER);
  947.           break;
  948.         } /* case IDM_SETTOOL_ERASER */
  949.  
  950.         case IDM_SETTOOL_SELECT:
  951.         {
  952.           IMG_SetTool(ghConv, 0, TOOL_SELECT);
  953.           break;
  954.         } /* case IDM_SETTOOL_SELECT */
  955.  
  956.         case IDM_SETTOOL_MOVERESIZE:
  957.         {
  958.           IMG_SetTool(ghConv, 0, TOOL_MOVERESIZE);
  959.           break;
  960.         } /* case IDM_SETTOOL_MOVERESIZE */
  961.  
  962.         case IDM_SETTOOL_ROTATE:
  963.         {
  964.           IMG_SetTool(ghConv, 0, TOOL_ROTATE);
  965.           break;
  966.         } /* case IDM_SETTOOL_ROTATE */
  967.  
  968.         case IDM_SETTOOL_CHANGETEXT:
  969.         {
  970.           IMG_SetTool(ghConv, 0, TOOL_CHANGETEXT);
  971.           break;
  972.         } /* case IDM_SETTOOL_CHANGETEXT */
  973.  
  974.         case IDM_SETTOOL_ARC:
  975.         {
  976.           IMG_SetTool(ghConv, 0, TOOL_ARC);
  977.           break;
  978.         } /* case IDM_SETTOOL_ARC */
  979.  
  980.         case IDM_GETTOOL:
  981.         {
  982.           IMG_GetTool(ghConv, 0, NULL);
  983.           break;
  984.         } /* case IDM_GETTOL */
  985.  
  986.  
  987.       } /* switch (wparam) */
  988.       _DDE_DISCONNECT(ghConv);
  989.  
  990.     } /* case WM_COMMAND */
  991.  
  992.     case WM_SIZE:
  993.     {
  994.       hWndStatus = GetProp(hWnd, "Status Window Handle");
  995.       if (hWndStatus)
  996.       {
  997.         GetClientRect(hWnd, lpClientRect);
  998.         xsize = lpClientRect->right - lpClientRect->left;
  999.         hDC = GetDC(hWndStatus);
  1000.  
  1001.         GetTextMetrics(hDC,  lptm);
  1002.         hFont = CreateFont(( lptm->tmHeight * 9 / 10 ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  1003.         if (hFont)
  1004.         {
  1005.           hFontOld = SelectObject(hDC, hFont);
  1006.         } /* if (hFont) */
  1007.  
  1008.         GetTextMetrics(hDC,  lptm);
  1009.  
  1010.         if (hFont)
  1011.         {
  1012.           SelectObject(hDC, hFontOld);
  1013.           DeleteObject(hFont);
  1014.         } /* if (hFont) */
  1015.  
  1016.         StatusBarSize = ysize = (int)((float)lptm->tmHeight * 1.75);
  1017.         ReleaseDC(hWndStatus, hDC);
  1018.         xpos = 0;
  1019.         ypos = lpClientRect->bottom - ysize;
  1020.  
  1021.         if (IsWindow(hWndStatus))
  1022.         {
  1023.           MoveWindow(hWndStatus, xpos, ypos, xsize, ysize, TRUE);
  1024.           ShowWindow(hWndStatus, SW_SHOW);
  1025.           GetClientRect(hWndStatus, lpClientRect);
  1026.           InvalidateRect(hWndStatus, lpClientRect, TRUE);
  1027.           UpdateWindow(hWndStatus);
  1028.         } /* if (IsWindow(hWndStatus)) */
  1029.  
  1030.         prevxsize = 0;
  1031.         GetClientRect(ghWndMain, lpClientRect);
  1032.         y_size = lpClientRect->bottom - lpClientRect->top - (ysize + ribbon_width);
  1033.         if (IsWindow(ghListBox))
  1034.         {
  1035.           prevxsize = xsize = (short)(ceil((lpClientRect->right - lpClientRect->left) * ratio) - HALF_MID_SIZE);
  1036.           MoveWindow(ghListBox, lpClientRect->left, lpClientRect->top + ribbon_width, xsize, y_size, TRUE);
  1037.         } /* if (IsWindow(ghListBox)) */
  1038.  
  1039.         if (IsWindow(ghListBox2))
  1040.         {
  1041.           xsize = (short)(ceil((lpClientRect->right - lpClientRect->left) * (1.0 - ratio)) - HALF_MID_SIZE);
  1042.           MoveWindow(ghListBox2, lpClientRect->left + prevxsize + MID_SIZE, lpClientRect->top + ribbon_width, xsize, y_size, TRUE);
  1043.         } /* if (IsWindow(ghListBox2)) */
  1044.  
  1045.         ShowWindow(hWndStatus, SW_SHOW);
  1046.         GetClientRect(hWndStatus, lpClientRect);
  1047.         InvalidateRect(hWndStatus, lpClientRect, TRUE);
  1048.         UpdateWindow(hWndStatus);
  1049.       } /* if (hWndStatus) */
  1050.  
  1051.       break;
  1052.     } /* case WM_SIZE */
  1053.  
  1054.     case WM_DESTROY:
  1055.     {
  1056.       RemoveProp(hWnd, "Status Window Handle");
  1057.       DdeFreeStringHandle(idInst, ghszTopic);
  1058.       DdeFreeStringHandle(idInst, ghszItem);
  1059.       DdeFreeStringHandle(idInst, ghszServer);
  1060.       DdeFreeStringHandle(idInst, hszServerBase);
  1061.  
  1062.       /* terminate all DDE conversations */
  1063.       DdeUninitialize(idInst);
  1064.       FreeProcInstance(lpfnDdeCallBack);
  1065.       PostQuitMessage(0);
  1066.  
  1067.       break;
  1068.     } /* case WM_DESTROY */
  1069.  
  1070.   } /* switch (msg)) */
  1071.  
  1072.   return (DefWindowProc(hWnd, msg, wParam, lParam));
  1073.  
  1074. } /*** MainWndProc() ***/
  1075.  
  1076. /* ========================================= Parallax C Function ==================
  1077.  
  1078.    @Name: WinMain
  1079.    @Desc: 
  1080.  
  1081. ============================================================================== */
  1082.  
  1083. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  1084. {
  1085.   MSG msg;
  1086.   HWND FirsthWnd, FirstChildhWnd;
  1087.  
  1088.   if (lpCmdLine) ;
  1089.  
  1090.   /* Only one instance of the client can run, so we check to see */
  1091.   /* if there is another one that is already running.  If there  */
  1092.   /* is, then we bring it to the top and do not start the second */
  1093.   /* instance.                                                   */
  1094.  
  1095.   if ((FirsthWnd = FindWindow(szMainClass, NULL)) != NULL)
  1096.   {
  1097.     FirstChildhWnd = GetLastActivePopup(FirsthWnd);
  1098.     BringWindowToTop(FirsthWnd);
  1099.  
  1100.     if (FirsthWnd != FirstChildhWnd) BringWindowToTop(FirstChildhWnd);
  1101.  
  1102.     return (FALSE);
  1103.   } /* if ((FirsthWnd = FindWindow(szMainClass, NULL)) != NULL) */
  1104.  
  1105.   if (!hPrevInstance && !InitApplication(hInstance)) return (FALSE);
  1106.  
  1107.   if (!InitInstance(hInstance, nCmdShow)) return (FALSE);
  1108.  
  1109.   while (GetMessage(&msg, NULL, 0, 0))
  1110.   {
  1111.     TranslateMessage(&msg);
  1112.     DispatchMessage(&msg);
  1113.   } /* while (GetMessage(&msg, NULL, 0, 0)) */
  1114.  
  1115.   return (msg.wParam);
  1116. } /* WinMain() */
  1117.  
  1118. #define  CLOCK_TIMER    24
  1119. /* ========================================= Parallax C Function ==================
  1120.  
  1121.    @Name: ClockProc
  1122.    @Desc: 
  1123.  
  1124. ============================================================================== */
  1125.  
  1126. void CALLBACK ClockProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 
  1127. {
  1128.   char      szBuffer[64];
  1129. #ifdef __TURBOC__
  1130.   struct  dostime_t   time;
  1131. #else
  1132. #ifndef _WIN32
  1133.   struct _dostime_t   time;
  1134. #else
  1135.   int       i;
  1136.   time_t    time_value;
  1137. #endif
  1138. #endif
  1139.  
  1140.   if (lParam) ;
  1141.  
  1142.   switch (msg)
  1143.   {
  1144.     case WM_TIMER:
  1145.     {
  1146.       switch (wParam)
  1147.       {
  1148.         case CLOCK_TIMER:
  1149.         {
  1150.           KillTimer(hWnd, wParam);
  1151. #ifndef _WIN32
  1152.           _dos_gettime(&time);
  1153.           wsprintf(szBuffer, "%2.2d:%2.2d:%2.2d", time.hour, time.minute, time.second);
  1154. #else
  1155.           time (&time_value) ;
  1156.           strcpy (szBuffer, ctime (&time_value)) ;
  1157.             for ( i = 0; szBuffer[i] > 0; i++ ) {
  1158.                 if ( szBuffer[i] < ' ' ) {
  1159.                     szBuffer[i] = 0;
  1160.                 }
  1161.             }
  1162. #endif
  1163.           SendMessage(hWnd, WM_COMMAND, 1, (LPARAM)((LPSTR)szBuffer));
  1164.           SetTimer(hWnd, wParam, 1000, (TIMERPROC)ClockProc);
  1165.  
  1166.           break;
  1167.         } /* case CLOCK_TIMER */
  1168.  
  1169.         default:
  1170.         {
  1171.           break;
  1172.         } /* case default */
  1173.       } /* switch (wParam) */
  1174.  
  1175.       break;
  1176.     } /* case WM_TIMER */
  1177.   } /* switch (msg) */
  1178. } /* CallBack() */
  1179.  
  1180. /* ========================================= Parallax C Function ==================
  1181.  
  1182.    @Name: StatusBarTextWndProc
  1183.    @Desc: 
  1184.  
  1185. ============================================================================== */
  1186.  
  1187. long FAR PASCAL StatusBarTextWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  1188. {
  1189.   HDC               hDC;
  1190.   PAINTSTRUCT       ps;
  1191.   HGDIOBJ           oldObj;
  1192.   HPEN              hPen;
  1193.   RECT              rect;
  1194.   HFONT             hFont;
  1195.   HFONT             hFontOld = (HFONT)0;
  1196.   TEXTMETRIC        tm;
  1197.   TEXTMETRIC  FAR  *lptm = &tm;
  1198.   HANDLE            hCurText = NULL;
  1199.   LPSTR             currentText;
  1200.   long              style;
  1201.   HANDLE            hStyle;
  1202.   LPLONG            lpStyle;
  1203.  
  1204.   switch (msg)
  1205.   {
  1206.     case WM_CREATE:
  1207.     {
  1208.       SetProp(hWnd, "Current Text", GlobalAlloc(GHND | GMEM_DDESHARE, 1024));
  1209.  
  1210.       break;
  1211.     } /* case WM_CREATE */
  1212.  
  1213.     case WM_PAINT:
  1214.     {
  1215.       hDC = BeginPaint(hWnd, &ps);
  1216.       hPen = CreatePen(PS_SOLID, 3, RGB(128, 128, 128));
  1217.       oldObj = SelectObject(hDC, hPen);
  1218.       GetClientRect(hWnd, &rect);
  1219.       MoveTo(hDC, rect.left, rect.bottom);
  1220.       LineTo(hDC, rect.left, rect.top);
  1221.       LineTo(hDC, rect.right, rect.top);
  1222.       SelectObject(hDC, oldObj);
  1223.       DeleteObject(hPen);
  1224.       hPen = CreatePen(PS_SOLID, 3, RGB(255, 255, 255));
  1225.       SelectObject(hDC, hPen);
  1226.       LineTo(hDC, rect.right, rect.bottom);
  1227.       LineTo(hDC, rect.left, rect.bottom);
  1228.       SelectObject(hDC, oldObj);
  1229.       DeleteObject(hPen);
  1230.  
  1231.       hCurText = GetProp(hWnd, "Current Text");
  1232.       if (hCurText)
  1233.       {
  1234.         currentText = GlobalLock(hCurText);
  1235.  
  1236.         if (lstrlen((LPSTR)currentText))
  1237.         {
  1238.           GetClientRect(hWnd, &rect);
  1239.           InflateRect(&rect, -3, -3);
  1240.           SetBkMode(hDC, TRANSPARENT);
  1241.           GetTextMetrics(hDC,  lptm);
  1242.  
  1243.           hFont = CreateFont(( lptm->tmHeight * 9 / 10 ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  1244.           if (hFont)
  1245.           {
  1246.             hFontOld = SelectObject(hDC, hFont);
  1247.           } /* if (hFont) */
  1248.  
  1249.           hStyle = GetProp(hWnd, "Current Text Style");
  1250.           if (hStyle)
  1251.           {
  1252.             lpStyle = (long far *)GlobalLock(hStyle);
  1253.             style = *lpStyle;
  1254.             GlobalUnlock(hStyle);
  1255.           } else /* if (hStyle) */
  1256.           {
  1257.             style = DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER;
  1258.           } /* if (hStyle) */
  1259.  
  1260.           DrawText(hDC, (LPSTR)currentText, -1, &rect, (WORD)style);
  1261.  
  1262.           if (hFont)
  1263.           {
  1264.             SelectObject(hDC, hFontOld);
  1265.             DeleteObject(hFont);
  1266.           } /* if (hFont) */
  1267.  
  1268.           GlobalUnlock(hCurText);
  1269.         } /* if (lstrlen((LPSTR)currentText)) */
  1270.       } /* if (hCurText) */
  1271.  
  1272.       EndPaint(hWnd, &ps);
  1273.  
  1274.       break;
  1275.     } /* case WM_PAINT */
  1276.  
  1277.     case WM_COMMAND:
  1278.     {
  1279.       switch (wParam)
  1280.       {
  1281.         case 1:
  1282.         {
  1283.           hCurText = GetProp(hWnd, "Current Text");
  1284.           if (hCurText)
  1285.           {
  1286.             currentText = GlobalLock(hCurText);
  1287.  
  1288.             if (lstrlen((LPSTR)lParam))
  1289.             {
  1290.               lstrcpy((LPSTR)currentText, (LPSTR)lParam);
  1291.               GetClientRect(hWnd, &rect);
  1292.               InflateRect(&rect, -3, -3);
  1293.               InvalidateRect(hWnd, &rect, TRUE);
  1294.               UpdateWindow(hWnd);
  1295.               GlobalUnlock(hCurText);
  1296.             } /* if (lstrlen((LPSTR)lParam)) */
  1297.           } /* if (hCurText) */
  1298.  
  1299.           break;
  1300.         } /* case 1*/
  1301.  
  1302.         case 2:
  1303.         {
  1304.           hStyle = GlobalAlloc(GHND | GMEM_DDESHARE, sizeof(long));
  1305.           lpStyle = (long far *)GlobalLock(hStyle);
  1306.           *lpStyle = lParam;
  1307.           GlobalUnlock(hStyle);
  1308.           SetProp(hWnd, "Current Text Style", (HWND)hStyle);
  1309.  
  1310.           break;
  1311.         } /* case 2 */
  1312.  
  1313.         default:
  1314.         {
  1315.           break;
  1316.         } /* case default */
  1317.       } /* switch (wParam) */
  1318.  
  1319.       break;
  1320.     } /* case WM_COMMAMD */
  1321.  
  1322.     case WM_DESTROY:
  1323.     {
  1324.       hCurText = GetProp(hWnd, "Current Text");
  1325.       GlobalFree(hCurText);
  1326.       RemoveProp(hWnd, "Current Text");
  1327.  
  1328.       hStyle = GetProp(hWnd, "Current Text Style");
  1329.       if (hStyle)
  1330.       {
  1331.         GlobalFree(hStyle);
  1332.         RemoveProp(hWnd, "Current Text Style");
  1333.       } if (hStyle)
  1334.  
  1335.       PostQuitMessage(0);
  1336.  
  1337.       break;
  1338.     } /* case WM_DESTROY */
  1339.   } /* switch (msg) */
  1340.  
  1341.   return (DefWindowProc(hWnd, msg, wParam, lParam));
  1342. } /* StatusBarTextWndProc */
  1343.  
  1344.  
  1345.  
  1346. /* ========================================= Parallax C Function ==================
  1347.  
  1348.    @Name: StatusBarWndProc
  1349.    @Desc: 
  1350.  
  1351. ============================================================================== */
  1352.  
  1353. long FAR PASCAL StatusBarWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  1354. {
  1355.   HDC               hDC;
  1356.   RECT              ClientRect;
  1357.   RECT             *lpClientRect = &ClientRect;
  1358.   RECT              Rect;
  1359.   RECT             *lpRect = &Rect;
  1360.   int               xpos;
  1361.   int               ypos;
  1362.   int               xsize;
  1363.   int               ysize;
  1364.   HWND              hWndStatusButton = NULL;
  1365.   HFONT             hFont;
  1366.   HFONT             hFontOld = (HFONT)0;
  1367.   TEXTMETRIC        tm;
  1368.   TEXTMETRIC  FAR  *lptm = &tm;
  1369.   char              szBuffer[64];
  1370. #ifdef __TURBOC__
  1371.   struct dostime_t    time;
  1372. #else
  1373. #ifndef _WIN32
  1374.   struct _dostime_t   time;
  1375. #else
  1376.   time_t            time_value ;
  1377.   int               i;
  1378. #endif
  1379. #endif
  1380.  
  1381.   switch (msg)
  1382.   {
  1383.     case WM_CREATE:
  1384.     {
  1385.       GetClientRect(hWnd, lpClientRect);
  1386.       CopyRect(lpRect, lpClientRect);
  1387.       InflateRect(lpClientRect, -3, 0);
  1388.       hDC = GetDC(hWnd);
  1389.       GetTextMetrics(hDC,  lptm);
  1390.  
  1391.       hFont = CreateFont(( lptm->tmHeight * 9 / 10 ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  1392.       if (hFont)
  1393.       {
  1394.         hFontOld = SelectObject(hDC, hFont);
  1395.       } /* if (hFont) */
  1396.  
  1397.       xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.6);
  1398.  
  1399.       if (hFont)
  1400.       {
  1401.         SelectObject(hDC, hFontOld);
  1402.         DeleteObject(hFont);
  1403.       } /* if (hFont) */
  1404.  
  1405.       ysize = (int)((float)lpClientRect->bottom * 0.875);
  1406.       ReleaseDC(hWnd, hDC);
  1407.       xpos = 3;
  1408.       ypos = lpRect->bottom  / 16;
  1409.       hWndStatusButton = CreateWindow(szStatusBarTextClass,
  1410.                                       NULL,
  1411.                                       WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE ,
  1412.                                       xpos, ypos,
  1413.                                       xsize, ysize,
  1414.                                       hWnd, NULL, ghInst, NULL);
  1415.       if (hWndStatusButton)
  1416.       {
  1417.         ShowWindow(hWndStatusButton, SW_SHOW);
  1418.         SetProp(hWnd, "Status Window Text Handle", hWndStatusButton);
  1419.       } /* if (hWndStatusButton) */
  1420.  
  1421.       GetClientRect(hWnd, lpClientRect);
  1422.       CopyRect(lpRect, lpClientRect);
  1423.       InflateRect(lpClientRect, -3, 0);
  1424.       xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.35);
  1425.       hDC = GetDC(hWnd);
  1426.       ReleaseDC(hWnd, hDC);
  1427.       xpos = (int)((float)lpRect->right - xsize - 3);
  1428.       hWndStatusButton = CreateWindow(szStatusBarTextClass,
  1429.                                       NULL,
  1430.                                       WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE ,
  1431.                                       xpos, ypos,
  1432.                                       xsize, ysize,
  1433.                                       hWnd, NULL, ghInst, NULL);
  1434.       if (hWndStatusButton)
  1435.       {
  1436.         ShowWindow(hWndStatusButton, SW_SHOW);
  1437.         SetProp(hWnd, "Status Window Clock Handle", hWndStatusButton);
  1438. #ifndef _WIN32
  1439.         _dos_gettime(&time);
  1440.         wsprintf(szBuffer, "%2.2d:%2.2d:%2.2d", time.hour, time.minute, time.second);
  1441. #else
  1442.         time (&time_value) ;
  1443.         strcpy (szBuffer, ctime (&time_value)) ;
  1444.         for ( i = 0; szBuffer[i] > 0; i++ ) {
  1445.             if ( szBuffer[i] < ' ' ) {
  1446.                 szBuffer[i] = 0;
  1447.             }
  1448.         }
  1449. #endif
  1450.         SendMessage(hWndStatusButton, WM_COMMAND, 2, (LPARAM)(DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER));
  1451.         SendMessage(hWndStatusButton, WM_COMMAND, 1, (LPARAM)((LPSTR)szBuffer));
  1452.         SetTimer(hWndStatusButton, CLOCK_TIMER, 1000, (TIMERPROC)ClockProc);
  1453.       } /* if (hWndStatusButton) */
  1454.  
  1455.       break;
  1456.     } /* case WM_CREATE */
  1457.  
  1458.     case WM_SIZE:
  1459.     {
  1460.       hWndStatusButton = GetProp(hWnd, "Status Window Text Handle");
  1461.       if (hWndStatusButton)
  1462.       {
  1463.         GetClientRect(hWnd, lpClientRect);
  1464.         CopyRect(lpRect, lpClientRect);
  1465.         InflateRect(lpClientRect, -3, 0);
  1466.         xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.6);
  1467.         hDC = GetDC(hWnd);
  1468.         ysize = (int)((float)lpClientRect->bottom * 0.875);
  1469.         ReleaseDC(hWnd, hDC);
  1470.         xpos = 3;
  1471.         ypos = lpRect->bottom  / 16;
  1472.         MoveWindow(hWndStatusButton, xpos, ypos, xsize, ysize, TRUE);
  1473.         ShowWindow(hWndStatusButton, SW_SHOW);
  1474.         GetClientRect(hWndStatusButton, lpClientRect);
  1475.         InvalidateRect(hWndStatusButton, lpClientRect, TRUE);
  1476.         UpdateWindow(hWndStatusButton);
  1477.       } /* if (hWndStatusButton) */
  1478.  
  1479.       hWndStatusButton = GetProp(hWnd, "Status Window Clock Handle");
  1480.       if (hWndStatusButton)
  1481.       {
  1482.         GetClientRect(hWnd, lpClientRect);
  1483.         CopyRect(lpRect, lpClientRect);
  1484.         InflateRect(lpClientRect, -3, 0);
  1485.         hDC = GetDC(hWnd);
  1486.         xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.35);
  1487.         ysize = (int)((float)lpClientRect->bottom * 0.875);
  1488.         ReleaseDC(hWnd, hDC);
  1489.         xpos = (int)((float)lpRect->right - xsize - 3);
  1490.         ypos = lpRect->bottom  / 16;
  1491.         MoveWindow(hWndStatusButton, xpos, ypos, xsize, ysize, TRUE);
  1492.         ShowWindow(hWndStatusButton, SW_SHOW);
  1493.         GetClientRect(hWndStatusButton, lpClientRect);
  1494.         InvalidateRect(hWndStatusButton, lpClientRect, TRUE);
  1495.         UpdateWindow(hWndStatusButton);
  1496.       } /* if (hWndStatusButton) */
  1497.  
  1498.       break;
  1499.     } /* case WM_SIZE */
  1500.  
  1501.     case WM_DESTROY:
  1502.     {
  1503.       RemoveProp(hWnd, "Status Window Text Handle");
  1504.       RemoveProp(hWnd, "Status Window Clock Handle");
  1505.       PostQuitMessage(0);
  1506.  
  1507.       break;
  1508.     } /* case WM_DESTROY */
  1509.   } /* switch (msg) */
  1510.  
  1511.   return (DefWindowProc(hWnd, msg, wParam, lParam));
  1512. } /* StatusBarWndProc() */
  1513.  
  1514. void STS_Message(HWND hWnd, LPSTR msg)
  1515. {
  1516.   HWND  hWndStatus = GetProp(hWnd, "Status Window Handle");
  1517.   HWND  hWndStatusButton = NULL;
  1518.  
  1519.   if (hWndStatus)
  1520.   {
  1521.     hWndStatusButton = GetProp(hWndStatus, "Status Window Text Handle");
  1522.     SendMessage(hWndStatusButton, WM_COMMAND, 1, (LPARAM)msg);
  1523.   }  /* if (hWndStatus) */
  1524.  
  1525.   return;
  1526. } /* STS_Message() */
  1527.  
  1528.  
  1529. /* DDE_TEST.C */
  1530. /* end of file */
  1531.