--- mstools/samples/ole/clidemo/object.c 2018/08/09 18:20:49 1.1 +++ mstools/samples/ole/clidemo/object.c 2018/08/09 18:21:52 1.1.1.2 @@ -20,11 +20,17 @@ #include "utility.h" #include "register.h" +#define HIMETRIC_PER_INCH 2540 + //*** VARIABLES *** //*** Globals INT cOleWait = 0; +INT giXppli ; +INT giYppli ; + + /*************************************************************************** * CallBack() @@ -256,6 +262,7 @@ LONG APIENTRY ItemWndProc( // PAINTSTRUCT ps; //* paint structure POINT pt; //* point RECT rc; //* bounding rectangle +// char lpstr[256]; switch (msg) { @@ -319,8 +326,8 @@ LONG APIENTRY ItemWndProc( // ScreenToClient(hwndFrame, (LPPOINT)&dragRect); ScreenToClient(hwndFrame, (LPPOINT)&dragRect.right); - dragPt.x = LOWORD(lParam); - dragPt.y = HIWORD(lParam); + dragPt.x = (LONG)(SHORT)LOWORD(lParam); + dragPt.y = (LONG)(SHORT)HIWORD(lParam); ClientToScreen(hwnd, (LPPOINT)&dragPt); ScreenToClient(hwndFrame, (LPPOINT)&dragPt); @@ -341,9 +348,9 @@ LONG APIENTRY ItemWndProc( // case WM_MOUSEMOVE: if (!fCaptured) break; - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - + pt.x = (LONG)(SHORT)LOWORD(lParam); + pt.y = (LONG)(SHORT)HIWORD(lParam); + ClientToScreen(hwnd, (LPPOINT)&pt); ScreenToClient(hwndFrame, (LPPOINT)&pt); @@ -468,21 +475,21 @@ VOID FAR ConvertToClient( / LPRECT lprc //* pointer to bounding rectangle ){ //* LOCAL + //* 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 { - HDC hdc = GetDC(NULL); + //* 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->right -= lprc->left; - lprc->bottom -= lprc->top ; - lprc->top = lprc->left = NULL; - - SetMapMode ( hdc, MM_HIMETRIC ); - LPtoDP ( hdc, (LPPOINT)&lprc->right, 1 ); - - ReleaseDC(NULL, hdc); - } + lprc->left = 0; + lprc->top = 0; + } } /*************************************************************************** @@ -502,7 +509,7 @@ VOID FAR ObjInsert( / CHAR szTmp[CBOBJNAMEMAX]; //* buffer to unique object name if (DialogBoxParam(hInst, MAKEINTRESOURCE(DTCREATE),hwndFrame, - fnInsertNew, (LONG)((LPSTR)szClassName)) != IDCANCEL) + (DLGPROC) fnInsertNew, (LONG)((LPSTR)szClassName)) != IDCANCEL) { if (pItem = PreItemCreate(lpClient, FALSE, lhcDoc)) { @@ -520,7 +527,6 @@ VOID FAR ObjInsert( / } } - FreeProcInstance(lpfnInsertNew); } @@ -1130,26 +1136,24 @@ VOID FAR ExecuteVerb( / * * Returns BOOL - TRUE if successful. ***************************************************************************/ - BOOL FAR ObjSetBounds( //* ENTRY: APPITEMPTR pItem //* application item pointer ){ //* LOCAL: - RECT itemRect; //* bounding rectangle - HDC hdc; + RECT itemRect; //* bounding rectangle GetWindowRect(pItem->hwnd,&itemRect);//* get item window react - itemRect.right = ( itemRect.right - itemRect.left ) - 2 * GetSystemMetrics(SM_CXFRAME); - itemRect.bottom = ( itemRect.bottom - itemRect.top ) - 2 * GetSystemMetrics(SM_CYFRAME); + itemRect.right -= GetSystemMetrics(SM_CXFRAME); + itemRect.left += GetSystemMetrics(SM_CXFRAME); + itemRect.top += GetSystemMetrics(SM_CYFRAME); + itemRect.bottom -= GetSystemMetrics(SM_CYFRAME); + + 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; - - hdc = GetDC(NULL); - SetMapMode(hdc,MM_HIMETRIC); - - DPtoLP(hdc,(LPPOINT)&itemRect.right,1); - - ReleaseDC(NULL,hdc); //* set the rect for the server if (Error(OleSetBounds(pItem->lpObject,(LPRECT)&itemRect))) return FALSE; //* ERROR return @@ -1158,3 +1162,4 @@ BOOL FAR ObjSetBounds( / return TRUE; //* SUCCESS return } +