热情软件屋

 

如何创建不能用鼠标移动的分割条


编号:QA002718
建立日期: 2000年3月12日 最后修改日期:2000年3月12日
所属类别:

李斌:
    操作系统: win98/NT
    编程工具: VC++5.0
    问题: 如何创建不能用鼠标移动的分割条?(固定位置的分割条CSplitteWnd)

回答:

    下面的方法摘自微软的Knowledge Base的文章:“Q105150 OWTO: Prevent Static Splitter Bars from Tracking”
    


    

    SUMMARY
    =======
    In addition to providing the ability to dynamically split a single view, the CSplitterWnd class provides a convenient method of displaying two or more view classes in a single frame. This type of splitter window is called a "static splitter." The CSplitterWnd class contains member functions that allow the splitter bar to be dragged by the mouse or moved using the keyboard to change the proportionate sizes of the views (or panes, in splitter terminology) within the frame.
    Sometimes it is desirable to fix the initial position of the splitter bars and not allow the user to move them. This can be accomplished simply by deriving a class from CSplitterWnd and overriding several members. This method is outlined below.
    
    MORE INFORMATION
    ================
    1. Use ClassWizard to create a new class named CMySplitterWnd of class type "generic CWnd" and change the references to CWnd in the class declaration and BEGIN_MESSAGE_MAP macro to CSplitterWnd.
    2. Using ClassWizard, create message handlers for WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_MOUSEMOVE. Bypass the CSplitterWnd functionality in each of these overrides by calling the corresponding CWnd handlers. The following example illustrates the WM_LBUTTONDOWN handler:
    
     void CMySplitterWnd::OnLButtonDown(UINT nFlags, Cpoint point)
     {
     CWnd::OnLButtonDown(nFlags, point);
     }
    
    3. Change any embedded CSplitterWnd members of your frame class to type CMySplitterWnd.
    4. Remove any menu items that generate a ID_WINDOW_SPLIT command (such as the "Split" item on the VIEWEX sample's "Window" menu). This prevents CView::OnSplitCmd() from being called.
    

此问题由李海回答。

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio