1
申明全局变量,全局函数一定要在cpp中申明
其他类引用该全局变量就include该cpp的h文件
然后extern一下就好了
否则容易出现该重复定义错误
例如A.h中如果申明了全局变量int Global;
在B.h中include "A.h"
extern int Global;
则你include A.h相当于把A.h中全局变量的申明也include进来了,编译器就会认为是重复定义
所以全局变量和函数申明一定要在cpp中
2
GetMouseMovePoints()这个API函数,可以获得鼠标当前以及历史的位置记录的,使用GetCursorPos获得鼠标指针位置,然后再利用ScreenToClient转换坐标到客户区坐标系(以窗口视区左上角为坐标原点,单位为像素),设该坐标为(POINT screenPt)。
/*--------以下内容来自MSDN-----------*/
GetMouseMovePointsEx
The GetMouseMovePointsEx function retrieves a history of up to 64 previous coordinates of the mouse or pen.
int GetMouseMovePointsEx( UINT cbSize // size of mouse move point LPMOUSEMOVEPOINT lppt, // current mouse move point LPMOUSEMOVEPOINT lpptBuf, // buffer to store points int nBufPoints, // points the buffer can store DWORD resolution // resolution of the points );
Parameters
-
cbSize
- [in] Specifies the size, in bytes, of the MOUSEMOVEPOINT structure. lppt
-
[in] Pointer to a
MOUSEMOVEPOINT structure containing valid mouse coordinates (in screen coordinates). It may also contain a time stamp.
The GetMouseMovePointsEx function searches for the point in the mouse coordinates history. If the function finds the point, it returns the last nBufPoints prior to and including the supplied point.
If your application supplies a time stamp, the GetMouseMovePointsEx function will use it to differentiate between two equal points that were recorded at different times.
An application should call this function using the mouse coordinates received from the WM_MOUSEMOVE message and convert them to screen coordinates.
lpptBuf
- [in] Pointer to a buffer that will receive the points. It should be at least cbSize* nBuffPoints in size. nBufPoints
- [in] Specifies the number of points to retrieve. resolution
-
[in] Specifies the resolution desired. This parameter can be one of the following values.
Value Meaning GMMP_USE_DISPLAY_POINTS Retrieves the points using the display resolution. GMMP_USE_HIGH_RESOLUTION_POINTS Retrieves high resolution points. Points can range from zero to 65,535 (0xFFFF) in both x- and y-coordinates. This is the resolution provided by absolute coordinate pointing devices such as drawing tablets.
Return Values
If the function succeeds, the return value is the number of points in the buffer. Otherwise, the function returns –1. For extended error information, your application can call GetLastError. The GetLastError function may return the following error code.
Value | Meaning |
---|---|
GMMP_ERR_POINT_NOT_FOUND | The point specified by lppt could not be found or is no longer in the system buffer. |
Remarks
The system retains the last 64 mouse coordinates and their time stamps. If your application supplies a mouse coordinate to GetMouseMovePointsEx and the coordinate exists in the system's mouse coordinate history, the function retrieves the specified number of coordinates from the systems' history. You can also supply a time stamp, which will be used to differentiate between identical points in the history.
The GetMouseMovePointsEx function will return points that eventually were dispatched not only to the calling thread but also to other threads.
GetMouseMovePointsEx may fail or return erroneous values in the following cases:
- If negative coordinates are passed in the MOUSEMOVEPOINT structure.
- If GetMouseMovePointsEx retrieves a coordinate with a negative value.
These situations can occur if multiple monitors are present. To correct this, first call GetSystemMetrics to get the following values:
- SM_XVIRTUALSCREEN,
- SM_YVIRTUALSCREEN,
- SM_CXVIRTUALSCREEN, and
- SM_CYVIRTUALSCREEN.
Then, for each point that is returned from GetMouseMovePointsEx, perform the following transform:
int nVirtualWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN) ; int nVirtualHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN) ; int nVirtualLeft = GetSystemMetrics(SM_XVIRTUALSCREEN) ; int nVirtualTop = GetSystemMetrics(SM_YVIRTUALSCREEN) ; int cpt = 0 ; int mode = GMMP_USE_DISPLAY_POINTS ; MOUSEMOVEPOINT mp_in ; MOUSEMOVEPOINT mp_out[64] ; ZeroMemory(&mp_in, sizeof(mp_in)) ; mp_in.x = pt.x & 0x0000FFFF ;//Ensure that this number will pass through. mp_in.y = pt.y & 0x0000FFFF ; cpt = GetMouseMovePointsEx(&mp_in, &mp_out, 64, mode) ; for (int i = 0; i < cpt; i++) { switch(mode) { case GMMP_USE_DISPLAY_POINTS: if (mp_out[i].x > 32767) mp_out[i].x -= 65536 ; if (mp_out[i].y > 32767) mp_out[i].y -= 65536 ; break ; case GMMP_USE_HIGH_RESOLUTION_POINTS: mp_out[i].x = ((mp_out[i].x * (nVirtualWidth - 1)) - (nVirtualLeft * 65536)) / nVirtualWidth ; mp_out[i].y = ((mp_out[i].y * (nVirtualHeight - 1)) - (nVirtualTop * 65536)) / nVirtualHeight ; break ; } }
3 VC 调用 JS
m_ReUrl.Format("javascript:CategHandle('%d','%s','%d','yes')", /
g_nGroupIndex + 1,dlg.m_vFileGroup[g_nGroupIndex].strGroup,dlg.m_vFileGroup.size());
CComPtr<IDispatch> ppDisp = NULL;
m_browser->get_Document(&ppDisp);
if( ppDisp == NULL) return;CComPtr<IHTMLDocument2> ppDoc2 = NULL;
ppDisp->QueryInterface(IID_IHTMLDocument2, (void**)&ppDoc2 );
if(ppDoc2 == NULL) return;CComPtr<IHTMLWindow2> ppHtmlWindow = NULL;
ppDoc2->get_parentWindow(&ppHtmlWindow);
if( ppHtmlWindow == NULL ) return;CComBSTR bstrJsCode(m_ReUrl);
CComBSTR bstrJsLang("JavaScript");
COleVariant var;
HRESULT hr = ppHtmlWindow->execScript(bstrJsCode, bstrJsLang, &var );
More Particular Thing You can look :http://www.codeproject.com/KB/COM/jscalls.aspx
用户坐标系:也称为世界坐标系(WC:World Coordinate System)。用于定义用户整图或最高层图形结构,一般与用户定义形体和图素的坐标系一致,各种子图,图段,图经调用后都放在用户坐标系中的适当位置。用户可根据应用的情况选择相应的坐标,如直角坐标系、仿射坐标系、圆柱坐标系、求坐标系、极坐标系等。
观察坐标系:(VC:Viewing Coordinate System)可在用户坐标系的任何位置、任何方向定义。它有两个用途,一是用于指定裁剪空间,确定形体的哪一部分要显示输出;二是通过定义观察(投影)平面,把三维形体的用户坐标变换成规格化坐标。
规格化设备坐标系(NDC:Normalized Device Coordinate System)用来定义视图区,其取值范围一般约定为(0.0,0.0,0.0)到(1.0,1.0,1.0)。通过NDC进行坐标转换可提高应用程序的可移植性。
设备坐标系:(DC:Device Coordinate System)是图形输入输出设备的坐标系,如图形显示器有其特殊的坐标系。DC通常也是定义像素或位图的坐标系。
1. 如果世界坐标系和页面坐标系的原点都是在工作区左上角,那么他们相同。
2.如果页面坐标系和设备坐标系都是用像素作为度量单位,那么他们相同。
如果不同,设备坐标系 = 页面坐标系 × 每度量的像素数
逻辑单位(logical units)到设备单位(device units)的换算: pDC->LPtoDP(...);