home *** CD-ROM | disk | FTP | other *** search
Wrap
/*-------------------------- Parallax Standard C_File ---------------------------- C_File: utdde.c Purpose: This file contains the C-interface for all Eroica's DDE functions. -------------------------------------------------------------------------------- Copyright (c)1996 Parallax Software , All rights reserved. ------------------------------------------------------------------------------*/ #include "dde_test.h" #include <windows.h> #include <string.h> #include <stdio.h> #include <ddeml.h> #include "utdde.h" #include <stdlib.h> #include <malloc.h> static DWORD IMG_Execute(HCONV ghConv, void FAR *szBuffer, WORD size, HDDEDATA* hData); static DWORD IMG_Request(HCONV ghConv, void FAR *szBuffer, HDDEDATA* hData); static int IMG_GetData(HDDEDATA hData, char FAR* pData, int n) ; char nulltitle[] = " "; #define SYNCTIMEOUT 120000L #define PARMSIZE 120 #define STARTUP_PATH "C:\\EROICA\\OTHER\\PICTUREZ\\" /* ================ */ /* global variables */ /* ================ */ HWND hViewWnd = NULL; static char pDdeErrMsg[] = "*Error - call failed."; extern void STS_Message(HWND, LPSTR); /* 970224 jk add redefinitions of far string functions */ #ifdef _WIN32 static char *_fstrncpy(char *string1, const char *string2, size_t count) { return strncpy(string1, string2, count) ; } static char *_fstrcpy(char *string1, const char *string2) { return strcpy(string1, string2); } #endif /* 970224 jk end */ /* ========================================= Parallax C Function ================== @Name: _GetDocWin @Desc: ============================================================================== */ int _GetDocWin(HCONV ghConv, char bMessage) { DOCWINID hViewWnd = 0; HDDEDATA hData = NULL; DWORD result; DWORD buf_size; #ifdef __BORLANDC__ LPSTR img_buf; #else PSTR img_buf; #endif int ret = FALSE; HSZ hszString; if (ghConv == NULL) goto cleanup; hszString = DdeCreateStringHandle(idInst, (LPSTR)"GETDOCWIN", CP_WINANSI); hData = DdeClientTransaction(NULL, 0, ghConv, hszString, CF_TEXT, XTYP_REQUEST, 3000, (DWORD FAR *)&result); DdeFreeStringHandle(idInst, hszString); if (hData) { buf_size = DdeGetData(hData, NULL, 0, 0L); buf_size++; img_buf = malloc((WORD)buf_size); if (img_buf) { if (DdeGetData(hData, (LPSTR)img_buf, buf_size, 0L)) { sscanf(img_buf, "%d", &hViewWnd); ret = (int)hViewWnd; } /* if (DdeGetData(hData, (LPSTR)img_buf, buf_size, 0L)) */ free(img_buf); } /* if (img_buf) */ DdeFreeDataHandle(hData); } /* if (hData) */ cleanup: if ((!ret) && (bMessage == TRUE)) { _MSG("**No active window."); } /* if (!ret) */ return (ret); } /* _GetDocWin() */ /* ========================================= Parallax C Function ================== @Name: _GetActiveEditLayer @Desc: ============================================================================== */ LAYERID _GetActiveEditLayer(HCONV ghConv, DOCWINID docWinID) { HDDEDATA hData; char szBuffer[256]; LAYERID ret = 0; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, FALSE); } /* if (!docWinId) */ if (!docWinID) return (0); wsprintf(szBuffer, "[GETACTIVELAYER(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 2); if (igd == 2) { LAYERID tmp; sscanf(&pData[PARMSIZE*1], "%d", &tmp); ret = tmp; } /* if (igd == 2) */ } /* if (hData) */ cleanup: return (ret); } /* _GetActiveEditLayer() */ /* ========================================= Parallax C Function ================== @Name: img_ATOI @Desc: ============================================================================== */ int img_ATOI(LPSTR inStr) { static char staticStr[21]; _fstrncpy((LPSTR)staticStr, inStr, 20); return (atoi(staticStr)); } /* img_ATOI() */ /* ========================================= Parallax C Function ================== @Name: img_ATOF @Desc: ============================================================================== */ float img_ATOF(LPSTR inStr) { static char staticStr[21]; _fstrncpy((LPSTR)staticStr, inStr, 20); return ((float)atof(staticStr)); } /* img_ATOF() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetData @Desc: ============================================================================== */ static int IMG_GetData(HDDEDATA hData, char FAR* pData, int n) { DWORD buf_size; char pBuf[2000]; char* pTmp0; char* pTmp1; int i = 0; if (hData > (HDDEDATA)1) { buf_size = DdeGetData(hData, (void FAR *)NULL, 0, 0L); buf_size++; DdeGetData(hData, pBuf, buf_size, 0L); i = 0; pTmp0 = (char*)pBuf; pTmp1 = strchr(pTmp0, ','); while (pTmp1 != NULL && (i+1) < n) { *pTmp1 = 0; lstrcpyn (&pData[PARMSIZE*i], (LPSTR)pTmp0, PARMSIZE); pTmp0 = pTmp1+1; pTmp1 = strchr(pTmp0, ','); i++; } /* while (pTmp1 != NULL && (i+1) < n) */ lstrcpyn (&pData[PARMSIZE*i], (LPSTR)pTmp0, PARMSIZE); i++; DdeFreeDataHandle(hData); } /* if (hData > (HDDEDATA)1) */ return (i); } /* IMG_GetData() */ /* ========================================= Parallax C Function ================== @Name: IMG_Execute @Desc: ============================================================================== */ static DWORD IMG_Execute(HCONV ghConv, void FAR *szBuffer, WORD size, HDDEDATA* hData) { HDDEDATA hTmp; DWORD result = 0; STS_Message(ghWndMain, (LPSTR)szBuffer); hTmp = DdeClientTransaction(szBuffer, size, ghConv, NULL, CF_TEXT, XTYP_EXECUTE, SYNCTIMEOUT, &result); if (hData!=0) *hData = hTmp; return (result); } /* IMG_Execute() */ /* ========================================= Parallax C Function ================== @Name: IMG_Request @Desc: ============================================================================== */ static DWORD IMG_Request(HCONV ghConv, void FAR *szBuffer, HDDEDATA* hData) { DWORD result = 0; HSZ hszString; HDDEDATA hTmp; STS_Message(ghWndMain, (LPSTR)szBuffer); hszString = DdeCreateStringHandle(idInst, (LPSTR)szBuffer, CP_WINANSI); hTmp = DdeClientTransaction(NULL, 0, ghConv, hszString, CF_TEXT, XTYP_REQUEST, SYNCTIMEOUT, (DWORD FAR *)&result); if (hData!=0) *hData = hTmp; DdeFreeStringHandle(idInst, hszString); return (result); } /* IMG_Request() */ /* ========================================= Parallax C Function ================== @Name: IMG_Advise @Desc: ============================================================================== */ static DWORD IMG_Advise(HCONV ghConv, void FAR *szBuffer, HDDEDATA* hData) { DWORD result = 0; HSZ hszString; HDDEDATA hTmp; STS_Message(ghWndMain, (LPSTR)szBuffer); hszString = DdeCreateStringHandle(idInst, (LPSTR)szBuffer, CP_WINANSI); hTmp = DdeClientTransaction(NULL, 0, ghConv, hszString, CF_TEXT, XTYP_ADVSTART, SYNCTIMEOUT, (DWORD FAR *)&result); if (hData!=0) *hData = hTmp; DdeFreeStringHandle(idInst, hszString); return (result); } /* IMG_Advise */ /* ========================================= Parallax C Function ================== @Name: IMG_AdviseStop @Desc: ============================================================================== */ static DWORD IMG_AdviseStop(HCONV ghConv, void FAR *szBuffer, HDDEDATA* hData) { DWORD result = 0; HSZ hszString; HDDEDATA hTmp; STS_Message(ghWndMain, (LPSTR)szBuffer); hszString = DdeCreateStringHandle(idInst, (LPSTR)szBuffer, CP_WINANSI); hTmp = DdeClientTransaction(NULL, 0, ghConv, hszString, CF_TEXT, XTYP_ADVSTOP, SYNCTIMEOUT, (DWORD FAR *)&result); if (hData!=0) *hData = hTmp; DdeFreeStringHandle(idInst, hszString); return (result); } /* IMG_AdviseStop */ /* ========================================= Parallax C Function ================== @Name: IMG_Connect @Desc: ============================================================================== */ HCONV IMG_Connect(HWND ghWndMain, DWORD idInst, HSZ hszServer, HSZ ghszTopic) { HCONV ghConv = NULL; static char IMG_Connect_szBuffer[256]; WORD wError; if ( ghWndMain ); ghConv = DdeConnect(idInst, hszServer, ghszTopic, (LPVOID)NULL); if (!ghConv) { wError = (WORD)DdeGetLastError(idInst); /* removed by Cerda wsprintf((LPSTR)IMG_Connect_szBuffer, (LPSTR)"Error - DDE Connect failed. Error #%#0x.", wError); STS_Message((HWND)ghWndMain, (LPSTR)IMG_Connect_szBuffer); */ _FMTMSG( "**Err #%#0x - DDE Connect failed.", wError); _MSG( "Check if EROICA.EXE is running." ); } /* if (!ghConv) */ return (ghConv); } /* IMG_Connect() */ /* ========================================= Parallax C Function ================== @Name: IMG_StartUp @Desc: ============================================================================== */ int IMG_StartUp(HCONV ghConv) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[OPENDOCWIN(0, 0, \"" STARTUP_PATH "16cx.tif\", \"16cx (TIF)\", 10, 0, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[OPENDOCWIN(0, 0, \"" STARTUP_PATH "256cx.tif\", \"256cx (TIF)\", 10, 0, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[OPENDOCWIN(0, 0, \"" STARTUP_PATH "16mcx.tif\", \"16mcx (TIF)\", 10, 0, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[OPENDOCWIN(0, 0, \"" STARTUP_PATH "edit16.clf\", \"edit16 (CLF)\", 10, 0, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[OPENDOCWIN(0, 0, \"" STARTUP_PATH "edit256.clf\", \"edit256 (CLF)\", 10, 0, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[OPENDOCWIN(0, 0, \"" STARTUP_PATH "edit16m.clf\", \"edit16m (CLF)\", 10, 0, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[ARRANGEDOCWINS(1)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); wsprintf(szBuffer, "[SETDOCWIN(5, 0)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); /* window 5 layer 2 - FullEdit */ wsprintf(szBuffer, "[SETACTIVELAYER(5, 1030, 1)]"); size = (WORD)(lstrlen(szBuffer) + 1); IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL); ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (TRUE); } /* IMG_StartUp() */ /* ========================================= Parallax C Function ================== @Name: IMG_RasterDPIChange @Desc: ============================================================================== */ int IMG_RasterDPIChange(HCONV ghConv, int xres, int yres) { char szBuffer[256]; WORD size; int ret = FALSE; HCONV ghConvLoc = ghConv; if (ghConv == NULL) goto cleanup; if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) { _MSG("No open document. Cannot change Raster DPI."); ret = TRUE; } else /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ { _FMTMSG2("Raster DPI change to %d x %d.", xres, yres); wsprintf(szBuffer, "[CHANGERASTER(0, 0, %d, %d, 0, 0, 0)]", xres, yres); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_RasterDPIChange() */ /* ========================================= Parallax C Function ================== @Name: IMG_ArrangeDocWins @Desc: ============================================================================== */ int IMG_ArrangeDocWins(HCONV ghConv, int arrangement) { char szBuffer[256]; WORD size; int ret = FALSE; HCONV ghConvLoc = ghConv; if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) { _MSG("No open windows. Nothing to arrange."); ret = TRUE; } else /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ { switch (arrangement) { case ARRANGE_TILE: { _MSG("Arrange windows by tiling."); break; } /* case ARRANGE_TILE */ case ARRANGE_CASCADE: { _MSG("Arrange windows by cascading."); break; } /* case ARRANGE_CASCADE */ case ARRANGE_HORZSTRIP: { _MSG("Arrange windows by horizontal strips."); break; } /* case ARRANGE_HORSTRIP */ case ARRANGE_VERTSTRIP: { _MSG("Arrange windows by vertical strips."); break; } /* case ARRANGE_HORSTRIP */ default: { _FMTMSG("Arrange windows by %d.", arrangement); break; } /* case default */ } /* switch (arrangement) */ if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[ARRANGEDOCWINS(%d)]", arrangement); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_ArrangeDocWins() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyHotSpot @Desc: ============================================================================== */ int IMG_NotifyHotSpot(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Notify of HotSpot Activation."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- HotSpotActivated"); if (IMG_Advise(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyHotSpot() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyHotSpotPlaced @Desc: ============================================================================== */ int IMG_NotifyHotSpotPlaced(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Notify of HotSpot Placement."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- HotSpotPlaced"); if (IMG_Advise(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyHotSpotPlaced() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyHotSpotHighlighted @Desc: ============================================================================== */ int IMG_NotifyHotSpotHighlighted(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Notify of HotSpot Highlight."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- HotSpotHighlighted"); if (IMG_Advise(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyHotSpotHighlighted() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyApi @Desc: ============================================================================== */ int IMG_NotifyApi(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Notify of API Use."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- API In Use"); if (IMG_Advise(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyApi() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyHotSpotPlacedStop @Desc: ============================================================================== */ int IMG_NotifyHotSpotPlacedStop(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Stop Notification of HotSpot Placement."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- HotSpotPlaced"); if (IMG_AdviseStop(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyHotSpotPlacedStop() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyHotSpotHighlightedStop @Desc: ============================================================================== */ int IMG_NotifyHotSpotHighlightedStop(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Stop Notification of HotSpot Highlight."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- HotSpotHighlighted"); if (IMG_AdviseStop(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyHotSpotHighlightedStop() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyHotSpotStop @Desc: ============================================================================== */ int IMG_NotifyHotSpotStop(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Stop Notification of HotSpot Activation."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- HotSpotActivated"); if (IMG_AdviseStop(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyHotSpotStop() */ /* ========================================= Parallax C Function ================== @Name: IMG_NotifyApiStop @Desc: ============================================================================== */ int IMG_NotifyApiStop(HCONV ghConv) { char szBuffer[256]; int ret = FALSE; _MSG("Stop Notification of API Use."); if (ghConv == NULL) goto cleanup; lstrcpy(szBuffer, "NotifyIM -- API In Use"); if (IMG_AdviseStop(ghConv, (void FAR*)szBuffer, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NotifyApiStop() */ /* ========================================= Parallax C Function ================== @Name: IMG_Checkin @Desc: ============================================================================== */ int IMG_Checkin(HCONV ghConv, DOCWINID docWinID, BOOL bClose) { char szBuffer[256]; WORD size; int ret = FALSE; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (bClose) { _FMTMSG("Checkin and close docWinID %d.", docWinID); } else /* if (bClose) */ { _FMTMSG("Checkin docWinID %d.", docWinID); } /* if (bClose) */ if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[CHECKIN(%d,%d)]", docWinID, bClose); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Checkin() */ /* ========================================= Parallax C Function ================== @Name: IMG_CheckinAll @Desc: ============================================================================== */ int IMG_CheckinAll(HCONV ghConv, BOOL bClose) { char szBuffer[256]; WORD size; int ret = FALSE; if (bClose) { _MSG("Checkin and close all docWins."); } else /* if (bClose) */ { _MSG("Checkin all docWins"); } /* if (bClose) */ if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[CHECKINALL(%d)]", bClose); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_CheckinAll() */ /* ========================================= Parallax C Function ================== @Name: IMG_CloseAllDocWin @Desc: ============================================================================== */ int IMG_CloseAllDocWin(HCONV ghConv, BOOL bSave) { char szBuffer[256]; WORD size; int ret = FALSE; HCONV ghConvLoc = ghConv; if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) { _MSG("No open windows. Nothing to close."); ret = TRUE; } else /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ { if (bSave) { _MSG("Save and close all docWins"); } else /* if (bSave) */ { _MSG("Close all docWins"); } /* if (bSave) */ if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[CLOSEALLDOCWIN(%d)]", bSave); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_CloseAllDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_CloseDocWin @Desc: ============================================================================== */ int IMG_CloseDocWin(HCONV ghConv, DOCWINID docWinID, BOOL bSave) { char szBuffer[256]; WORD size; int ret = FALSE; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (bSave) { _FMTMSG("Save and close docWinID %d.", docWinID); } else /* if (bSave) */ { _FMTMSG("Close docWinID %d.", docWinID); } /* if (bSave) */ if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[CLOSEDOCWIN(%d,%d)]", docWinID, bSave); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_CloseDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_CreateDocWin @Desc: ============================================================================== */ int IMG_CreateDocWin(HCONV ghConv, void FAR* title, DOCWINID FAR* docWinID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (title == NULL) title = (void FAR*)nulltitle; _FMTMSG("Create docWin with title \"%s\".", title); if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[CREATEDOCWIN (\"%s\")]", (LPSTR)title); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp = 0; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (docWinID) *docWinID = tmp; _FMTMSG(" Created docWinID %d.", tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_CreateDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_DeleteLayer @Desc: ============================================================================== */ int IMG_DeleteLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID) { char szBuffer[256]; WORD size; int ret = FALSE; _FMTMSG2("Delete layerID %d of docWin %d.", layerID, docWinID); if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[DELETELAYER(%d,%d)]", docWinID, layerID); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_DeleteLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_EndEroica @Desc: ============================================================================== */ int IMG_EndEroica(HCONV ghConv) { char szBuffer[256]; WORD size; int ret = FALSE; _MSG("End program."); if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[ENDFRAME]"); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_EndEroica() */ /* ========================================= Parallax C Function ================== @Name: IMG_ExportLayer @Desc: ============================================================================== */ int IMG_ExportLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, BOOL bSaveAs, void FAR* fname, void FAR* title, BOOL bOverwrite) { char szBuffer[256]; WORD size; int ret = FALSE; if (title == NULL) title=(void FAR*)nulltitle; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG2("Export layerID %d of docWin %d.", layerID, docWinID); _FMTMSG( " Layer Title = \"%s\".", title); if (bSaveAs) { _MSG( " SaveAs = Yes."); } else /* if (bSaveAs) */ { _MSG( " SaveAs = No."); } /* if (bSaveAs) */ if (fname == NULL) goto cleanup; _FMTMSG( " Filename = \"%s\".", fname); if (bOverwrite) { _MSG( " Overwrite = Yes."); } else /* if (bOverwrite) */ { _MSG( " Overwrite = No."); } /* if (bOverwrite) */ /* if (bSaveAs) */ if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[EXPORTLAYER(%d,%d,%d,\"%s\",\"%s\",%d,0,0)]", docWinID, layerID, bSaveAs, (LPSTR)fname, (LPSTR)title, bOverwrite); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_ExportLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetActiveEditLayer @Desc: ============================================================================== */ int IMG_GetActiveEditLayer(HCONV ghConv, DOCWINID docWinID, LAYERID FAR* layerID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinId) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETACTIVELAYER(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 2); if (igd == 2) { LAYERID tmp; sscanf(&pData[PARMSIZE*1], "%d", &tmp); if (layerID) *layerID = tmp; if (tmp == 0) { _FMTMSG("No active edit layer for docWinID %d.", docWinID); } else /* if (tmp == 0) */ { _FMTMSG2("Active edit layerID is %d for docWinID %d.", tmp, docWinID); } /* if (tmp == 0) */ ret = TRUE; } /* if (igd == 2) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetActiveEditLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetActiveRasterLayer @Desc: ============================================================================== */ int IMG_GetActiveRasterLayer(HCONV ghConv, DOCWINID docWinID, LAYERID FAR* layerID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETACTIVELAYER(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 2); if (igd == 2) { LAYERID tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (layerID) *layerID = tmp; if (tmp == 0) { _FMTMSG("No active raster layer for docWinID %d.", docWinID); } else /* if (tmp == 0) */ { _FMTMSG2("Active raster layerID is %d for docWinID %d.", tmp, docWinID); } /* if (tmp == 0) */ ret = TRUE; } /* if (igd == 2) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetActiveRasterLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetDisplayLayer @Desc: ============================================================================== */ int IMG_GetDisplayLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, BOOL FAR* bDisplay) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETDISPLAYLAYER(%d,%d)]", docWinID, layerID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (bDisplay) *bDisplay = tmp; if (tmp) { _FMTMSG2("LayerID %d of docWin %d is displayed.", layerID, docWinID); } else /* if (tmp) */ { _FMTMSG2("LayerID %d of docWin %d is NOT displayed.", layerID, docWinID); } /* if (tmp) */ ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetDisplayLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetDocumentDirtyStatus @Desc: ============================================================================== */ int IMG_GetDocumentDirtyStatus(HCONV ghConv, DOCWINID docWinID, int FAR* status) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETDOCUMENTDIRTYSTATUS(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (status) *status = tmp; _FMTMSG2("docWinID %d has dirty status 0x%x.", docWinID, tmp); strcpy(szBuffer, " -->"); if (tmp & 0x01) strcpy(&szBuffer[strlen(szBuffer)], "CLEAN "); if (tmp & 0x02) strcpy(&szBuffer[strlen(szBuffer)], "MODIFIED "); if (tmp & 0x04) strcpy(&szBuffer[strlen(szBuffer)], "DELETED "); if (tmp & 0x08) strcpy(&szBuffer[strlen(szBuffer)], "NEW "); if (tmp & 0x10) strcpy(&szBuffer[strlen(szBuffer)], "DBI_MOD "); if (tmp & 0x20) strcpy(&szBuffer[strlen(szBuffer)], "DBI_NEW "); if (tmp & 0x40) strcpy(&szBuffer[strlen(szBuffer)], "DBI_OPEN "); _MSG(szBuffer); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetDocumentDirtyStatus() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetDocumentTitle @Desc: ============================================================================== */ int IMG_GetDocumentTitle(HCONV ghConv, DOCWINID docWinID, char FAR* title) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETDOCUMENTTITLE(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { if (title) IMG_GetData(hData, title, 1); _FMTMSG2("DocWinID %d has title \"%s\".", docWinID, title); ret = TRUE; } cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetDocumentTitle() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetDocWin @Desc: ============================================================================== */ int IMG_GetDocWin(HCONV ghConv, DOCWINID FAR* docWinID) { DOCWINID hViewWnd = 0; HDDEDATA hData = NULL; DWORD result; DWORD buf_size; #ifdef __BORLANDC__ LPSTR img_buf; #else PSTR img_buf; #endif int ret = FALSE; HSZ hszString; if (ghConv == NULL) goto cleanup; hszString = DdeCreateStringHandle(idInst, (LPSTR)"GETDOCWIN", CP_WINANSI); hData = DdeClientTransaction(NULL, 0, ghConv, hszString, CF_TEXT, XTYP_REQUEST, 3000, (DWORD FAR *)&result); DdeFreeStringHandle(idInst, hszString); if (hData) { buf_size = DdeGetData(hData, NULL, 0, 0L); buf_size++; img_buf = malloc((WORD)buf_size); if (img_buf) { if (DdeGetData(hData, (LPSTR)img_buf, buf_size, 0L)) { sscanf(img_buf, "%d", &hViewWnd); if (docWinID) *docWinID = hViewWnd; _FMTMSG((LPSTR)"Active docWinID is %d.", (int)hViewWnd); } /* if (DdeGetData(hData, (LPSTR)img_buf, buf_size, 0L)) */ free(img_buf); ret = TRUE; } /* if (img_buf) */ DdeFreeDataHandle(hData); } else /* if (hData) */ { ret = TRUE; _MSG("No active docWin."); } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetLayerDirtyStatus @Desc: ============================================================================== */ int IMG_GetLayerDirtyStatus(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, int FAR* status) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETLAYERDIRTYSTATUS(%d,%d)]", docWinID, layerID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (status) *status = tmp; _FMTMSG3("LayerID %d of docWin %d has status 0x%x.", layerID, docWinID, tmp); strcpy(szBuffer, " -->"); if (tmp & 0x01) strcpy(&szBuffer[strlen(szBuffer)], "CLEAN "); if (tmp & 0x02) strcpy(&szBuffer[strlen(szBuffer)], "MODIFIED "); if (tmp & 0x04) strcpy(&szBuffer[strlen(szBuffer)], "DELETED "); if (tmp & 0x08) strcpy(&szBuffer[strlen(szBuffer)], "NEW "); if (tmp & 0x10) strcpy(&szBuffer[strlen(szBuffer)], "DBI_MOD "); if (tmp & 0x20) strcpy(&szBuffer[strlen(szBuffer)], "DBI_NEW "); if (tmp & 0x40) strcpy(&szBuffer[strlen(szBuffer)], "DBI_OPEN "); _MSG(szBuffer); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetLayerDirtyStatus() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetLayerFormat @Desc: ============================================================================== */ int IMG_GetLayerFormat(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, int FAR* format) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETLAYERFORMAT(%d,%d)]", docWinID, layerID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (format) *format = tmp; switch (tmp) { case 0: { _FMTMSG2("LayerID %d of docWin %d is an UNKNOWN layer.", layerID, docWinID); break; } /* case 0 */ case 1: { _FMTMSG2("LayerID %d of docWin %d is an edit layer.", layerID, docWinID); break; } /* case 1 */ case 2: { _FMTMSG2("LayerID %d of docWin %d is a raster layer.", layerID, docWinID); break; } /* case 2 */ case 3: { _FMTMSG2("LayerID %d of docWin %d is a text layer.", layerID, docWinID); break; } /* case 3 */ default: { _FMTMSG2("LayerID %d of docWin %d is of an ???unrecognized??? type.", layerID, docWinID); break; } /* case default */ } /* switch (tmp) */ ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetLayerFormat() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetLayerFormatList @Desc: ============================================================================== */ int IMG_GetLayerFormatList(HCONV ghConv) { int ret = FALSE; HDDEDATA hData; char szBuffer[256]; int dflt, count; int max=50; int maxent=max*3+2; char pDataArea[PARMSIZE * (50*3+2) ]; char* pData; if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[GETLAYERFORMATLIST(2)]"); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { int i,j; BOOL bDefaultFound = FALSE; pData = pDataArea; j = IMG_GetData(hData, (char FAR*)pData, maxent); sscanf(pData, "%d", &count); pData += PARMSIZE; if (count > max) count=max; j = (j-2)/3; if (count > j) count=j; sscanf(pData, "%d", &dflt); pData += PARMSIZE; for (i=0; i<count; i++) { int id; char szExt[5]; char szDesc[50]; lstrcpyn (szExt, pData, sizeof(szExt)); pData += PARMSIZE; lstrcpyn (szDesc, pData, sizeof(szDesc)); pData += PARMSIZE; id = img_ATOI(pData); pData += PARMSIZE; if (i == dflt) { _FMTMSG3(" * %3.3d (%3.3s) -- %s", id, szExt, szDesc); bDefaultFound = TRUE; } else /* if (i == dflt) */ { _FMTMSG3(" %3.3d (%3.3s) -- %s", id, szExt, szDesc); } /* if (i == dflt) */ } /* for (i=0; i<count; i++) */ /* either default format is found or we read more entries than sent */ ret = bDefaultFound || ( count == max ); } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetLayerFormatList() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetLayerIDs @Desc: ============================================================================== */ int IMG_GetLayerIDs(HCONV ghConv, DOCWINID docWinID, LAYERID FAR* pLayers, int max, int FAR* count) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETLAYERIDS(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { int i; char * pData; pData = (char*) malloc(PARMSIZE * (max+1)); IMG_GetData(hData, (char FAR*)pData, max+1); sscanf(&pData[PARMSIZE*0], "%d", count); if (*count > max) *count=max; for (i=0; i<*count; i++) { int tmp; sscanf(&pData[PARMSIZE*(i+1)], "%d", &tmp); pLayers[i] = tmp; } /* for (i=0; i<*count; i++) */ free(pData); ret = TRUE; } cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetLayerIDs() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetLayerTitle @Desc: ============================================================================== */ int IMG_GetLayerTitle(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, char FAR* title) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETLAYERTITLE(%d,%d)]", docWinID, layerID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { IMG_GetData(hData, title, 1); _FMTMSG3("LayerID %d of docWin %d has title \"%s\".", layerID, docWinID, title); ret = TRUE; } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetLayerTitle() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetNumberDocWins @Desc: ============================================================================== */ int IMG_GetNumberDocWins(HCONV ghConv, int FAR* count) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[GETNUMBERDOCWINS]"); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (count) *count = tmp; _FMTMSG("Number of docWins is %d.", tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetNumberDocWins() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetNumberLayers @Desc: ============================================================================== */ int IMG_GetNumberLayers(HCONV ghConv, DOCWINID docWinID, int FAR* count) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETNUMBERLAYERS(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd = 0; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (count) *count = tmp; _FMTMSG2("DocWinID %d has %d layers.", docWinID, tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetNumberLayers() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetTool @Desc: ============================================================================== */ int IMG_GetTool(HCONV ghConv, DOCWINID docWinID, int FAR* tooltype) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (!_GetActiveEditLayer(ghConv, docWinID)) { _MSG("No active edit layer. No tool could be active."); ret = TRUE; } else /* if (!_GetActiveEditLayer(ghConv, docWinID)) */ { wsprintf(szBuffer, "[GETTOOL(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd = 0; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (tooltype) *tooltype = tmp; switch (tmp) { case TOOL_NONE: { _FMTMSG("No Active tool for docWinID %d.", docWinID); break; } /* case TOOL_NONE */ case TOOL_CUT: { _FMTMSG("Active tool is CUT for docWinID %d.", docWinID); break; } /* case TOOL_CUT */ case TOOL_COPY: { _FMTMSG("Active tool is COPY for docWinID %d.", docWinID); break; } /* case TOOL_COPY */ case TOOL_PASTE: { _FMTMSG("Active tool is PASTE for docWinID %d.", docWinID); break; } /* case TOOL_PASTE */ case TOOL_LINE: { _FMTMSG("Active tool is LINE for docWinID %d.", docWinID); break; } /* case TOOL_LINE */ case TOOL_BOX: { _FMTMSG("Active tool is BOX for docWinID %d.", docWinID); break; } /* case TOOL_BOX */ case TOOL_CIRCLE: { _FMTMSG("Active tool is CIRCLE for docWinID %d.", docWinID); break; } /* case TOOL_CIRCLE */ case TOOL_ELLIPSE: { _FMTMSG("Active tool is ELLIPSE for docWinID %d.", docWinID); break; } /* case TOOL_ELLIPSE */ case TOOL_ARROW: { _FMTMSG("Active tool is ARROW for docWinID %d.", docWinID); break; } /* case TOOL_ARROW */ case TOOL_SKETCH: { _FMTMSG("Active tool is SKETCH for docWinID %d.", docWinID); break; } /* case TOOL_SKETCH */ case TOOL_POLYLINE: { _FMTMSG("Active tool is POLYLINE for docWinID %d.", docWinID); break; } /* case TOOL_POLYLINE */ case TOOL_POLYGON: { _FMTMSG("Active tool is POLYGON for docWinID %d.", docWinID); break; } /* case TOOL_POLYGON */ case TOOL_TEXT: { _FMTMSG("Active tool is TEXT for docWinID %d.", docWinID); break; } /* case TOOL_TEXT */ case TOOL_ANNOTATION: { _FMTMSG("Active tool is ANNOTATION for docWinID %d.", docWinID); break; } /* case TOOL_ANNOTATION */ case TOOL_DIMENSION: { _FMTMSG("Active tool is DIMENSION for docWinID %d.", docWinID); break; } /* case TOOL_DIMENSION */ case TOOL_SYMBOL: { _FMTMSG("Active tool is SYMBOL for docWinID %d.", docWinID); break; } /* case TOOL_SYMBOL */ case TOOL_HOTSPOT: { _FMTMSG("Active tool is HOTSPOT for docWinID %d.", docWinID); break; } /* case TOOL_HOTSPOT */ case TOOL_RUBOUT: { _FMTMSG("Active tool is RUBOUT for docWinID %d.", docWinID); break; } /* case TOOL_RUBOUT */ case TOOL_ERASER: { _FMTMSG("Active tool is ERASER for docWinID %d.", docWinID); break; } /* case TOOL_ERASER */ case TOOL_SELECT: { _FMTMSG("Active tool is SELECT for docWinID %d.", docWinID); break; } /* case TOOL_SELECT */ case TOOL_MOVERESIZE: { _FMTMSG("Active tool is MOVERESIZE for docWinID %d.", docWinID); break; } /* case TOOL_MOVERESIZE */ case TOOL_ROTATE: { _FMTMSG("Active tool is ROTATE for docWinID %d.", docWinID); break; } /* case TOOL_ROTATE */ case TOOL_CHANGETEXT: { _FMTMSG("Active tool is CHANGETEXT for docWinID %d.", docWinID); break; } /* case TOOL_CHANGETEXT */ case TOOL_ARC: { _FMTMSG("Active tool is ARC for docWinID %d.", docWinID); break; } /* case TOOL_ARC */ default: { _FMTMSG("***Unrecognized tool for docWinID %d.", docWinID); break; } /* case default */ } /* switch (tmp) */ ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ } /* if (!_GetActiveEditLayer(ghConv, docWinID)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetTool() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetWindowTitle @Desc: ============================================================================== */ int IMG_GetWindowTitle(HCONV ghConv, DOCWINID docWinID, char FAR* title) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETWINDOWTITLE(%d)]", docWinID); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { IMG_GetData(hData, title, 1); _FMTMSG2("DocWinID %d has window title \"%s\".", docWinID, title); ret = TRUE; } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetWindowTitle() */ /* ========================================= Parallax C Function ================== @Name: IMG_ImportLayer @Desc: ============================================================================== */ int IMG_ImportLayer(HCONV ghConv, DOCWINID docWinID, void FAR* fname, void FAR* title, int layerType, LAYERID FAR* layerID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; if (fname == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (title == NULL) title = (void FAR*)nulltitle; _FMTMSG("Import layer into docWinID %d.", docWinID); _FMTMSG(" -->filename = \"%s\".", fname); _FMTMSG(" -->layer title = \"%s\".", title); switch (layerType) { case 0: { _MSG(" -->import as non-text layer."); break; } /* case 0 */ case 1: { _MSG(" -->import as an edit layer."); break; } /* case 1 */ case 2: { _MSG(" -->import as a raster layer."); break; } /* case 2 */ case 3: { _MSG(" -->import as a text layer."); break; } /* case 3 */ default: { _MSG(" ***unknown layer type."); break; } /* case default */ } /* switch (layerType) */ wsprintf(szBuffer, "[IMPORTLAYER(%d,\"%s\",\"%s\",%d)]", docWinID, (LPSTR)fname, (LPSTR)title, layerType); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (layerID) *layerID = tmp; _FMTMSG(" -->layerID is %d.", tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_ImportLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_Merge @Desc: ============================================================================== */ int IMG_Merge(HCONV ghConv, DOCWINID docWinID, int mergetype, DOCWINID FAR* newDocWinID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG("Merge layers of docWinID %d.", docWinID); if (mergetype == MERGE_USER) _MSG(" -->merge using dialog box. "); if (mergetype & MERGE_WHOLEDOC) _MSG(" -->merge whole document."); if (mergetype & MERGE_DISPLAYEDLAYERS) _MSG(" -->merge displayed layers."); if (mergetype & MERGE_ASDISPLAYED) _MSG(" -->merge as displayed."); if (mergetype & MERGE_ACTIVERASTER) _MSG(" -->merge active raster."); if (mergetype & MERGE_ACTIVEEDIT) _MSG(" -->merge active edit."); if (mergetype & MERGE_DISPLAYEDRASTERS) _MSG(" -->merge displayed raster layers."); if (mergetype & MERGE_DISPLAYEDEDITS) _MSG(" -->merge displayed edit layers."); wsprintf(szBuffer, "[MERGE(%d,%d)]", docWinID, mergetype); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (newDocWinID) *newDocWinID = tmp; _FMTMSG(" -->new docWinID is %d.", tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Merge() */ /* ========================================= Parallax C Function ================== @Name: IMG_NewDocument @Desc: ============================================================================== */ int IMG_NewDocument(HCONV ghConv, char FAR* title, char FAR* fname, DOCWINID FAR* docWinID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; if (fname == NULL) fname=(void FAR*)nulltitle; if (title == NULL) title=(void FAR*)nulltitle; _MSG("Create new document."); _FMTMSG(" -->filename = \"%s\".", fname); _FMTMSG(" -->title = \"%s\".", title); wsprintf(szBuffer, "[NEWDOCUMENT(\"%s\",\"%s\")]", (LPSTR)title, (LPSTR)fname); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 2); if (igd == 2) { int tmp; sscanf(&pData[PARMSIZE*1], "%d", &tmp); if (docWinID) *docWinID = tmp; _FMTMSG(" -->docWinID is %d.", tmp); ret = TRUE; } /* if (igd == 2) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NewDocument() */ /* ========================================= Parallax C Function ================== @Name: IMG_NewLayer @Desc: ============================================================================== */ int IMG_NewLayer(HCONV ghConv, DOCWINID docWinID, int layerType, LAYERID FAR* layerID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG("Create new layer for docWinID %d.", docWinID); switch (layerType) { case 1: { _MSG(" -->Redline layer."); break; } /* case 1 */ case 2: { _MSG(" -->Edit layer."); break; } /* case 2 */ case 3: { _MSG(" -->Full edit layer."); break; } /* case 3 */ case 4: { _MSG(" -->Annotation layer."); break; } /* case 4 */ case 5: { _MSG(" -->Hotspot layer."); break; } /* case 5 */ default: { _MSG(" ***unknown layer type."); break; } /* case default */ } /* switch (layerType) */ wsprintf(szBuffer, "[NEWLAYER(%d,%d)]", docWinID, layerType); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*0], "%d", &tmp); if (layerID) *layerID = tmp; _FMTMSG(" -->layerID is %d.", tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_NewLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_OpenDocWin @Desc: ============================================================================== */ int IMG_OpenDocWin(HCONV ghConv, int location, int fileType, void FAR* fname, void FAR* title, int perms, int wother, int lother, DOCWINID FAR* docWinID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; if (fname == NULL) goto cleanup; if (title == NULL) title=(void FAR*)nulltitle; _MSG("Open file as new docWin."); _FMTMSG(" -->location is %d.", location); switch (fileType) { case 0: { _MSG(" -->open as non-text file."); break; } /* case 0 */ case 1: { _MSG(" -->open as an edit file."); break; } /* case 1 */ case 2: { _MSG(" -->open as a raster file."); break; } /* case 2 */ case 3: { _MSG(" -->open as a text file."); break; } /* case 3 */ default: { _MSG(" ***unknown file type."); break; } /* case default */ } /* switch (fileType) */ _FMTMSG(" -->docWin title= \"%s\".", title); _FMTMSG(" -->file name = \"%s\".", fname); wsprintf(szBuffer, "[OPENDOCWIN(%d,%d,\"%s\",\"%s\",%d,%d,%d)]", location, fileType, (LPSTR)fname, (LPSTR)title, perms, wother, lother); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 2); if (igd == 2) { int tmp; sscanf(&pData[PARMSIZE*1], "%d", &tmp); if (docWinID) *docWinID = tmp; _FMTMSG(" -->docWinID is %d.", tmp); ret = TRUE; } /* if (igd == 2) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_OpenDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_PrintDocWin @Desc: ============================================================================== */ int IMG_PrintDocWin(HCONV ghConv, DOCWINID docWinID, int pagerange, int firstpage, int lastpage, int ncopies, BOOL bUseDialog) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG3("Print docWinID %d from page %d to page %d.", docWinID, firstpage, lastpage); wsprintf(szBuffer, "[PRINTDOCWIN(%d,%d,%d,%d,%d,%d,8)]", docWinID, pagerange, firstpage, lastpage, ncopies, bUseDialog); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_PrintDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_Refresh @Desc: ============================================================================== */ int IMG_Refresh(HCONV ghConv, DOCWINID docWinID) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG("Refresh docWinID %d.", docWinID); wsprintf(szBuffer, "[REFRESH(%d)]", docWinID); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Refresh() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetShowStatusDialogs @Desc: ============================================================================== */ int IMG_SetShowStatusDialogs(HCONV ghConv, BOOL status) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; wsprintf(szBuffer, "[SETSHOWSTATUSDIALOGS(%d)]", status); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetShowStatusDialogs() */ /* ========================================= Parallax C Function ================== @Name: IMG_ReorderLayer @Desc: ============================================================================== */ int IMG_ReorderLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, int position) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG3("Reorder layerID %d of docWinID %d to position %d.", layerID, docWinID, position); wsprintf(szBuffer, "[REORDERLAYER(%d,%d,%d)]", docWinID, layerID, position); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_ReorderLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_Save @Desc: ============================================================================== */ int IMG_Save(HCONV ghConv, DOCWINID docWinID, BOOL bSaveAs, void FAR* fname, void FAR* title, BOOL bOverwrite) { char szBuffer[256]; char szTmpFname[256]; char szTmpTitle[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; if (fname == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (title == NULL) title = (void FAR*)nulltitle; _fstrcpy(szTmpFname, fname); _fstrcpy(szTmpTitle, title); _FMTMSG("Save docWinID %d.", docWinID); _FMTMSG(" -->filename = \"%s\".", szTmpFname); _FMTMSG(" -->title = \"%s\".", szTmpTitle); if (bOverwrite) { _MSG(" -->overwrite = Yes."); } else /* if (bOverwrite) */ { _MSG(" -->overwrite = No."); } /* if (bOverwrite) */ if (bSaveAs) { _MSG(" -->save as = Yes."); } else /* if (bSaveAs) */ { _MSG(" -->save as = No."); } /* if (bSaveAs) */ wsprintf(szBuffer, "[SAVE(%d,%d,\"%s\",\"%s\",%d)]", docWinID, bSaveAs, (LPSTR)szTmpFname, (LPSTR)szTmpTitle, bOverwrite); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Save() */ /* ========================================= Parallax C Function ================== @Name: IMG_SaveLayer @Desc: ============================================================================== */ int IMG_SaveLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, BOOL bSaveAs, void FAR* fname, void FAR* title, BOOL bOverwrite, int format, int rotation) { char szBuffer[256]; char szTmpFname[256]; char szTmpTitle[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; if (fname == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (title == NULL) title = (void FAR*)nulltitle; _fstrcpy(szTmpFname, fname); _fstrcpy(szTmpTitle, title); _FMTMSG2("Save layerID %d of docWinID %d.", layerID, docWinID); _FMTMSG(" -->filename = \"%s\".", szTmpFname); _FMTMSG(" -->title = \"%s\".", szTmpTitle); if (bOverwrite) { _MSG(" -->overwrite = Yes."); } else /* if (bOverwrite) */ { _MSG(" -->overwrite = No."); } /* if (bOverwrite) */ if (bSaveAs) { _MSG(" -->save as = Yes."); } else /* if (bSaveAs) */ { _MSG(" -->save as = No."); } /* if (bSaveAs) */ _FMTMSG(" -->rotation = %d.", rotation); wsprintf(szBuffer, "[SAVELAYER(%d,%d,%d,\"%s\",\"%s\",%d,%d,%d)]", docWinID, layerID, bSaveAs, (LPSTR)szTmpFname, (LPSTR)szTmpTitle, bOverwrite, format, rotation); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SaveLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetActiveLayer @Desc: ============================================================================== */ int IMG_SetActiveLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, BOOL bActivate) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG2("Set active layer of docWinID %d to layerID %d.", docWinID, layerID); if (bActivate) { _MSG(" -->activate = Yes."); } else /* if (bActivate) */ { _MSG(" -->activate = No."); } /* if (bActivate) */ wsprintf(szBuffer, "[SETACTIVELAYER(%d,%d,%d)]", docWinID, layerID, bActivate); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetActiveLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetDisplayLayer @Desc: ============================================================================== */ int IMG_SetDisplayLayer(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, BOOL bDisplay) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG2("Set display status of layerID %d in docWinID %d.", layerID, docWinID); if (bDisplay) { _MSG(" -->display = Yes."); } else /* if (bDisplay) */ { _MSG(" -->display = No."); } /* if (bDisplay) */ wsprintf(szBuffer, "[SETDISPLAYLAYER(%d,%d,%d)]", docWinID, layerID, bDisplay); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetDisplayLayer() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetDocumentTitle @Desc: ============================================================================== */ int IMG_SetDocumentTitle(HCONV ghConv, DOCWINID docWinID, void FAR* title) { char szBuffer[256]; int ret = FALSE; WORD size; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (title == NULL) title=(void FAR*)nulltitle; _FMTMSG("Set document title of docWinID %d.", docWinID); _FMTMSG(" -->title = \"%s\".", title); wsprintf(szBuffer, "[SETDOCUMENTTITLE(%d,\"%s\")]", docWinID, (LPSTR)title); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetDocumentTitle() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetDocWin @Desc: ============================================================================== */ int IMG_SetDocWin(HCONV ghConv, DOCWINID docWinID, BOOL bStep, DOCWINID FAR* newDocWinID) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _MSG("Set active docWinID."); _FMTMSG(" -->from docWinID %d.", docWinID); if (bStep) { _MSG(" -->step forward = Yes."); } else /* if (bStep) */ { _MSG(" -->step forward = No."); } /* if (bStep) */ wsprintf(szBuffer, "[SETDOCWIN(%d,%d)]", docWinID, bStep); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[1*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { int tmp; sscanf(&pData[PARMSIZE*1], "%d", &tmp); if (newDocWinID) *newDocWinID = tmp; { HCONV ghConvLoc = ghConv; tmp = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* */ _FMTMSG(" -->active docWinID is %d.", tmp); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetDocWIn() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetFocus @Desc: ============================================================================== */ int IMG_SetFocus(HCONV ghConv) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; _MSG("Set focus to program."); wsprintf(szBuffer, "[SETFOCUS]"); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetFocus() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetLayerTitle @Desc: ============================================================================== */ int IMG_SetLayerTitle(HCONV ghConv, DOCWINID docWinID, LAYERID layerID, void FAR* title) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (title == NULL) title=(void FAR*)nulltitle; _FMTMSG2("Set layer title of layerID %d in docWinID %d.", layerID, docWinID); _FMTMSG(" -->title = \"%s\".", title); wsprintf(szBuffer, "[SETLAYERTITLE(%d,%d\"%s\")]", docWinID, layerID, (LPSTR)title); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetLayerTitle() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetScrollStep @Desc: ============================================================================== */ int IMG_SetScrollStep(HCONV ghConv, DOCWINID docWinID, float scrollstep) { char szBuffer[256]; WORD size; int ret = FALSE; char ptr[10]; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG("Set scroll step for docWinID %d.", docWinID); gcvt((double)scrollstep, 5, ptr); _FMTMSG(" -->step = %s.", (LPSTR)ptr); wsprintf(szBuffer, "[SETSCROLLSTEP(%d,%s)]", docWinID, (LPSTR)ptr); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetScrollStep() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetScrollView @Desc: ============================================================================== */ int IMG_SetScrollView(HCONV ghConv, DOCWINID docWinID, int scrollmode) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); switch (scrollmode) { case SCROLLVIEW_CENTER: { _FMTMSG("Scroll docWinID %d center.", docWinID); break; } /* case SCROLLVIEW_CENTER */ case SCROLLVIEW_BOTTOMLEFT: { _FMTMSG("Scroll docWinID %d bottom left.", docWinID); break; } /* case SCROLLVIEW_BOTTOMLEFT */ case SCROLLVIEW_BOTTOMRIGHT: { _FMTMSG("Scroll docWinID %d bottom right.", docWinID); break; } /* case SCROLLVIEW_BOTTOMRIGHT */ case SCROLLVIEW_TOPLEFT: { _FMTMSG("Scroll docWinID %d top left.", docWinID); break; } /* case SCROLLVIEW_TOPLEFT */ case SCROLLVIEW_TOPRIGHT: { _FMTMSG("Scroll docWinID %d top right.", docWinID); break; } /* case SCROLLVIEW_TOPRIGHT */ case SCROLLVIEW_UPSTEP: { _FMTMSG("Scroll docWinID %d step up.", docWinID); break; } /* case SCROLLVIEW_UPSTEP */ case SCROLLVIEW_DOWNSTEP: { _FMTMSG("Scroll docWinID %d step down.", docWinID); break; } /* case SCROLLVIEW_DOWNSTEP */ case SCROLLVIEW_RIGHTSTEP: { _FMTMSG("Scroll docWinID %d step right.", docWinID); break; } /* case SCROLLVIEW_RIGHTSTEP */ case SCROLLVIEW_LEFTSTEP: { _FMTMSG("Scroll docWinID %d step left.", docWinID); break; } /* case SCROLLVIEW_LEFTSTEP */ case SCROLLVIEW_UPPAGE: { _FMTMSG("Scroll docWinID %d page up.", docWinID); break; } /* case SCROLLVIEW_UPPAGE */ case SCROLLVIEW_DOWNPAGE: { _FMTMSG("Scroll docWinID %d page down.", docWinID); break; } /* case SCROLLVIEW_DOWNPAGE */ case SCROLLVIEW_LEFTPAGE: { _FMTMSG("Scroll docWinID %d page left.", docWinID); break; } /* case SCROLLVIEW_LEFTPAGE */ case SCROLLVIEW_RIGHTPAGE: { _FMTMSG("Scroll docWinID %d page right.", docWinID); break; } /* case SCROLLVIEW_RIGHTPAGE */ case SCROLLVIEW_LEFTDOWNSTEP: { _FMTMSG("Scroll docWinID %d step left and down.", docWinID); break; } /* case SCROLLVIEW_LEFTDOWNSTEP */ case SCROLLVIEW_RIGHTDOWNSTEP: { _FMTMSG("Scroll docWinID %d step right and down.", docWinID); break; } /* case SCROLLVIEW_RIGHTDOWNSTEP */ case SCROLLVIEW_LEFTUPSTEP: { _FMTMSG("Scroll docWinID %d tep left and up.", docWinID); break; } /* case SCROLLVIEW_LEFTUPSTEP */ case SCROLLVIEW_RIGHTUPSTEP: { _FMTMSG("Scroll docWinID %d step right and up.", docWinID); break; } /* case SCROLLVIEW_RIGHTUPSTEP */ case SCROLLVIEW_LEFTDOWNPAGE: { _FMTMSG("Scroll docWinID %d page left and down.", docWinID); break; } /* case SCROLLVIEW_LEFTDOWNPAGE */ case SCROLLVIEW_RIGHTDOWNPAGE: { _FMTMSG("Scroll docWinID %d page right and down.", docWinID); break; } /* case SCROLLVIEW_RIGHTDOWNPAGE */ case SCROLLVIEW_LEFTUPPAGE: { _FMTMSG("Scroll docWinID %d page left and up.", docWinID); break; } /* case SCROLLVIEW_LEFTUPPAGE */ case SCROLLVIEW_RIGHTUPPAGE: { _FMTMSG("Scroll docWinID %d page right and up.", docWinID); break; } /* case SCROLLVIEW_RIGHTUPPAGE */ default: { _FMTMSG("***Unrecognized scrollmode for docWinID %d.", docWinID); break; } /* case default */ } /* switch (scrollmode) */ wsprintf(szBuffer, "[SETSCROLLVIEW(%d,%d)]", docWinID, scrollmode); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetScrollView() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetTool @Desc: ============================================================================== */ int IMG_SetTool(HCONV ghConv, DOCWINID docWinID, int tooltype) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (!_GetActiveEditLayer(ghConv, docWinID)) { _MSG("No active edit layer. Couldn't set any tool."); ret = TRUE; } else /* if (!_GetActiveEditLayer(ghConv, docWinID)) */ { switch (tooltype) { case TOOL_NONE: { _FMTMSG("Set no active tool for docWinID %d.", docWinID); break; } /* case TOOL_NONE */ case TOOL_CUT: { _FMTMSG("Set active tool to CUT for docWinID %d.", docWinID); break; } /* case TOOL_CUT */ case TOOL_COPY: { _FMTMSG("Set active tool to COPY for docWinID %d.", docWinID); break; } /* case TOOL_COPY */ case TOOL_PASTE: { _FMTMSG("Set active tool to PASTE for docWinID %d.", docWinID); break; } /* case TOOL_PASTE */ case TOOL_LINE: { _FMTMSG("Set active tool to LINE for docWinID %d.", docWinID); break; } /* case TOOL_LINE */ case TOOL_BOX: { _FMTMSG("Set active tool to BOX for docWinID %d.", docWinID); break; } /* case TOOL_BOX */ case TOOL_CIRCLE: { _FMTMSG("Set active tool to CIRCLE for docWinID %d.", docWinID); break; } /* case TOOL_CIRCLE */ case TOOL_ELLIPSE: { _FMTMSG("Set active tool to ELLIPSE for docWinID %d.", docWinID); break; } /* case TOOL_ELLPISE */ case TOOL_ARROW: { _FMTMSG("Set active tool to ARROW for docWinID %d.", docWinID); break; } /* case TOOL_ARROW */ case TOOL_SKETCH: { _FMTMSG("Set active tool to SKETCH for docWinID %d.", docWinID); break; } /* case TOOL_SKETCH */ case TOOL_POLYLINE: { _FMTMSG("Set active tool to POLYLINE for docWinID %d.", docWinID); break; } /* case TOOL_POLYLINE */ case TOOL_POLYGON: { _FMTMSG("Set active tool to POLYGON for docWinID %d.", docWinID); break; } /* case TOOL_POLYGON */ case TOOL_TEXT: { _FMTMSG("Set active tool to TEXT for docWinID %d.", docWinID); break; } /* case TOOL_TEXT */ case TOOL_ANNOTATION: { _FMTMSG("Set active tool to ANNOTATION for docWinID %d.", docWinID); break; } /* case TOOL_ANNOTATION */ case TOOL_DIMENSION: { _FMTMSG("Set active tool to DIMENSION for docWinID %d.", docWinID); break; } /* case TOOL_DIMENSION */ case TOOL_SYMBOL: { _FMTMSG("Set active tool to SYMBOL for docWinID %d.", docWinID); break; } /* case TOOL_SYMBOL */ case TOOL_HOTSPOT: { _FMTMSG("Set active tool to HOTSPOT for docWinID %d.", docWinID); break; } /* case TOOL_HOTSPOT */ case TOOL_RUBOUT: { _FMTMSG("Set active tool to RUBOUT for docWinID %d.", docWinID); break; } /* case TOOL_RUBOUT */ case TOOL_ERASER: { _FMTMSG("Set active tool to ERASER for docWinID %d.", docWinID); break; } /* case TOOL_ERASER */ case TOOL_SELECT: { _FMTMSG("Set active tool to SELECT for docWinID %d.", docWinID); break; } /* case TOOL_SELECT */ case TOOL_MOVERESIZE: { _FMTMSG("Set active tool to MOVERESIZE for docWinID %d.", docWinID); break; } /* case TOOL_MOVERESIZE */ case TOOL_ROTATE: { _FMTMSG("Set active tool to ROTATE for docWinID %d.", docWinID); break; } /* case TOOL_ROTATE */ case TOOL_CHANGETEXT: { _FMTMSG("Set active tool to CHANGETEXT for docWinID %d.", docWinID); break; } /* case TOOL_CHANGETEXT */ case TOOL_ARC: { _FMTMSG("Set active tool to ARC for docWinID %d.", docWinID); break; } /* case TOOL_ARC */ default: { _FMTMSG("***Unrecognized tool set for docWinID %d.", docWinID); break; } /* case default */ } /* switch (toolType) */ wsprintf(szBuffer, "[SETTOOL(%d,%d)]", docWinID, tooltype); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!_GetActiveEditLayer(ghConv, docWinID)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetTool() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetWindowTitle @Desc: ============================================================================== */ int IMG_SetWindowTitle(HCONV ghConv, DOCWINID docWinID, void FAR* title) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); if (title == NULL) title=(void FAR*)nulltitle; _FMTMSG("Set window title of docWinID %d.", docWinID); _FMTMSG(" -->title = \"%s\".", title); wsprintf(szBuffer, "[SETWINDOWTITLE(%d,\"%s\")]", docWinID, (LPSTR)title); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetWindowTitle() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetZoom @Desc: ============================================================================== */ int IMG_SetZoom(HCONV ghConv, DOCWINID docWinID, int zoomLevel, float factor, int xpos, int ypos) { char szBuffer[256]; WORD size; int ret = FALSE; char ptr[10]; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } if (!docWinID) return (FALSE); _FMTMSG("Set zoom level for docWinID %d.", docWinID); switch (zoomLevel) { case ZOOM_IN: { _MSG(" -->Zoom in."); break; } /* case ZOOM_IN */ case ZOOM_OUT: { _MSG(" -->Zoom out."); break; } /* case ZOOM_OUT */ case ZOOM_FIT: { _MSG(" -->Zoom to fit."); break; } /* case ZOOM_FIT */ case ZOOM_HFIT: { _MSG(" -->Zoom horizontal fit."); break; } /* case ZOOM_HFIT */ case ZOOM_VFIT: { _MSG(" -->Zoom vertical fit."); break; } /* case ZOOM_VFIT */ case ZOOM_ACTUAL: { _MSG(" -->Zoom to actual size."); break; } /* case ZOOM_ACTUAL */ case ZOOM_1TO1: { _MSG(" -->Zoom to 1:1."); break; } /* case ZOOM_1TO1 */ default: { _MSG(" ***unrecognized zoom level."); break; } /* case default */ } /* switch (zoomLevel) */ gcvt((double)factor, 5, ptr); _FMTMSG(" -->scale factor = %s", ptr); _FMTMSG(" -->x position = %d", xpos); _FMTMSG(" -->y position = %d", ypos); wsprintf(szBuffer, "[SETZOOM(%d,%d,%s,%d,%d)]", docWinID, zoomLevel, (LPSTR)ptr, xpos, ypos); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetZoom() */ /* ========================================= Parallax C Function ================== @Name: IMG_SetZoomStep @Desc: ============================================================================== */ int IMG_SetZoomStep(HCONV ghConv, DOCWINID docWinID, float zoomstep) { char szBuffer[256]; WORD size; int ret = FALSE; char ptr[10]; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); _FMTMSG("Set zoom step for docWinID %d.", docWinID); gcvt((double)zoomstep, 5, ptr); _FMTMSG(" -->zoom step = %s.", ptr); wsprintf(szBuffer, "[SETZOOMSTEP(%d,%s)]", docWinID, (LPSTR)ptr); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_SetZoomStep() */ /* ========================================= Parallax C Function ================== @Name: IMG_ShowDocWin @Desc: ============================================================================== */ int IMG_ShowDocWin(HCONV ghConv, DOCWINID docWinID, int arrangement) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); switch (arrangement) { case SHOW_MINIMIZE: { _FMTMSG("Minimize docWinID %d.", docWinID); break; } /* case SHOW_MINIMIZE */ case SHOW_MAXIMIZE: { _FMTMSG("Maximize docWinID %d.", docWinID); break; } /* case SHOW_MAXIMIZE */ case SHOW_RESTORE: { _FMTMSG("Restore docWinID %d.", docWinID); break; } /* case SHOW_RESTORE */ case SHOW_HIDE: { _FMTMSG("Hide docWinID %d.", docWinID); break; } /* case SHOW_HIDE */ case SHOW_UNHIDE: { _FMTMSG("Unhide docWinID %d.", docWinID); break; } /* case SHOW_UNHIDE */ default: { _MSG("***Unrecognized show command."); break; } /* case default */ } /* switch (arrangement) */ wsprintf(szBuffer, "[SHOWDOCWIN(%d,%d)]", docWinID, arrangement); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_ShowDocWin() */ /* ========================================= Parallax C Function ================== @Name: IMG_Terminate @Desc: ============================================================================== */ int IMG_Terminate(HCONV ghConv) { char szBuffer[256]; WORD size; int ret = FALSE; if (ghConv == NULL) goto cleanup; _MSG("Terminate program."); wsprintf(szBuffer, "[TERMINATE]"); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Terminate() */ /* ========================================= Parallax C Function ================== @Name: IMG_Despeckle @Desc: ============================================================================== */ int IMG_Despeckle(HCONV ghConv, HWND docWinId, int speckle) { char szBuffer[256]; WORD size; int ret = FALSE; HCONV ghConvLoc = ghConv; if (ghConv == NULL) goto cleanup; if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) { _MSG("No open document. Nothing to despeckle."); ret = TRUE; } else /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ { _FMTMSG("Despeckle Current DocWin %d speckles", speckle); wsprintf(szBuffer, "[DESPECKLE(%d,%d,%d)]", docWinId, 0, speckle); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Despeckle() */ /* ========================================= Parallax C Function ================== @Name: IMG_Deskew @Desc: ============================================================================== */ int IMG_Deskew(HCONV ghConv, HWND docWinId, float angle) { char szBuffer[256]; WORD size; int ret = FALSE; char ptr[10]; HCONV ghConvLoc = ghConv; if (ghConv == NULL) goto cleanup; if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) { _MSG("No open document. Nothing to deskew."); ret = TRUE; } else /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ { gcvt((double)angle, 5, ptr); _FMTMSG("Deskew current doc win %s degrees.", (LPSTR)ptr); wsprintf(szBuffer, "[DESKEW(%d,%d,%s)]", docWinId, 0, (LPSTR)ptr); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Deskew() */ /* ========================================= Parallax C Function ================== @Name: IMG_Crop @Desc: ============================================================================== */ int IMG_Crop(HCONV ghConv, HWND docWinId, long x1, long y1, long x2, long y2) { char szBuffer[256]; WORD size; int ret = FALSE; HCONV ghConvLoc = ghConv; if (ghConv == NULL) goto cleanup; if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) { _MSG("No open document. Nothing to crop."); ret = TRUE; } else /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ { wsprintf(szBuffer, "Crop DocWin:%d, Layer:%d at (%lu,%lu) -- (%lu,%lu)", docWinId, 0, x1, y1, x2, y2); _MSG(szBuffer); wsprintf(szBuffer, "[CROPLAYER(%d,%d,%d,0,0,%lu.0,%lu.0,%lu.0,%lu.0)]", docWinId, 1, 1, x1, y1, x2, y2); size = (WORD)(lstrlen(szBuffer) + 1); if (IMG_Execute(ghConv, (void FAR*)szBuffer, size, NULL) == DDE_FACK) ret = TRUE; } /* if (!(DOCWINID)_GetDocWin(ghConvLoc, FALSE)) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_Crop() */ /* ========================================= Parallax C Function ================== @Name: IMG_GetDeskewLimit @Desc: ============================================================================== */ int IMG_GetDeskewLimit(HCONV ghConv, DOCWINID docWinID, LAYERID layerId, double FAR* angle) { HDDEDATA hData; char szBuffer[256]; int ret = FALSE; double tmp = 0.0; if (ghConv == NULL) goto cleanup; /* docWinID = 0 */ if (!docWinID) { HCONV ghConvLoc = ghConv; docWinID = (DOCWINID)_GetDocWin(ghConvLoc, TRUE); } /* if (!docWinID) */ if (!docWinID) return (FALSE); wsprintf(szBuffer, "[GETDESKEWLIMITS(%d,%d)]", docWinID, layerId); IMG_Request(ghConv, (void FAR*)szBuffer, &hData); if (hData) { char pData[2*PARMSIZE]; int igd; igd = IMG_GetData(hData, (char FAR*)pData, 1); if (igd == 1) { tmp = img_ATOF(pData); if (angle) *angle = tmp; _FMTMSG2("Deskew Limit for Active Raster layer is %s for docWinID %x.", (LPSTR)pData, (short)docWinID); ret = TRUE; } /* if (igd == 1) */ } /* if (hData) */ cleanup: if (!ret) _MSG(pDdeErrMsg); return (ret); } /* IMG_GetDeskewLimit() */ /* UTDDE.C */ /* end of file */