home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 March
/
Chip_1998-03_cd.bin
/
tema
/
eroiica
/
EROICA16
/
DDE_TEST.C_
/
DDE_TEST.C
Wrap
C/C++ Source or Header
|
1998-01-15
|
45KB
|
1,531 lines
/*-------------------------- Parallax Standard C_File ----------------------------
C_File: dde_test.c
Purpose: This file contains the source code for the main
window procedure for the Eroica unit test program.
$nokeywords$
--------------------------------------------------------------------------------
Copyright (c)1996 Parallax Software , All rights reserved.
------------------------------------------------------------------------------*/
#include "dde_test.h"
#include "utdlg.h"
#include "utdde.h"
#include "testcase.h"
#include <memory.h>
#include <string.h>
#include <dos.h>
#include <stdlib.h>
#include <commdlg.h>
#include <stdio.h>
#include <math.h>
#ifdef _WIN32
#include <time.h>
#endif
/* global variables */
HANDLE ghInst = NULL; /* handle to this instance */
HWND ghWndMain = NULL; /* handle to main window */
HWND ghListBox = NULL; /* handle to main's listbox */
HWND ghListBox2 = NULL; /* handle to main's 2nd listbox */
char szMainMenu[] = "MainMenu";
char szMainClass[] = "Dde_TestClass";
char szStatusBarClass[] = "IMG_StatusBarClass(PDM)";
char szStatusBarTextClass[] = "IMG_StatusBarTextClass(PDM)";
DWORD idInst = 0L; /* instance identifier */
HSZ ghszTopic, ghszItem;
HSZ ghszServer;
HSZ hszServerBase = NULL; /* Service name */
HSZ hszServerInst;
UINT old_tool = 0;
UINT ribbon_width = 0;
UINT StatusBarSize;
/* local functions */
void SaveAs(HWND hWnd, LPSTR RasterFormatList);
void STS_Message(HWND hWnd, LPSTR msg);
static HCONV _dupatom_IMG_Connect(HWND hWnd, DWORD idInst, HSZ ghszServer, HSZ ghszTopic)
{
/* need to create atoms that can be destroyed by the server */
char buf[256];
HSZ srv, topic;
if (DdeQueryString(idInst, ghszServer, buf, sizeof(buf), CP_WINANSI))
{
srv = DdeCreateStringHandle(idInst, buf, CP_WINANSI);
if (DdeQueryString(idInst, ghszTopic, buf, sizeof(buf), CP_WINANSI))
{
topic = DdeCreateStringHandle(idInst, buf, CP_WINANSI);
return (IMG_Connect(hWnd, idInst, srv, topic));
} /* if (DdeQueryString(idInst, ghszTopic, buf, sizeof(buf), CP_WINANSI)) */
} /* if (DdeQueryString(idInst, ghszServer, buf, sizeof(buf), CP_WINANSI)) */
return(NULL);
} /* _dupatom_IMG_Connect */
#define _DDE_CONNECT(ghConv) ghConv = _dupatom_IMG_Connect( hWnd, idInst, ghszServer, ghszTopic )
#define _DDE_DISCONNECT(ghConv) { DdeDisconnect(ghConv); ghConv=0; }
static HCONV apiConv = NULL;
static HCONV hotspotActivationConv = NULL;
static HCONV hotspotPlacementConv = NULL;
static HCONV hotspotHighlightConv = NULL;
#define MID_SIZE 4
#define HALF_MID_SIZE 2
double ratio = 0.6; /* Percentage of screen real estate to give to 1st listbox */
/* 970224 jk add to cover missing function in WIN32 API */
#ifdef _WIN32
static POINT MoveTo(HDC hDC, int x, int y)
{
POINT oldpos ;
MoveToEx(hDC, x, y, &oldpos) ;
return oldpos ;
}
#endif
/* 970224 jk end */
/* ========================================= Parallax C Function ==================
@Name: MainWndProc
@Desc:
============================================================================== */
long FAR PASCAL MainWndProc(HWND hWnd, unsigned msg, WORD wParam, LONG lParam)
{
static FARPROC lpProc;
RECT ClientRect;
RECT *lpClientRect = &ClientRect;
RECT Rect;
RECT *lpRect = &Rect;
static FARPROC lpfnDdeCallBack;
int xpos;
int ypos;
int xsize;
int prevxsize;
int ysize;
int y_size;
HDC hDC;
TEXTMETRIC tm;
TEXTMETRIC FAR *lptm = &tm;
HWND hWndStatus = NULL;
HFONT hFont;
HFONT hFontOld = (HFONT)0;
char szTmp[132];
char szBuffer[1024];
WORD fwMenu;
static POINT pt;
static int capture = FALSE;
switch (msg)
{
case WM_CREATE:
{
/* Ddeml initialization */
lpfnDdeCallBack = MakeProcInstance((FARPROC)DdeCallBack, ghInst);
if (DdeInitialize(&idInst, (PFNCALLBACK)lpfnDdeCallBack, APPCMD_CLIENTONLY, 0L))
{
return FALSE;
} /* if (DdeInitialize(&idInst, (PFNCALLBACK)lpfnDdeCallBack, APPCMD_CLIENTONLY, 0L)) */
/* Topic Name.... */
ghszTopic = DdeCreateStringHandle(idInst, (LPSTR)"imaging", CP_WINANSI);
/* Server Name..... */
ghszServer = DdeCreateStringHandle(idInst, (LPSTR)"Eroica", CP_WINANSI);
GetClientRect(hWnd, lpClientRect);
xsize = lpClientRect->right - lpClientRect->left;
hDC = GetDC(hWnd);
GetTextMetrics(hDC, lptm);
StatusBarSize = ysize = lptm->tmHeight * 2;
ReleaseDC(hWnd, hDC);
xpos = 0;
ypos = lpClientRect->bottom - ysize;
hWndStatus = CreateWindow(szStatusBarClass,
NULL,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | WS_BORDER,
xpos,
ypos,
xsize,
ysize,
hWnd, NULL, ghInst, NULL);
if (hWndStatus)
{
SetProp(hWnd, "Status Window Handle", hWndStatus);
ShowWindow(hWndStatus, SW_SHOW);
GetClientRect(hWndStatus, lpClientRect);
InvalidateRect(hWndStatus, lpClientRect, TRUE);
UpdateWindow(hWndStatus);
GetClientRect(hWnd, lpClientRect);
xsize = lpClientRect->right - lpClientRect->left;
hDC = GetDC(hWnd);
GetTextMetrics(hDC, lptm);
ysize = lptm->tmHeight * 2;
ReleaseDC(hWnd, hDC);
} else /* if (hWndStatus) */
{
MessageBox(ghWndMain, "Unable to Create Window", "Error", MB_OK);
} /* fi (hWndStatus)) */
GetClientRect(hWnd, lpRect);
break;
} /* case WM_CREATE */
case WM_MOUSEMOVE:
{
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
if (wParam & MK_LBUTTON)
{
HDC hDC;
RECT rect;
HPEN hPen;
HPEN hOldPen;
int oRop;
if (capture == TRUE)
{
hDC = GetDC(hWnd);
if (hDC)
{
SetCapture(hWnd);
GetClientRect(hWnd, &rect);
hPen = CreatePen(PS_SOLID, 1, RGB(127, 127, 127));
hOldPen = SelectObject(hDC, hPen);
oRop = SetROP2(hDC, R2_NOTXORPEN);
MoveTo(hDC, pt.x, ribbon_width);
LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
MoveTo(hDC, pt.x, ribbon_width);
LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
SelectObject(hDC, hOldPen);
DeleteObject(hPen);
SetROP2(hDC, oRop);
ReleaseDC(hWnd, hDC);
} /* if (hDC)) */
} /* if (capture == TRUE)) */
} /* if (wParam & MK_LBUTTON)) */
break;
} /* case WM_MOUSEMOVE */
case WM_LBUTTONUP:
{
RECT rect;
int range;
HDC hDC;
HPEN hPen;
HPEN hOldPen;
int oRop;
if (capture == TRUE)
{
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
GetClientRect(hWnd, &rect);
range = rect.right - rect.left + 1;
ratio = (double)pt.x / (double)range;
if (ratio > 0.95) ratio = 0.95;
if (ratio < 0.05) ratio = 0.05;
ReleaseCapture();
capture = FALSE;
hDC = GetDC(hWnd);
if (hDC)
{
hPen = CreatePen(PS_SOLID, 1, RGB(127, 127, 127));
hOldPen = SelectObject(hDC, hPen);
oRop = SetROP2(hDC, R2_NOTXORPEN);
MoveTo(hDC, pt.x, ribbon_width);
LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
pt.x = 0;
pt.y = 0;
SelectObject(hDC, hOldPen);
DeleteObject(hPen);
SetROP2(hDC, oRop);
ReleaseDC(hWnd, hDC);
} /* fi (hDC)) */
GetWindowRect(hWnd, &rect);
SendMessage(hWnd, WM_SIZE, SIZE_RESTORED, MAKELONG(rect.right - rect.left, rect.bottom - rect.top));
} /* if (capture == TRUE)) */
break;
} /* case WM_LBUTTONUP */
case WM_LBUTTONDOWN:
{
HDC hDC;
RECT rect;
HPEN hPen;
HPEN hOldPen;
int oRop;
hDC = GetDC(hWnd);
if (hDC)
{
SetCapture(hWnd);
GetClientRect(hWnd, &rect);
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
hPen = CreatePen(PS_SOLID, 1, RGB(127, 127, 127));
hOldPen = SelectObject(hDC, hPen);
oRop = SetROP2(hDC, R2_NOTXORPEN);
MoveTo(hDC, pt.x, ribbon_width);
LineTo(hDC, pt.x, rect.bottom - StatusBarSize);
SelectObject(hDC, hOldPen);
DeleteObject(hPen);
SetROP2(hDC, oRop);
ReleaseDC(hWnd, hDC);
capture = TRUE;
} /* if (hDC)) */
break;
} /* case WM_LBUTTONDOWN */
case WM_MENUSELECT:
{
fwMenu = LOWORD(lParam);
if (fwMenu & MF_POPUP)
{
;
} else /* if (fwMenu & MF_POPUP)) */
{
if (LoadString(ghInst, wParam, (LPSTR)szBuffer, sizeof(szBuffer)))
{
STS_Message(ghWndMain, (LPSTR)szBuffer);
} /* LoadString(ghInst, wParam, (LPSTR)szBuffer, sizeof(szBuffer)) */
} /* if (fwMenu & MF_POPUP)) */
break;
} /* case WM_MENUSELECT */
case WM_COMMAND:
{
HCONV ghConv;
/* try to serve not-DDE commands first */
switch (wParam)
{
case IDM_ABOUT: /* show about box */
{
lpProc = MakeProcInstance((int (pascal far*)())About, ghInst);
#ifdef __TURBOC__
DialogBox(ghInst, "BorAbout", hWnd, lpProc);
#else
DialogBox(ghInst, "About", hWnd, lpProc);
#endif
FreeProcInstance(lpProc);
return( 0 );
} /* case IDM_ABOUT */
case IDM_CLEAR: /* clear text box */
{
SendMessage(ghListBox, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
SendMessage(ghListBox2, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
return( 0 );
} /* case IDM_CLEAR */
case IDM_EXIT:
{
PostMessage(hWnd, WM_CLOSE, 0, 0L);
return( 0 );
} /* case IDM_EXIT */
}
/* if not served they are DDE, try to open communication */
_DDE_CONNECT(ghConv);
if ( !ghConv )
return( 0 );
/* we can communicate, process command */
switch (wParam)
{
case IDM_STARTUP:
{
IMG_StartUp(ghConv);
break;
} /* case IDM_STARTUP */
case IDM_MERGE:
{
IMG_Merge(ghConv, 0, MERGE_WHOLEDOC, NULL);
break;
} /* case IDM_MERGE */
case IDM_CROP700:
{
IMG_SetShowStatusDialogs(ghConv, 0);
IMG_Crop(ghConv, 0, 50, 100, 750, 800);
break;
} /* case IDM_CROP700 */
case IDM_DESKEW1:
{
IMG_SetShowStatusDialogs(ghConv, 0);
IMG_Deskew(ghConv, 0, (float)1.0);
break;
} /* case IDM_DESKEW1 */
case IDM_DESPECKLE30:
{
IMG_Despeckle(ghConv, 0, 30);
break;
} /* case IDM_DESPECKLE30 */
case IDM_DPITO200x100:
{
IMG_RasterDPIChange(ghConv, 200, 100);
break;
} /* case IDM_DPITO200x100 */
case IDM_API_NOTIFY:
{
if (!apiConv)
{
_DDE_CONNECT(apiConv);
IMG_NotifyApi(apiConv);
} /* if (!apiConv)) */
break;
} /* case IDM_API_NOTIFY */
case IDM_API_UNNOTIFY:
{
if (apiConv)
{
IMG_NotifyApiStop(apiConv);
_DDE_DISCONNECT(apiConv);
} /* if (apiConv)) */
break;
} /* case IDM_API_UNNOTIFY */
case IDM_HOTSPOT_NOTIFY:
{
if (!hotspotActivationConv)
{
_DDE_CONNECT(hotspotActivationConv);
IMG_NotifyHotSpot(hotspotActivationConv);
} /* if (!hotspotActivationConv)) */
break;
} /* case IDM_HOTSPOT_NOTIFY */
case IDM_HOTSPOT_UNNOTIFY:
{
if (hotspotActivationConv)
{
IMG_NotifyHotSpotStop(hotspotActivationConv);
_DDE_DISCONNECT(hotspotActivationConv);
} /* if (hotspotActivationConv)) */
break;
} /* case IDM_HOTSPOT_UNNOTIFY */
case IDM_HOTSPOT_NOTIFY_PLACEMENT:
{
if (!hotspotPlacementConv)
{
_DDE_CONNECT(hotspotPlacementConv);
IMG_NotifyHotSpotPlaced(hotspotPlacementConv);
} /* if (!hotspotPlacementConv)) */
break;
} /* case IDM_HOTSPOT_NOTIFY_PLACEMENT */
case IDM_HOTSPOT_UNNOTIFY_PLACEMENT:
{
if (hotspotPlacementConv)
{
IMG_NotifyHotSpotPlacedStop(hotspotPlacementConv);
_DDE_DISCONNECT(hotspotPlacementConv);
} /* if (hotspotPlacementConv)) */
break;
} /* case IDM_HOTSPOT_UNNOTIFY_PLACEMENT */
case IDM_HOTSPOT_NOTIFY_HIGHLIGHT:
{
if (!hotspotHighlightConv)
{
_DDE_CONNECT(hotspotHighlightConv);
IMG_NotifyHotSpotHighlighted(hotspotHighlightConv);
} /* if (!hotspotPlacementConv)) */
break;
} /* case IDM_HOTSPOT_NOTIFY_HIGHLIGHT */
case IDM_HOTSPOT_UNNOTIFY_HIGHLIGHT:
{
if (hotspotHighlightConv)
{
IMG_NotifyHotSpotHighlightedStop(hotspotHighlightConv);
_DDE_DISCONNECT(hotspotHighlightConv);
} /* if (hotspotPlacementConv)) */
break;
} /* case IDM_HOTSPOT_UNNOTIFY_HIGHLIGHT */
case IDM_TESTDESKEW:
{
UT_TestDeskew(ghConv);
break;
} /* case IDM_TESTDESKEW */
case IDM_TESTLOAD:
{
UT_TestLoad(ghConv);
break;
} /* TESTLOAD */
case IDM_TESTSAVE:
{
UT_TestSave(ghConv);
break;
} /* TESTSAVE */
case IDM_TESTMERGE:
{
UT_TestMerge(ghConv);
break;
} /* TESTMERGE */
case IDM_TESTDISPLAYLAYER:
{
UT_TestDisplayLayer(ghConv);
break;
} /* case IDM_TESTDISPLAYLAYER */
case IDM_TESTTOOLSET:
{
UT_TestToolSet(ghConv);
break;
} /* case IDM_TESTTOOLSET */
case IDM_ARRANGETILE:
{
IMG_ArrangeDocWins(ghConv, ARRANGE_TILE);
break;
} /* case IDM_ARRANGETILE */
case IDM_ARRANGECASCADE:
{
IMG_ArrangeDocWins(ghConv, ARRANGE_CASCADE);
break;
} /* case IDM_ARRANGECASCADE */
case IDM_ARRANGEHSTRIP:
{
IMG_ArrangeDocWins(ghConv, ARRANGE_HORZSTRIP);
break;
} /* case IDM_ARRANGEHSTRIP */
case IDM_ARRANGEVSTRIP:
{
IMG_ArrangeDocWins(ghConv, ARRANGE_VERTSTRIP);
break;
} /* case IDM_ARRANGEVSTRIP */
case IDM_GETNUMBERDOCWINS:
{
IMG_GetNumberDocWins(ghConv, NULL);
break;
} /* case IDM_GETNUMBERDOCWINS */
case IDM_GETNUMBERLAYERS:
{
IMG_GetNumberLayers(ghConv, 0, NULL);
break;
} /* case IDM_GETNUMBERLAYERS */
case IDM_GETCURRENTDOCWIN:
{
IMG_GetDocWin(ghConv, NULL);
break;
} /* case IDM_GETCURRENTDOCWIN */
case IDM_PRINTDOCWIN:
{
IMG_PrintDocWin(ghConv, 0, 3, 0, 0, 1, 0);
break;
} /* case IDM_PRINTDOCWIN */
case IDM_GETACTIVERASTER:
{
IMG_GetActiveRasterLayer(ghConv, 0, NULL);
break;
} /* case IDM_GETACTIVERASTER */
case IDM_GETACTIVEEDIT:
{
IMG_GetActiveEditLayer(ghConv, 0, NULL);
break;
} /* case IDM_GETACTIVEEDIT */
case IDM_GETDOCDIRTYSTATUS:
{
IMG_GetDocumentDirtyStatus(ghConv, 0, NULL);
break;
} /* case IDM_GETDOCDIRTYSTATUS */
case IDM_GETLAYERDIRTYSTATUS:
{
int i,count;
LAYERID list[20];
if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
{
if (count==0)
{
_MSG("**No layers in active document.");
} else /* fi (count == 0)) */
{
for (i=0; i<count; i++)
{
IMG_GetLayerDirtyStatus(ghConv, 0, list[i], NULL);
} /* for (i = 0; i < count; i++)) */
} /* if (count == 0)) */
} /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
break;
} /* case IDM_GETLAYERDIRTYSTATUS */
case IDM_GETLAYERDISPLAYSTATUS:
{
int i,count;
LAYERID list[20];
if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
{
if (count==0)
{
_MSG("**No layers in active document.");
} else /* if (count == 0)) */
{
for (i=0; i<count; i++)
{
IMG_GetDisplayLayer(ghConv, 0, list[i], NULL);
} /* for (i = 0; i < count; i++)) */
} /* if (count == 0)) */
} /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
break;
} /* case IDM_GETLAYERDISPLAYSTATUS */
case IDM_GETLAYERFORMATS:
{
int i,count;
LAYERID list[20];
if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
{
if (count==0)
{
_MSG("**No layers in active document.");
} else /* if (count == 0)) */
{
for (i=0; i<count; i++)
{
IMG_GetLayerFormat(ghConv, 0, list[i], NULL);
} /* for (i = 0; i < count; i++)) */
} /* if (count == 0)) */
} /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
break;
} /* case IDM_GETLAYERFORMATS */
case IDM_GETLAYERFORMATLIST:
{
IMG_GetLayerFormatList(ghConv);
break;
} /* GETLAYERFORMATLIST */
case IDM_GETLAYERIDS:
{
int i,count;
LAYERID list[20];
if (IMG_GetLayerIDs(ghConv, 0, list, 20, &count))
{
if (count==0)
{
_MSG("**No layers in active document.");
} else /* if (count == 0)) */
{
_MSG("Layer IDs in active document.");
for (i=0; i<count; i++)
{
_FMTMSG2(" Position %d --> layerID %d.", i+1, list[i]);
} /* for (i = 0; i < count; i++)) */
} /* if (count == 0)) */
} /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, &count)) */
break;
} /* case IDM_GETLAYERIDS */
case IDM_GETWINDOWTITLE:
{
char title[80];
IMG_GetWindowTitle(ghConv, 0, (LPSTR)title);
break;
} /* case IDM_GETWINDOWTITLE */
case IDM_GETDOCTITLE:
{
char title[80];
IMG_GetDocumentTitle(ghConv, 0, (LPSTR)title);
break;
} /* case IDM_GETDOCTITLE */
case IDM_GETLAYERTITLES:
{
int i,count;
LAYERID list[20];
if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count))
{
if (count==0)
{
_MSG("**No layers in active document.");
} else /* if (count == 0)) */
{
for (i=0; i<count; i++)
{
IMG_GetLayerTitle(ghConv, 0, list[i], szTmp);
} /* for (i = 0; i < count; i++)) */
} /* if (count == 0)) */
} /* if (IMG_GetLayerIDs(ghConv, 0, list, 20, (int FAR*)&count)) */
break;
} /* case IDM_GETLAYERTITLES */
case IDM_CLOSEALLDOCWIN:
{
IMG_CloseAllDocWin(ghConv, FALSE);
break;
} /* case IDM_CLOSEALLDOCWIN */
case IDM_CLOSEDOCWIN:
{
IMG_CloseDocWin(ghConv, 0, FALSE);
break;
} /* case IDM_CLOSEDOCWIN */
case IDM_ENDFRAME:
{
IMG_EndEroica(ghConv);
break;
} /* case IDM_ENDFRAME */
case IDM_TERMINATE:
{
IMG_Terminate(ghConv);
break;
} /* case IDM_TERMINATE */
case IDM_REFRESH:
{
IMG_Refresh(ghConv, 0);
break;
} /* case IDM_REFRESH */
case IDM_NEXTDOCWIN:
{
DOCWINID docWinID;
IMG_SetDocWin(ghConv, 0, TRUE, &docWinID);
break;
} /* case IDM_NEXTDOCWIN */
case IDM_FOCUSONFRAME:
{
IMG_SetFocus(ghConv);
break;
} /* case IDM_FOCUSFRAME */
case IDM_ZOOMIN:
{
IMG_SetZoom(ghConv, 0, ZOOM_IN, 0, 0, 0);
break;
} /* case IDM_ZOOMIN */
case IDM_ZOOMOUT:
{
IMG_SetZoom(ghConv, 0, ZOOM_OUT, 0, 0, 0);
break;
} /* case IDM_ZOOMOUT */
case IDM_ZOOMFIT:
{
IMG_SetZoom(ghConv, 0, ZOOM_FIT, 0, 0, 0);
break;
} /* case IDM_ZOOMFIT */
case IDM_ZOOMVFIT:
{
IMG_SetZoom(ghConv, 0, ZOOM_VFIT, 0, 0, 0);
break;
} /* case IDM_ZOOMVFIT */
case IDM_ZOOMHFIT:
{
IMG_SetZoom(ghConv, 0, ZOOM_HFIT, 0, 0, 0);
break;
} /* case IDM_ZOOMHFIT */
case IDM_ZOOMACTUAL:
{
IMG_SetZoom(ghConv, 0, ZOOM_ACTUAL, 0, 0, 0);
break;
} /* case IDM_ZOOMACTUAL */
case IDM_ZOOMONETOONE:
{
IMG_SetZoom(ghConv, 0, ZOOM_1TO1, 0, 0, 0);
break;
} /* case IDM_ZOOMTOONE */
case IDM_SHOWMIN:
{
IMG_ShowDocWin(ghConv, 0, SHOW_MINIMIZE);
break;
} /* case IDM_SHOWMIN */
case IDM_SHOWMAX:
{
IMG_ShowDocWin(ghConv, 0, SHOW_MAXIMIZE);
break;
} /* case IDM_SHOWMAX */
case IDM_SHOWRESTORE:
{
IMG_ShowDocWin(ghConv, 0, SHOW_RESTORE);
break;
} /* case IDM_SHOWRESTORE */
case IDM_SHOWHIDE:
{
IMG_ShowDocWin(ghConv, 0, SHOW_HIDE);
break;
} /* case IDM_SHOWHIDE */
case IDM_SHOWUNHIDE:
{
IMG_ShowDocWin(ghConv, 0, SHOW_UNHIDE);
break;
} /* case IDM_SHOWUNHIDE */
case IDM_SETTOOL_NONE:
{
IMG_SetTool(ghConv, 0, TOOL_NONE);
break;
} /* case IDM_SETTOOL_NONE */
case IDM_SETTOOL_CUT:
{
IMG_SetTool(ghConv, 0, TOOL_CUT);
break;
} /* case IDM_SETTOOL_CUT */
case IDM_SETTOOL_COPY:
{
IMG_SetTool(ghConv, 0, TOOL_COPY);
break;
} /* case IDM_SETTOOL_COPY */
case IDM_SETTOOL_PASTE:
{
IMG_SetTool(ghConv, 0, TOOL_PASTE);
break;
} /* case IDM_SETTOOL_PASTE */
case IDM_SETTOOL_LINE:
{
IMG_SetTool(ghConv, 0, TOOL_LINE);
break;
} /* case IDM_SETTOOL_LINE */
case IDM_SETTOOL_BOX:
{
IMG_SetTool(ghConv, 0, TOOL_BOX);
break;
} /* case IDM_SETTOOL_BOX */
case IDM_SETTOOL_CIRCLE:
{
IMG_SetTool(ghConv, 0, TOOL_CIRCLE);
break;
} /* case IDM_SETTOOL_CIRCLE */
case IDM_SETTOOL_ELLIPSE:
{
IMG_SetTool(ghConv, 0, TOOL_ELLIPSE);
break;
} /* case IDM_SETTOOL_ELLIPSE */
case IDM_SETTOOL_ARROW:
{
IMG_SetTool(ghConv, 0, TOOL_ARROW);
break;
} /* case IDM_SETTOOL_ARROW */
case IDM_SETTOOL_SKETCH:
{
IMG_SetTool(ghConv, 0, TOOL_SKETCH);
break;
} /* case IDM_SETTOOL_SKETCH */
case IDM_SETTOOL_POLYLINE:
{
IMG_SetTool(ghConv, 0, TOOL_POLYLINE);
break;
} /* case IDM_SETTOOL_POLYLINE */
case IDM_SETTOOL_POLYGON:
{
IMG_SetTool(ghConv, 0, TOOL_POLYGON);
break;
} /* case IDM_SETTOOL_POLYGON */
case IDM_SETTOOL_TEXT:
{
IMG_SetTool(ghConv, 0, TOOL_TEXT);
break;
} /* case IDM_SETTOOL_TEXT */
case IDM_SETTOOL_ANNOTATION:
{
IMG_SetTool(ghConv, 0, TOOL_ANNOTATION);
break;
} /* case IDM_SETTOOL_ANNOTATION */
case IDM_SETTOOL_DIMENSION:
{
IMG_SetTool(ghConv, 0, TOOL_DIMENSION);
break;
} /* case IDM_SETTOOL_DIMENSION */
case IDM_SETTOOL_SYMBOL:
{
IMG_SetTool(ghConv, 0, TOOL_SYMBOL);
break;
} /* case IDM_SETTOOL_SYMBOL */
case IDM_SETTOOL_HOTSPOT:
{
IMG_SetTool(ghConv, 0, TOOL_HOTSPOT);
break;
} /* case IDM_SETTOOL_HOTSPOT */
case IDM_SETTOOL_RUBOUT:
{
IMG_SetTool(ghConv, 0, TOOL_RUBOUT);
break;
} /* case IDM_SETTOOL_RUBOUT */
case IDM_SETTOOL_ERASER:
{
IMG_SetTool(ghConv, 0, TOOL_ERASER);
break;
} /* case IDM_SETTOOL_ERASER */
case IDM_SETTOOL_SELECT:
{
IMG_SetTool(ghConv, 0, TOOL_SELECT);
break;
} /* case IDM_SETTOOL_SELECT */
case IDM_SETTOOL_MOVERESIZE:
{
IMG_SetTool(ghConv, 0, TOOL_MOVERESIZE);
break;
} /* case IDM_SETTOOL_MOVERESIZE */
case IDM_SETTOOL_ROTATE:
{
IMG_SetTool(ghConv, 0, TOOL_ROTATE);
break;
} /* case IDM_SETTOOL_ROTATE */
case IDM_SETTOOL_CHANGETEXT:
{
IMG_SetTool(ghConv, 0, TOOL_CHANGETEXT);
break;
} /* case IDM_SETTOOL_CHANGETEXT */
case IDM_SETTOOL_ARC:
{
IMG_SetTool(ghConv, 0, TOOL_ARC);
break;
} /* case IDM_SETTOOL_ARC */
case IDM_GETTOOL:
{
IMG_GetTool(ghConv, 0, NULL);
break;
} /* case IDM_GETTOL */
} /* switch (wparam) */
_DDE_DISCONNECT(ghConv);
} /* case WM_COMMAND */
case WM_SIZE:
{
hWndStatus = GetProp(hWnd, "Status Window Handle");
if (hWndStatus)
{
GetClientRect(hWnd, lpClientRect);
xsize = lpClientRect->right - lpClientRect->left;
hDC = GetDC(hWndStatus);
GetTextMetrics(hDC, lptm);
hFont = CreateFont(( lptm->tmHeight * 9 / 10 ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
if (hFont)
{
hFontOld = SelectObject(hDC, hFont);
} /* if (hFont) */
GetTextMetrics(hDC, lptm);
if (hFont)
{
SelectObject(hDC, hFontOld);
DeleteObject(hFont);
} /* if (hFont) */
StatusBarSize = ysize = (int)((float)lptm->tmHeight * 1.75);
ReleaseDC(hWndStatus, hDC);
xpos = 0;
ypos = lpClientRect->bottom - ysize;
if (IsWindow(hWndStatus))
{
MoveWindow(hWndStatus, xpos, ypos, xsize, ysize, TRUE);
ShowWindow(hWndStatus, SW_SHOW);
GetClientRect(hWndStatus, lpClientRect);
InvalidateRect(hWndStatus, lpClientRect, TRUE);
UpdateWindow(hWndStatus);
} /* if (IsWindow(hWndStatus)) */
prevxsize = 0;
GetClientRect(ghWndMain, lpClientRect);
y_size = lpClientRect->bottom - lpClientRect->top - (ysize + ribbon_width);
if (IsWindow(ghListBox))
{
prevxsize = xsize = (short)(ceil((lpClientRect->right - lpClientRect->left) * ratio) - HALF_MID_SIZE);
MoveWindow(ghListBox, lpClientRect->left, lpClientRect->top + ribbon_width, xsize, y_size, TRUE);
} /* if (IsWindow(ghListBox)) */
if (IsWindow(ghListBox2))
{
xsize = (short)(ceil((lpClientRect->right - lpClientRect->left) * (1.0 - ratio)) - HALF_MID_SIZE);
MoveWindow(ghListBox2, lpClientRect->left + prevxsize + MID_SIZE, lpClientRect->top + ribbon_width, xsize, y_size, TRUE);
} /* if (IsWindow(ghListBox2)) */
ShowWindow(hWndStatus, SW_SHOW);
GetClientRect(hWndStatus, lpClientRect);
InvalidateRect(hWndStatus, lpClientRect, TRUE);
UpdateWindow(hWndStatus);
} /* if (hWndStatus) */
break;
} /* case WM_SIZE */
case WM_DESTROY:
{
RemoveProp(hWnd, "Status Window Handle");
DdeFreeStringHandle(idInst, ghszTopic);
DdeFreeStringHandle(idInst, ghszItem);
DdeFreeStringHandle(idInst, ghszServer);
DdeFreeStringHandle(idInst, hszServerBase);
/* terminate all DDE conversations */
DdeUninitialize(idInst);
FreeProcInstance(lpfnDdeCallBack);
PostQuitMessage(0);
break;
} /* case WM_DESTROY */
} /* switch (msg)) */
return (DefWindowProc(hWnd, msg, wParam, lParam));
} /*** MainWndProc() ***/
/* ========================================= Parallax C Function ==================
@Name: WinMain
@Desc:
============================================================================== */
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
HWND FirsthWnd, FirstChildhWnd;
if (lpCmdLine) ;
/* Only one instance of the client can run, so we check to see */
/* if there is another one that is already running. If there */
/* is, then we bring it to the top and do not start the second */
/* instance. */
if ((FirsthWnd = FindWindow(szMainClass, NULL)) != NULL)
{
FirstChildhWnd = GetLastActivePopup(FirsthWnd);
BringWindowToTop(FirsthWnd);
if (FirsthWnd != FirstChildhWnd) BringWindowToTop(FirstChildhWnd);
return (FALSE);
} /* if ((FirsthWnd = FindWindow(szMainClass, NULL)) != NULL) */
if (!hPrevInstance && !InitApplication(hInstance)) return (FALSE);
if (!InitInstance(hInstance, nCmdShow)) return (FALSE);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} /* while (GetMessage(&msg, NULL, 0, 0)) */
return (msg.wParam);
} /* WinMain() */
#define CLOCK_TIMER 24
/* ========================================= Parallax C Function ==================
@Name: ClockProc
@Desc:
============================================================================== */
void CALLBACK ClockProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
char szBuffer[64];
#ifdef __TURBOC__
struct dostime_t time;
#else
#ifndef _WIN32
struct _dostime_t time;
#else
int i;
time_t time_value;
#endif
#endif
if (lParam) ;
switch (msg)
{
case WM_TIMER:
{
switch (wParam)
{
case CLOCK_TIMER:
{
KillTimer(hWnd, wParam);
#ifndef _WIN32
_dos_gettime(&time);
wsprintf(szBuffer, "%2.2d:%2.2d:%2.2d", time.hour, time.minute, time.second);
#else
time (&time_value) ;
strcpy (szBuffer, ctime (&time_value)) ;
for ( i = 0; szBuffer[i] > 0; i++ ) {
if ( szBuffer[i] < ' ' ) {
szBuffer[i] = 0;
}
}
#endif
SendMessage(hWnd, WM_COMMAND, 1, (LPARAM)((LPSTR)szBuffer));
SetTimer(hWnd, wParam, 1000, (TIMERPROC)ClockProc);
break;
} /* case CLOCK_TIMER */
default:
{
break;
} /* case default */
} /* switch (wParam) */
break;
} /* case WM_TIMER */
} /* switch (msg) */
} /* CallBack() */
/* ========================================= Parallax C Function ==================
@Name: StatusBarTextWndProc
@Desc:
============================================================================== */
long FAR PASCAL StatusBarTextWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
HGDIOBJ oldObj;
HPEN hPen;
RECT rect;
HFONT hFont;
HFONT hFontOld = (HFONT)0;
TEXTMETRIC tm;
TEXTMETRIC FAR *lptm = &tm;
HANDLE hCurText = NULL;
LPSTR currentText;
long style;
HANDLE hStyle;
LPLONG lpStyle;
switch (msg)
{
case WM_CREATE:
{
SetProp(hWnd, "Current Text", GlobalAlloc(GHND | GMEM_DDESHARE, 1024));
break;
} /* case WM_CREATE */
case WM_PAINT:
{
hDC = BeginPaint(hWnd, &ps);
hPen = CreatePen(PS_SOLID, 3, RGB(128, 128, 128));
oldObj = SelectObject(hDC, hPen);
GetClientRect(hWnd, &rect);
MoveTo(hDC, rect.left, rect.bottom);
LineTo(hDC, rect.left, rect.top);
LineTo(hDC, rect.right, rect.top);
SelectObject(hDC, oldObj);
DeleteObject(hPen);
hPen = CreatePen(PS_SOLID, 3, RGB(255, 255, 255));
SelectObject(hDC, hPen);
LineTo(hDC, rect.right, rect.bottom);
LineTo(hDC, rect.left, rect.bottom);
SelectObject(hDC, oldObj);
DeleteObject(hPen);
hCurText = GetProp(hWnd, "Current Text");
if (hCurText)
{
currentText = GlobalLock(hCurText);
if (lstrlen((LPSTR)currentText))
{
GetClientRect(hWnd, &rect);
InflateRect(&rect, -3, -3);
SetBkMode(hDC, TRANSPARENT);
GetTextMetrics(hDC, lptm);
hFont = CreateFont(( lptm->tmHeight * 9 / 10 ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
if (hFont)
{
hFontOld = SelectObject(hDC, hFont);
} /* if (hFont) */
hStyle = GetProp(hWnd, "Current Text Style");
if (hStyle)
{
lpStyle = (long far *)GlobalLock(hStyle);
style = *lpStyle;
GlobalUnlock(hStyle);
} else /* if (hStyle) */
{
style = DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER;
} /* if (hStyle) */
DrawText(hDC, (LPSTR)currentText, -1, &rect, (WORD)style);
if (hFont)
{
SelectObject(hDC, hFontOld);
DeleteObject(hFont);
} /* if (hFont) */
GlobalUnlock(hCurText);
} /* if (lstrlen((LPSTR)currentText)) */
} /* if (hCurText) */
EndPaint(hWnd, &ps);
break;
} /* case WM_PAINT */
case WM_COMMAND:
{
switch (wParam)
{
case 1:
{
hCurText = GetProp(hWnd, "Current Text");
if (hCurText)
{
currentText = GlobalLock(hCurText);
if (lstrlen((LPSTR)lParam))
{
lstrcpy((LPSTR)currentText, (LPSTR)lParam);
GetClientRect(hWnd, &rect);
InflateRect(&rect, -3, -3);
InvalidateRect(hWnd, &rect, TRUE);
UpdateWindow(hWnd);
GlobalUnlock(hCurText);
} /* if (lstrlen((LPSTR)lParam)) */
} /* if (hCurText) */
break;
} /* case 1*/
case 2:
{
hStyle = GlobalAlloc(GHND | GMEM_DDESHARE, sizeof(long));
lpStyle = (long far *)GlobalLock(hStyle);
*lpStyle = lParam;
GlobalUnlock(hStyle);
SetProp(hWnd, "Current Text Style", (HWND)hStyle);
break;
} /* case 2 */
default:
{
break;
} /* case default */
} /* switch (wParam) */
break;
} /* case WM_COMMAMD */
case WM_DESTROY:
{
hCurText = GetProp(hWnd, "Current Text");
GlobalFree(hCurText);
RemoveProp(hWnd, "Current Text");
hStyle = GetProp(hWnd, "Current Text Style");
if (hStyle)
{
GlobalFree(hStyle);
RemoveProp(hWnd, "Current Text Style");
} if (hStyle)
PostQuitMessage(0);
break;
} /* case WM_DESTROY */
} /* switch (msg) */
return (DefWindowProc(hWnd, msg, wParam, lParam));
} /* StatusBarTextWndProc */
/* ========================================= Parallax C Function ==================
@Name: StatusBarWndProc
@Desc:
============================================================================== */
long FAR PASCAL StatusBarWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
RECT ClientRect;
RECT *lpClientRect = &ClientRect;
RECT Rect;
RECT *lpRect = &Rect;
int xpos;
int ypos;
int xsize;
int ysize;
HWND hWndStatusButton = NULL;
HFONT hFont;
HFONT hFontOld = (HFONT)0;
TEXTMETRIC tm;
TEXTMETRIC FAR *lptm = &tm;
char szBuffer[64];
#ifdef __TURBOC__
struct dostime_t time;
#else
#ifndef _WIN32
struct _dostime_t time;
#else
time_t time_value ;
int i;
#endif
#endif
switch (msg)
{
case WM_CREATE:
{
GetClientRect(hWnd, lpClientRect);
CopyRect(lpRect, lpClientRect);
InflateRect(lpClientRect, -3, 0);
hDC = GetDC(hWnd);
GetTextMetrics(hDC, lptm);
hFont = CreateFont(( lptm->tmHeight * 9 / 10 ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
if (hFont)
{
hFontOld = SelectObject(hDC, hFont);
} /* if (hFont) */
xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.6);
if (hFont)
{
SelectObject(hDC, hFontOld);
DeleteObject(hFont);
} /* if (hFont) */
ysize = (int)((float)lpClientRect->bottom * 0.875);
ReleaseDC(hWnd, hDC);
xpos = 3;
ypos = lpRect->bottom / 16;
hWndStatusButton = CreateWindow(szStatusBarTextClass,
NULL,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE ,
xpos, ypos,
xsize, ysize,
hWnd, NULL, ghInst, NULL);
if (hWndStatusButton)
{
ShowWindow(hWndStatusButton, SW_SHOW);
SetProp(hWnd, "Status Window Text Handle", hWndStatusButton);
} /* if (hWndStatusButton) */
GetClientRect(hWnd, lpClientRect);
CopyRect(lpRect, lpClientRect);
InflateRect(lpClientRect, -3, 0);
xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.35);
hDC = GetDC(hWnd);
ReleaseDC(hWnd, hDC);
xpos = (int)((float)lpRect->right - xsize - 3);
hWndStatusButton = CreateWindow(szStatusBarTextClass,
NULL,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE ,
xpos, ypos,
xsize, ysize,
hWnd, NULL, ghInst, NULL);
if (hWndStatusButton)
{
ShowWindow(hWndStatusButton, SW_SHOW);
SetProp(hWnd, "Status Window Clock Handle", hWndStatusButton);
#ifndef _WIN32
_dos_gettime(&time);
wsprintf(szBuffer, "%2.2d:%2.2d:%2.2d", time.hour, time.minute, time.second);
#else
time (&time_value) ;
strcpy (szBuffer, ctime (&time_value)) ;
for ( i = 0; szBuffer[i] > 0; i++ ) {
if ( szBuffer[i] < ' ' ) {
szBuffer[i] = 0;
}
}
#endif
SendMessage(hWndStatusButton, WM_COMMAND, 2, (LPARAM)(DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER));
SendMessage(hWndStatusButton, WM_COMMAND, 1, (LPARAM)((LPSTR)szBuffer));
SetTimer(hWndStatusButton, CLOCK_TIMER, 1000, (TIMERPROC)ClockProc);
} /* if (hWndStatusButton) */
break;
} /* case WM_CREATE */
case WM_SIZE:
{
hWndStatusButton = GetProp(hWnd, "Status Window Text Handle");
if (hWndStatusButton)
{
GetClientRect(hWnd, lpClientRect);
CopyRect(lpRect, lpClientRect);
InflateRect(lpClientRect, -3, 0);
xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.6);
hDC = GetDC(hWnd);
ysize = (int)((float)lpClientRect->bottom * 0.875);
ReleaseDC(hWnd, hDC);
xpos = 3;
ypos = lpRect->bottom / 16;
MoveWindow(hWndStatusButton, xpos, ypos, xsize, ysize, TRUE);
ShowWindow(hWndStatusButton, SW_SHOW);
GetClientRect(hWndStatusButton, lpClientRect);
InvalidateRect(hWndStatusButton, lpClientRect, TRUE);
UpdateWindow(hWndStatusButton);
} /* if (hWndStatusButton) */
hWndStatusButton = GetProp(hWnd, "Status Window Clock Handle");
if (hWndStatusButton)
{
GetClientRect(hWnd, lpClientRect);
CopyRect(lpRect, lpClientRect);
InflateRect(lpClientRect, -3, 0);
hDC = GetDC(hWnd);
xsize = (int)((float)(lpClientRect->right - lpClientRect->left) * 0.35);
ysize = (int)((float)lpClientRect->bottom * 0.875);
ReleaseDC(hWnd, hDC);
xpos = (int)((float)lpRect->right - xsize - 3);
ypos = lpRect->bottom / 16;
MoveWindow(hWndStatusButton, xpos, ypos, xsize, ysize, TRUE);
ShowWindow(hWndStatusButton, SW_SHOW);
GetClientRect(hWndStatusButton, lpClientRect);
InvalidateRect(hWndStatusButton, lpClientRect, TRUE);
UpdateWindow(hWndStatusButton);
} /* if (hWndStatusButton) */
break;
} /* case WM_SIZE */
case WM_DESTROY:
{
RemoveProp(hWnd, "Status Window Text Handle");
RemoveProp(hWnd, "Status Window Clock Handle");
PostQuitMessage(0);
break;
} /* case WM_DESTROY */
} /* switch (msg) */
return (DefWindowProc(hWnd, msg, wParam, lParam));
} /* StatusBarWndProc() */
void STS_Message(HWND hWnd, LPSTR msg)
{
HWND hWndStatus = GetProp(hWnd, "Status Window Handle");
HWND hWndStatusButton = NULL;
if (hWndStatus)
{
hWndStatusButton = GetProp(hWndStatus, "Status Window Text Handle");
SendMessage(hWndStatusButton, WM_COMMAND, 1, (LPARAM)msg);
} /* if (hWndStatus) */
return;
} /* STS_Message() */
/* DDE_TEST.C */
/* end of file */