CFrameWnd* FloatControlBar( CControlBar * pBar, CPoint point, DWORD dwStyle = CBRS_ALIGN_TOP );point The location, in screen coordinates, where the top left corner of the control bar will be placed. 把这句ClientToScreen(&p);注释掉, point 相当于 CPoint p(0,0); 那么按照屏幕坐标系,当然是工具栏浮动在屏幕左上顶点了。 而加上那句之后,point就有值了,但这个指还是以屏幕为坐标的,所以运行后工具栏浮动有可能在窗口左上部某点。
CPoint p(0,0); //客户区左上点
ClientToScreen(&p); //屏幕上某点 这样注视你就明白了
ClientToScreen(&p); //获取窗口客户区左上顶点在屏幕中的位置
The ClientToScreen function converts the client coordinates of a specified point to screen coordinates.
//浮动工具栏
CPoint p(0,0);
ClientToScreen(&p);
m_wndDrawToolBar.EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndDrawToolBar,p);
这是我的代码
运行后工具栏浮动在窗口左上部某点
要把这句ClientToScreen(&p);注释掉,运行后工具栏浮动在屏幕左上顶点啊
这怎么解释啊
CFrameWnd* FloatControlBar( CControlBar * pBar, CPoint point, DWORD dwStyle = CBRS_ALIGN_TOP );point
The location, in screen coordinates, where the top left corner of the control bar will be placed.
把这句ClientToScreen(&p);注释掉, point 相当于 CPoint p(0,0); 那么按照屏幕坐标系,当然是工具栏浮动在屏幕左上顶点了。 而加上那句之后,point就有值了,但这个指还是以屏幕为坐标的,所以运行后工具栏浮动有可能在窗口左上部某点。
是不是说FloatControlBar()函数中的point默认是in screen coordinates的,把ClientToScreen(&p);注释掉后FloatControlBar()函数还是把p作为屏幕坐标处理?
是的,那个point默认就是屏幕坐标,你无论外面改成怎样,在framework 里面也会把point当成屏幕坐标来用的。所以,你传这个值的时候,需要把它转成 屏幕坐标。详细信息请参考 MSDN.