--- mstools/samples/ole/clidemo/object.c 2018/08/09 18:21:52 1.1.1.2 +++ mstools/samples/ole/clidemo/object.c 2018/08/09 18:24:01 1.1.1.3 @@ -1,5 +1,5 @@ -/* - * object.c - OLE object support routines +/* + * object.c - OLE object support routines * * Created by Microsoft Corporation. * (c) Copyright Microsoft Corp. 1990 - 1992 All Rights Reserved @@ -20,7 +20,7 @@ #include "utility.h" #include "register.h" -#define HIMETRIC_PER_INCH 2540 +#define HIMETRIC_PER_INCH 2540 //*** VARIABLES *** @@ -35,9 +35,9 @@ INT giYppli ; /*************************************************************************** * CallBack() * - * This routine will be called whenever an object has been changed, - * saved, renamed, is being painted, or an asynchronous operation has - * completed. This routine is called by the OLE client DLL in the + * This routine will be called whenever an object has been changed, + * saved, renamed, is being painted, or an asynchronous operation has + * completed. This routine is called by the OLE client DLL in the * above situations. A pointer to this function is kept in the client * vtbl. It is our obligation as a client application to insure that a * pointer to this procedure is in the vtbl. @@ -46,13 +46,13 @@ INT giYppli ; * the work right away. Well, this is done to avoid any possibility of * getting into another dispatch message loop. A MessageBox woul do this! * - * Returns int - see below + * Returns int - see below * - * The return value is generally ignored, except for these notifications: - * OLE_QUERY_PAINT and OLE_QUERY_RETRY. For these two notifications, + * The return value is generally ignored, except for these notifications: + * OLE_QUERY_PAINT and OLE_QUERY_RETRY. For these two notifications, * returning TRUE means continue the current operation(eg painting or retry) - * Returning FALSE means stop the current operation. This is useful as an - * object which takes a long time to paint can be interrupted in order to + * Returning FALSE means stop the current operation. This is useful as an + * object which takes a long time to paint can be interrupted in order to * perform other operations. ***************************************************************************/ @@ -63,14 +63,14 @@ INT APIENTRY CallBack( // ){ //* LOCAL: APPITEMPTR pItem; //* application item pointer - + pItem = (APPITEMPTR)lpClient; - switch (flags) + switch (flags) { case OLE_CLOSED: //* server has closed if (!pItem->fVisible) { - PostMessage(hwndFrame, WM_DELETE, (DWORD)pItem,0L); + PostMessage(hwndFrame, WM_DELETE, 0L, (DWORD)pItem); Dirty(DOC_UNDIRTY); } SetFocus( hwndFrame ); @@ -80,7 +80,7 @@ INT APIENTRY CallBack( // case OLE_CHANGED: //* object has changes cOleWait++; pItem->fServerChangedBounds = pItem->fVisible = TRUE; - PostMessage(pItem->hwnd, WM_CHANGE, NULL, 0L); + PostMessage(pItem->hwnd, WM_CHANGE, 0, 0L); break; case OLE_RELEASE: //* notification that an asynchronous @@ -94,29 +94,29 @@ INT APIENTRY CallBack( // if (!--cOleWait) Hourglass(FALSE); Release(pItem); - } + } break; case OLE_QUERY_RETRY: //* Continue retrying. ToggleBlockTimer(FALSE); //* toggle timer off if (!hRetry && pItem->fRetry) - PostMessage(hwndFrame,WM_RETRY,(DWORD)pItem,0L); + PostMessage(hwndFrame,WM_RETRY,0L, (DWORD)pItem); return (pItem->fRetry); - + case OLE_QUERY_PAINT: //* continue repainting return TRUE; //* a false return terminates either default: break; } - return 0; //* return value is ignored in + return 0; //* return value is ignored in //* most cases, see header } /*************************************************************************** * Release() * - * Check for an error on the OLE_RELEASE notification. + * Check for an error on the OLE_RELEASE notification. **************************************************************************/ static VOID Release( //* ENTRY: @@ -124,10 +124,10 @@ static VOID Release( / ){ //* LOCAL: DWORD wParam; //* error code parameter - if ((wParam = OleQueryReleaseError(pItem->lpObject)) == OLE_OK) + if ((wParam = OleQueryReleaseError(pItem->lpObject)) == OLE_OK) return; - switch (OleQueryReleaseMethod(pItem->lpObject)) + switch (OleQueryReleaseMethod(pItem->lpObject)) { case OLE_LNKPASTE: pItem->fVisible = FALSE; @@ -137,12 +137,12 @@ static VOID Release( / case OLE_CREATE: pItem->fVisible = FALSE; cOleWait++; - PostMessage(hwndFrame, WM_DELETE,(DWORD)pItem,1L); + PostMessage(hwndFrame, WM_DELETE,1L, (DWORD)pItem); Dirty(DOC_UNDIRTY); } //* post a message to the main window //* which will display a message box - PostMessage(hwndFrame,WM_ERROR,wParam,NULL); + PostMessage(hwndFrame,WM_ERROR,wParam,0); } @@ -163,7 +163,7 @@ OLESTATUS FAR Error( / OLESTATUS olestat //* OLE status ){ - switch (olestat) + switch (olestat) { case OLE_WAIT_FOR_RELEASE: if (!cOleWait) @@ -200,10 +200,10 @@ OLESTATUS FAR Error( / /**************************************************************************** * PreItemCreate() - * - * This routine allocates an application item structure. A pointer to this - * structure is passed as the client structure, therefore we need to - * have a pointer to the vtbl as the first entry. We are doing this + * + * This routine allocates an application item structure. A pointer to this + * structure is passed as the client structure, therefore we need to + * have a pointer to the vtbl as the first entry. We are doing this * to allow acess to the application item information during a OLE * DLL callback. This approach simplifies matters. * @@ -251,12 +251,12 @@ APPITEMPTR FAR PreItemCreate( / LONG APIENTRY ItemWndProc( //* ENTRY: HWND hwnd, //* standard windows parameters - UINT msg, - DWORD wParam, + UINT msg, + DWORD wParam, LONG lParam ){ //* LOCAL: - static POINT dragPt; //* Mouse drag point - static RECT dragRect; //* Mouse drag rectangle + static POINT dragPt; //* Mouse drag point + static RECT dragRect; //* Mouse drag rectangle static BOOL fCaptured; //* captured flag APPITEMPTR pItem; //* application item pointer PAINTSTRUCT ps; //* paint structure @@ -264,8 +264,8 @@ LONG APIENTRY ItemWndProc( // RECT rc; //* bounding rectangle // char lpstr[256]; - switch (msg) - { + switch (msg) + { case WM_SIZE: if (pItem = (APPITEMPTR)GetWindowLong(hwnd,0)) { @@ -279,14 +279,14 @@ LONG APIENTRY ItemWndProc( // case WM_CHANGE: --cOleWait; pItem = (APPITEMPTR)GetWindowLong(hwnd,0); - if (!Error(OleQueryBounds(pItem->lpObject, &rc))) + if (!Error(OleQueryBounds(pItem->lpObject, &rc))) { ConvertToClient(&rc); SetWindowPos( - hwnd, - NULL, - 0, + hwnd, + NULL, + 0, 0, rc.right - rc.left + 2*GetSystemMetrics(SM_CXFRAME), rc.bottom - rc.top + 2*GetSystemMetrics(SM_CYFRAME), @@ -316,12 +316,12 @@ LONG APIENTRY ItemWndProc( // EndPaint(hwnd, (LPPAINTSTRUCT)&ps); break; - case WM_LBUTTONDBLCLK: //* execute a verb + case WM_LBUTTONDBLCLK: //* execute a verb ANY_OBJECT_BUSY; ExecuteVerb(OLEVERB_PRIMARY,(APPITEMPTR)GetWindowLong(hwnd,0)); break; - case WM_LBUTTONDOWN: + case WM_LBUTTONDOWN: GetWindowRect(hwnd, (LPRECT)&dragRect); ScreenToClient(hwndFrame, (LPPOINT)&dragRect); ScreenToClient(hwndFrame, (LPPOINT)&dragRect.right); @@ -350,18 +350,18 @@ LONG APIENTRY ItemWndProc( // break; pt.x = (LONG)(SHORT)LOWORD(lParam); pt.y = (LONG)(SHORT)HIWORD(lParam); - + ClientToScreen(hwnd, (LPPOINT)&pt); ScreenToClient(hwndFrame, (LPPOINT)&pt); OffsetRect( - (LPRECT)&dragRect, - pt.x - dragPt.x, + (LPRECT)&dragRect, + pt.x - dragPt.x, pt.y - dragPt.y ); MoveWindow( - hwnd, + hwnd, dragRect.left, dragRect.top, dragRect.right - dragRect.left, dragRect.bottom - dragRect.top, TRUE @@ -370,8 +370,8 @@ LONG APIENTRY ItemWndProc( // dragPt.x = pt.x; dragPt.y = pt.y; break; - - default: + + default: return (DefWindowProc(hwnd, msg, wParam, lParam)); } return 0L; @@ -381,8 +381,8 @@ LONG APIENTRY ItemWndProc( // /**************************************************************************** * PostItemCreate() * - * This function creates a child window which will contain the newly - * created OLE object. A pointer to our item information is stored in the + * This function creates a child window which will contain the newly + * created OLE object. A pointer to our item information is stored in the * extra bytes of this window. This is where we internally keep track * of information related to the object as well as the * pointer to the object for subsequent OLE API calls. This routine is @@ -403,12 +403,12 @@ BOOL FAR PostItemCreate( / if (lprcObject) //* if the size of the objects rc = *lprcObject; //* bounding rectangle is not - else if (OleQueryBounds(lpObject, &rc) == OLE_OK) + else if (OleQueryBounds(lpObject, &rc) == OLE_OK) ConvertToClient(&rc); - else + else SetRect(&rc, 0, 0, 0, 0); - if (!(pItem->hwnd = CreateWindow( //* Create the child window + if (!(pItem->hwnd = CreateWindow( //* Create the child window szItemClass, "", WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_THICKFRAME, rc.left,rc.top, @@ -436,18 +436,18 @@ BOOL FAR PostItemCreate( / Error(OleSetHostNames(lpObject, (LPSTR)szAppName, (LPSTR)sz )); WaitForObject(pItem); } - else if (pItem->otObject == OT_LINK)//* if the object is linked + else if (pItem->otObject == OT_LINK)//* if the object is linked { //* retrieve update options WaitForObject(pItem); if(Error(OleGetLinkUpdateOptions(pItem->lpObject, &pItem->uoObject))) goto Error; - + if (ObjGetData(pItem,pData)) { - for (i=0; pData[i];i++); //* Skip past the server name + for (i=0; pData[i];i++); //* Skip past the server name pItem->aLinkName = AddAtom(&pData[++i]); - } + } else pItem->aLinkName = AddAtom(""); } @@ -460,11 +460,11 @@ Error: / ErrorMessage(E_FAILED_TO_CREATE_CHILD_WINDOW); FreeAppItem(pItem); - + return FALSE; //* ERROR return } - + /*************************************************************************** * ConvertToClient() * @@ -475,49 +475,49 @@ VOID FAR ConvertToClient( / LPRECT lprc //* pointer to bounding rectangle ){ //* LOCAL - //* If we have an empty rectangle then set the default size + //* If we have an empty rectangle then set the default size if (!(lprc->left || lprc->top || lprc->right || lprc->bottom)) SetRect(lprc, 0, 0, CXDEFAULT, CYDEFAULT); - else + else { - //* We got the himetric units, converts them to pixels now. + //* We got the himetric units, converts them to pixels now. lprc->right = MulDiv (giXppli, (lprc->right - lprc->left), HIMETRIC_PER_INCH); - + lprc->bottom = MulDiv (giYppli, (lprc->top - lprc->bottom), HIMETRIC_PER_INCH); lprc->left = 0; - lprc->top = 0; + lprc->top = 0; } } /*************************************************************************** * ObjInsert() - * + * * Query the user for object type to insert and insert the new OLE object ***************************************************************************/ VOID FAR ObjInsert( //* ENTRY: - LHCLIENTDOC lhcDoc, //* OLE document handle + LHCLIENTDOC lhcDoc, //* OLE document handle LPOLECLIENT lpClient //* pointer to OLE client structure -){ //* LOCAL: - LPOLEOBJECT lpObject; //* pointer to OLE object +){ //* LOCAL: + LPOLEOBJECT lpObject; //* pointer to OLE object APPITEMPTR pItem; //* item pointer - CHAR szServerName[CBPATHMAX];//* Class name for OleCreate() - CHAR szClassName[CBPATHMAX];//* Class name for OleCreate() - CHAR szTmp[CBOBJNAMEMAX]; //* buffer to unique object name - - if (DialogBoxParam(hInst, MAKEINTRESOURCE(DTCREATE),hwndFrame, - (DLGPROC) fnInsertNew, (LONG)((LPSTR)szClassName)) != IDCANCEL) + CHAR szServerName[CBPATHMAX];//* Class name for OleCreate() + CHAR szClassName[CBPATHMAX];//* Class name for OleCreate() + CHAR szTmp[CBOBJNAMEMAX]; //* buffer to unique object name + + if (DialogBoxParam(hInst, MAKEINTRESOURCE(DTCREATE),hwndFrame, + (DLGPROC) fnInsertNew, (LONG)((LPSTR)szClassName)) != IDCANCEL) { if (pItem = PreItemCreate(lpClient, FALSE, lhcDoc)) { RegGetClassId(szServerName, szClassName); pItem->aServer = AddAtom(szServerName); - if ( Error( OleCreate(STDFILEEDITING,(LPOLECLIENT)&(pItem->oleclient), - (LPSTR)szClassName, lhcDoc,CreateNewUniqueName(szTmp), - &lpObject,olerender_draw, 0))) + if ( Error( OleCreate(STDFILEEDITING,(LPOLECLIENT)&(pItem->oleclient), + (LPSTR)szClassName, lhcDoc,CreateNewUniqueName(szTmp), + &lpObject,olerender_draw, 0))) { ErrorMessage(E_FAILED_TO_CREATE_OBJECT); FreeAppItem(pItem); @@ -525,7 +525,7 @@ VOID FAR ObjInsert( / else PostItemCreate(lpObject, OT_EMBEDDED, NULL, pItem); } - } + } } @@ -533,13 +533,13 @@ VOID FAR ObjInsert( / /*************************************************************************** * ObjDelete() * - * Delete an OLE object. For this application, all OLE objects - * are associated with a child window; therefore the window must be + * Delete an OLE object. For this application, all OLE objects + * are associated with a child window; therefore the window must be * destroyed. * * NOTE: There is one case when we call OleRelease and the other when * we call OleDelete. We call OleRelease when we are deregistering - * a document and OleDelete when removing an object from a document. + * a document and OleDelete when removing an object from a document. **************************************************************************/ VOID FAR ObjDelete( //* ENTRY: @@ -554,7 +554,7 @@ VOID FAR ObjDelete( / WaitForObject(pItem); } - if (fDelete ? Error(OleDelete(pItem->lpObject)) + if (fDelete ? Error(OleDelete(pItem->lpObject)) : Error(OleRelease(pItem->lpObject))) { ErrorMessage(E_FAILED_TO_DELETE_OBJECT); @@ -563,16 +563,16 @@ VOID FAR ObjDelete( / if (pItem->fVisible) { - ShowWindow(pItem->hwnd, SW_HIDE); + ShowWindow(pItem->hwnd, SW_HIDE); pItem->fVisible = FALSE; } //* the operation has to complete WaitForObject(pItem); //* before the application structure - - FreeAppItem(pItem); + + FreeAppItem(pItem); iObjects--; -} +} /*************************************************************************** @@ -586,10 +586,10 @@ VOID FAR ObjDelete( / **************************************************************************/ VOID FAR ObjPaste( //* ENTRY: - BOOL fPaste, //* Paste/PasteLink flag + BOOL fPaste, //* Paste/PasteLink flag LHCLIENTDOC lhcDoc, //* client document handle LPOLECLIENT lpClient //* pointer to client -){ //* LOCAL: +){ //* LOCAL: LPOLEOBJECT lpObject; //* object pointer LONG otObject; //* object type APPITEMPTR pItem; //* application item pointer @@ -597,25 +597,25 @@ VOID FAR ObjPaste( / if (!(pItem = PreItemCreate(lpClient, TRUE, lhcDoc))) return; //* ERROR return - + if (!OpenClipboard(hwndFrame)) goto Error; //* ERROR jump - if (fPaste) //* PASTE the object. + if (fPaste) //* PASTE the object. { //* Try "StdFileEditing" protocol if (Error(OleCreateFromClip(STDFILEEDITING,(LPOLECLIENT)&(pItem->oleclient),lhcDoc, - CreateNewUniqueName(szTmp),&lpObject, olerender_draw,0))) + CreateNewUniqueName(szTmp),&lpObject, olerender_draw,0))) { //* next try "Static" protocol if (Error(OleCreateFromClip( STATICP, (LPOLECLIENT)&(pItem->oleclient), lhcDoc, - CreateNewUniqueName(szTmp), &lpObject, olerender_draw, 0))) + CreateNewUniqueName(szTmp), &lpObject, olerender_draw, 0))) goto Error; //* ERROR jump } - } - else - { //* LINK therefore must be + } + else + { //* LINK therefore must be // "STdFileEditing" protocol if (Error(OleCreateLinkFromClip( STDFILEEDITING,(LPOLECLIENT)&(pItem->oleclient), lhcDoc, @@ -638,7 +638,7 @@ Error: / ErrorMessage(E_GET_FROM_CLIPBOARD_FAILED); CloseClipboard(); FreeAppItem(pItem); - + return; //* ERROR return } @@ -656,8 +656,8 @@ BOOL FAR ObjCopy( / APPITEMPTR pItem //* pointer to app item ){ //* LOCAL: BOOL fReturn = TRUE; //* return value - - if (!OpenClipboard(hwndFrame)) + + if (!OpenClipboard(hwndFrame)) return FALSE; //* ERROR return EmptyClipboard(); @@ -685,14 +685,14 @@ VOID FAR ObjCreateFromTemplate( / CHAR szTmp[CBOBJNAMEMAX]; //* temporary object name string CHAR szFileName[CBPATHMAX];//* file name string - *szFileName = NULL; + *szFileName = 0; if (!OfnGetName(hwndFrame, szFileName, IDM_INSERTFILE)) return; //* ERROR operation aborted by user if (!(pItem = PreItemCreate(lpClient, FALSE, lhcDoc))) return; //* ERROR - + if (Error(OleCreateFromTemplate(STDFILEEDITING, (LPOLECLIENT)pItem, szFileName, lhcDoc, CreateNewUniqueName(szTmp), &lpObject, olerender_draw, 0))) { @@ -708,7 +708,7 @@ VOID FAR ObjCreateFromTemplate( / /**************************************************************************** * ObjGetData() - * + * * Get the object link data. The data that is retrieved from OLE is copied * into lpLinkData if lpLinkData is not NULL. Otherwise, space is dynamically * allocated or reallocated; space is allocated if pItem->lpLinkData is NULL @@ -720,14 +720,14 @@ BOOL FAR ObjGetData( / APPITEMPTR pItem, //* OLE object LPSTR lpLinkData //* pointer to linkdata ){ //* LOCAL: - HANDLE hData; //* handle to OLE link data + HANDLE hData; //* handle to OLE link data LPSTR lpData; //* pointer to OLE link data LPSTR lpWork; //* copy of OLE link data BOOL fFree = FALSE; //* free OLE memory flag LONG lSize; //* size of OLE link data INT i; - - switch (Error(OleGetData(pItem->lpObject, + + switch (Error(OleGetData(pItem->lpObject, (OLECLIPFORMAT)(pItem->otObject == OT_LINK ? vcfLink : vcfOwnerLink), &hData))) { case OLE_WARN_DELETE_DATA: @@ -737,7 +737,7 @@ BOOL FAR ObjGetData( / { //* copy the link data to new buffer lSize=SizeOfLinkData(lpData); - + if (!lpLinkData) { if (!pItem->lpLinkData) //* allocate @@ -750,18 +750,18 @@ BOOL FAR ObjGetData( / lpWork = lpLinkData; if (lpWork) - for (i=0L; i<(INT)lSize; i++) + for (i=0L; i<(INT)lSize; i++) *(lpWork+i)=*(lpData+i); GlobalUnlock(hData); //* free the linked data as needed if (fFree) GlobalFree(hData); - return TRUE; //* SUCCESS + return TRUE; //* SUCCESS } default: return FALSE; //* FAILURE - } + } } @@ -769,38 +769,39 @@ BOOL FAR ObjGetData( / * ObjChangeLink() * * Change the linkdata. This routine will change the document portion of - * link data to lpDoc. The old linkdata is expected to be in - * lpaItem->lpLinkData + * link data to lpDoc. The old linkdata is expected to be in + * lpaItem->lpLinkData **************************************************************************/ VOID FAR ObjChangeLinkData( //* ENTRY: - APPITEMPTR pItem, //* OLE object + APPITEMPTR pItem, //* OLE object LPSTR lpDoc //* document name ){ //* LOCAL: LONG lSize; //* used to link data size LPSTR lpLinkData; //* OLE link data pointer static CHAR pWork[OBJECT_LINK_MAX]; //* used to construct new link data INT i; //* index - + HANDLE hData; + pItem->aLinkName = AddAtom(lpDoc); for ( - lpLinkData = pItem->lpLinkData, i=0; - pWork[i] = *lpLinkData; + lpLinkData = pItem->lpLinkData, i=0; + pWork[i] = *lpLinkData; lpLinkData++, i++ ); //* into working buffer. - lstrcpy((LPSTR)&pWork[++i],lpDoc); //* copy new document name. - + lstrcpy((LPSTR)&pWork[++i],lpDoc); //* copy new document name. + for (; pWork[i]; i++); //* skip to end of document name for (++lpLinkData;*lpLinkData;lpLinkData++); //* copy item name. lstrcpy((LPSTR)&pWork[++i],++lpLinkData); for (; pWork[i]; i++); //* skip to end of buffer //* which is the end of item info. - pWork[++i] = NULL; //* add extra null. + pWork[++i] = 0; //* add extra null. - lSize = SizeOfLinkData(pWork); //* reallocate space so there is + lSize = SizeOfLinkData(pWork); //* reallocate space so there is ReallocLinkData(pItem,lSize); //* a properly sized block of info //* to send the linked data to the if (lpLinkData = pItem->lpLinkData) //* OLE DLL. @@ -808,18 +809,29 @@ VOID FAR ObjChangeLinkData( / *lpLinkData++ = pWork[i]; else return; //* ERROR return - + Error(OleSetData(pItem->lpObject, vcfLink, GlobalHandle(pItem->lpLinkData))); - + + /* + * The handle passed into OleSetData is owned by the OLE client library + * and should not be used after the call. On win32s, it is inaccessible + * after the call, so restore it by calling OleGetData. Note that the + * data is *still* owned by the library, but we will now have access + * to the memory. + */ + Error(OleGetData(pItem->lpObject, vcfLink, &hData)); + if (hData) { + pItem->lpLinkData = GlobalLock(hData); + } } //* SUCCESS return /**************************************************************************** * ObjSaveUndo() * * Clone the OLE object so that any changes to object can be undone if the - * user choses to exit without update. + * user choses to exit without update. ***************************************************************************/ - + VOID FAR ObjSaveUndo( //* ENTRY: APPITEMPTR pItem //* application item ){ //* LOCAL: @@ -830,9 +842,9 @@ VOID FAR ObjSaveUndo( / if (!pItem->lpObjectUndo) { OleQueryName(pItem->lpObject, szTmp, &i); - //* give clone a unique name by + //* give clone a unique name by //* altering object name prefix. - for (lpClone = OBJCLONE, i=0; *lpClone; szTmp[i++] = *lpClone++); + for (lpClone = OBJCLONE, i=0; *lpClone; szTmp[i++] = *lpClone++); if (Error(OleClone(pItem->lpObject, (LPOLECLIENT)pItem, pItem->lhcDoc, szTmp, &(pItem->lpObjectUndo)))) @@ -846,7 +858,7 @@ VOID FAR ObjSaveUndo( / if (OleQueryOpen(pItem->lpObject) == OLE_OK) pItem->fOpen = TRUE; - + } } //* SUCCESS return @@ -854,22 +866,22 @@ VOID FAR ObjSaveUndo( / /**************************************************************************** * ObjUndo() * - * Restore an object to its state before changes. The lpObject Undo is a + * Restore an object to its state before changes. The lpObject Undo is a * clone to the original object with a different name, therefore, all we * have to do is rename that object and ditch the changed object. ***************************************************************************/ - + VOID FAR ObjUndo( //* ENTRY: APPITEMPTR pItem //* application item ){ //* LOCAL: CHAR szTmp[CBOBJNAMEMAX]; //* object name holder UINT i = CBOBJNAMEMAX; - + OleQueryName(pItem->lpObject, szTmp, &i); if (Error(OleDelete(pItem->lpObject))) return; //* ERROR return //* reset app item vars - pItem->lpObject = pItem->lpObjectUndo; + pItem->lpObject = pItem->lpObjectUndo; pItem->otObject = pItem->otObjectUndo; pItem->uoObject = pItem->uoObjectUndo; pItem->aLinkName = pItem->aLinkUndo; @@ -886,7 +898,7 @@ VOID FAR ObjUndo( / } SetWindowPos( - pItem->hwnd, + pItem->hwnd, NULL, 0, 0, pItem->rect.right - pItem->rect.left + 2*GetSystemMetrics(SM_CXFRAME), pItem->rect.bottom - pItem->rect.top + 2*GetSystemMetrics(SM_CYFRAME), @@ -915,7 +927,7 @@ VOID FAR ObjDelUndo( / pItem->otObjectUndo = (LONG)NULL; DeleteAtom(pItem->aLinkUndo); pItem->lpObjectUndo = NULL; - + } //* SUCCESS return /**************************************************************************** @@ -923,7 +935,7 @@ VOID FAR ObjDelUndo( / * * Convert an object to a static object. ***************************************************************************/ - + VOID FAR ObjFreeze( //* ENTRY: APPITEMPTR pItem //* application item ){ //* LOCAL: @@ -931,11 +943,11 @@ VOID FAR ObjFreeze( / LPSTR lpTemp; //* temporary prefix string LPOLEOBJECT lpObjectTmp; //* temporary object pointer UINT i=CBOBJNAMEMAX; - + OleQueryName(pItem->lpObject, szTmp, &i); - //* create a unique name by changing + //* create a unique name by changing //* the object name prefix - for (lpTemp = OBJTEMP, i=0; *lpTemp; szTmp[i++] = *lpTemp++); + for (lpTemp = OBJTEMP, i=0; *lpTemp; szTmp[i++] = *lpTemp++); //* this API creates a static object if (Error(OleObjectConvert(pItem->lpObject, STATICP, (LPOLECLIENT)pItem, @@ -945,17 +957,17 @@ VOID FAR ObjFreeze( / if (Error(OleDelete(pItem->lpObject))) return; - WaitForObject(pItem); + WaitForObject(pItem); pItem->lpObject = lpObjectTmp; pItem->otObject = OT_STATIC; pItem->uoObject = -1L; - for (lpTemp = OBJPREFIX, i=0; *lpTemp; szTmp[i++] = *lpTemp++); + for (lpTemp = OBJPREFIX, i=0; *lpTemp; szTmp[i++] = *lpTemp++); if (Error(OleRename(pItem->lpObject,szTmp))) return; - - + + } /*************************************************************************** @@ -971,18 +983,18 @@ VOID FAR ObjCreateWrap( / LHCLIENTDOC lhcDoc, //* document handle LPOLECLIENT lpClient //* pointer to client structure ){ //* LOCAL: - CHAR szDragDrop[CBPATHMAX];//* Drag and drop file name - LPOLEOBJECT lpObject; //* pointer to OLE object + CHAR szDragDrop[CBPATHMAX];//* Drag and drop file name + LPOLEOBJECT lpObject; //* pointer to OLE object POINT pt; //* position of dropped object - RECT rc; //* object size and position - CHAR szTmp[CBOBJNAMEMAX]; //* buffer for unique object name + RECT rc; //* object size and position + CHAR szTmp[CBOBJNAMEMAX]; //* buffer for unique object name APPITEMPTR pItem; //* application item pointer INT x,y; //* icon sizes - + x = GetSystemMetrics(SM_CXICON) / 2; y = GetSystemMetrics(SM_CYICON) / 2; //* Get the drag and drop filename - //* position + //* position DragQueryPoint(hdrop, &pt); DragQueryFile(hdrop, 0, szDragDrop, CBPATHMAX); DragFinish(hdrop); @@ -992,8 +1004,8 @@ VOID FAR ObjCreateWrap( / if (!(pItem = PreItemCreate(lpClient, TRUE, lhcDoc))) return; //* ERROR return //* create OLE object - if (Error(OleCreateFromFile(STDFILEEDITING, (LPOLECLIENT)pItem, - "Package", szDragDrop, lhcDoc, CreateNewUniqueName(szTmp), + if (Error(OleCreateFromFile(STDFILEEDITING, (LPOLECLIENT)pItem, + "Package", szDragDrop, lhcDoc, CreateNewUniqueName(szTmp), &lpObject, olerender_draw, 0))) { ErrorMessage(E_FAILED_TO_CREATE_OBJECT); @@ -1001,9 +1013,9 @@ VOID FAR ObjCreateWrap( / return; //* ERROR return } - if (PostItemCreate(lpObject, OT_EMBEDDED, &rc, pItem)) + if (PostItemCreate(lpObject, OT_EMBEDDED, &rc, pItem)) ShowNewWindow(pItem); - + } //* SUCCESS return /*************************************************************************** @@ -1011,7 +1023,7 @@ VOID FAR ObjCreateWrap( / * * Add an object popup menu for the chosen object if multiple verbs exist. * The registration system is used to determine which verbs exist for the - * given object. + * given object. **************************************************************************/ VOID FAR UpdateObjectMenuItem( //* ENTRY: @@ -1025,28 +1037,28 @@ VOID FAR UpdateObjectMenuItem( / HMENU hPopupNew=NULL; HKEY hkeyTemp; CHAR pLinkData[OBJECT_LINK_MAX]; - //* delete current item and submenu + //* delete current item and submenu DeleteMenu(hMenu, POS_OBJECT, MF_BYPOSITION ); - + if (!(pItem = GetTopItem()) ) goto Error; //* ERROR jump else if (!pItem->fVisible) goto Error; //* ERROR jump //* if STATIC ? - if ((pItem->otObject != OT_EMBEDDED) && (pItem->otObject != OT_LINK)) + if ((pItem->otObject != OT_EMBEDDED) && (pItem->otObject != OT_LINK)) goto Error; //* ERROR jump if (!ObjGetData(pItem, pLinkData)) //* get linkdata as key reg database goto Error; //* ERROR jump - //* open reg database - szClass[0] = NULL; - if (RegOpenKey(HKEY_CLASSES_ROOT, szClass, &hkeyTemp)) + //* open reg database + szClass[0] = 0; + if (RegOpenKey(HKEY_CLASSES_ROOT, szClass, &hkeyTemp)) goto Error; //* ERROR jump //* check if class is reg-db if (RegQueryValue(HKEY_CLASSES_ROOT, pLinkData, szClass, &dwSize)) { RegCloseKey(hkeyTemp); - goto Error; //* ERROR jump + goto Error; //* ERROR jump } for (cVerbs=0; ;++cVerbs) //* extract all verbs from reg-db @@ -1075,7 +1087,7 @@ VOID FAR UpdateObjectMenuItem( / break; case 1: //* one - wsprintf(szBuffer, "%s %s %s", (LPSTR)szVerb, (LPSTR)szClass, + wsprintf(szBuffer, "%s %s %s", (LPSTR)szVerb, (LPSTR)szClass, (LPSTR)"&Object"); DestroyMenu(hPopupNew); InsertMenu(hMenu, POS_OBJECT, MF_BYPOSITION, IDM_VERBMIN, szBuffer); @@ -1085,14 +1097,14 @@ VOID FAR UpdateObjectMenuItem( / wsprintf(szBuffer, "%s %s", (LPSTR)szClass, (LPSTR)"&Object"); InsertMenu(hMenu, POS_OBJECT, MF_BYPOSITION | MF_POPUP, (UINT)hPopupNew, szBuffer); EnableMenuItem(hMenu, POS_OBJECT, MF_ENABLED|MF_BYPOSITION); - break; + break; } RegCloseKey(hkeyTemp); //* close reg-db return; //* SUCCESS return Error: //* ERROR tag - InsertMenu(hMenu, POS_OBJECT, MF_BYPOSITION, NULL, "&Object"); + InsertMenu(hMenu, POS_OBJECT, MF_BYPOSITION, 0, "&Object"); EnableMenuItem(hMenu, POS_OBJECT, MF_GRAYED | MF_BYPOSITION); } //* ERROR return @@ -1117,13 +1129,13 @@ VOID FAR ExecuteVerb( / //* get cliet area rectangle GetClientRect(hwndFrame, (LPRECT)&rc); //* execute OLE verb - if (Error(OleActivate(pItem->lpObject, iVerb, TRUE, TRUE, hwndFrame, &rc))) + if (Error(OleActivate(pItem->lpObject, iVerb, TRUE, TRUE, hwndFrame, &rc))) return; - + WaitForObject(pItem); //* wait for async. operation ObjSetBounds(pItem); - + } //* SUCCESS return @@ -1137,9 +1149,9 @@ VOID FAR ExecuteVerb( / * Returns BOOL - TRUE if successful. ***************************************************************************/ BOOL FAR ObjSetBounds( //* ENTRY: - APPITEMPTR pItem //* application item pointer + APPITEMPTR pItem //* application item pointer ){ //* LOCAL: - RECT itemRect; //* bounding rectangle + RECT itemRect; //* bounding rectangle GetWindowRect(pItem->hwnd,&itemRect);//* get item window react @@ -1151,9 +1163,9 @@ BOOL FAR ObjSetBounds( / itemRect.right = MulDiv ((itemRect.right - itemRect.left), HIMETRIC_PER_INCH, giXppli); itemRect.bottom = - MulDiv((itemRect.bottom - itemRect.top), - HIMETRIC_PER_INCH, giYppli); - itemRect.top = NULL; - itemRect.left = NULL; + HIMETRIC_PER_INCH, giYppli); + itemRect.top = 0; + itemRect.left = 0; //* set the rect for the server if (Error(OleSetBounds(pItem->lpObject,(LPRECT)&itemRect))) return FALSE; //* ERROR return