要完成一个类似word的文档结构图,在点击toolbar上的按钮后,左边弹出一个dialog,里面有listcontrol,这个已经完成了,但是如何调整位置。我不想把它在左边显示,想在最下面显示。
  CCoolDialogBar   wndDialogBar2;(CCoolDialogBar继承CControlBar,IDD_DIALOG3为我插入的dialog的id,在此dialog的类名为CTestListControl,还加入了listcontrol控键)  //创建toolbar上的一个消息,通过点击toolbar上的控键来弹出对话框
void CMainFrame::OnButtonShowListView()
{
if(::IsWindow(m_wndDialogBar2))
{
ShowControlBar(&m_wndDialogBar2, TRUE, FALSE);
return;
} if (!m_wndDialogBar2.Create(this, &m_cListCtrlDialog, CString(""), IDD_DIALOG3))
{
TRACE0("Failed to create dialogbar\n");
return;      // fail to create
}    m_wndDialogBar2.SetBarStyle(m_wndDialogBar2.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC);
m_wndDialogBar2.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndDialogBar2);
}//显示对话框的消息
void   CTestListControl::OnSize(UINT   nType,   int   cx,   int   cy) 

   CDialog::OnSize(nType,   cx,   cy);    MoveWindow(0,400,200,400);                  //该句只能修改ListControl的显示位置,并不能修改dialog的显示位置,我想做成像VC中点击debug时下面弹出的界面那种形式
   if(m_CListCtrl.GetSafeHwnd()) 
   { 
    CRect       rect;       
    GetClientRect(&rect);       
    m_CListCtrl.MoveWindow(rect);     
   }  
}

解决方案 »

  1.   

    你描述的不是很清楚你的需求是在一个sdi的程序中,点击工具栏的按钮弹出一个对话框(包含CListCtrl控件),希望该对话框能够显示在sdi界面的最下面,是这个意思吧?顺便问下你的CTestListControl是个什么类啊?
      

  2.   

    CTestListControl是继承的CDialog,是希望对话框能够在最下面显示
      

  3.   

    你是说dialog显示在下面还是别的什么东西?MoveWindow应该可以满足要求
      

  4.   

    用VC6测试了一下,在SDI程序中通过点击工具栏按钮显示一个对话框,对话框显示在SDI框架底部
    对话框用的是非模态对话,在工具栏按钮响应函数中:
    //////////////////
    if(m_bShow)  //用bool变量m_bShow控制对话框的显示与隐藏
    {
        m_dlgTest.Create(IDD_DIALOG1,this);
        m_bShow = false;
        m_dlgTest.ShowWindow(SW_SHOW);
    }
    else
    {
        m_dlgTest.DestroyWindow();
        m_bShow = true;
    }
    ////////////////要改变对话框显示的位置和大小,可以用MoveWindow或SetWindowPos实现
    但必须在对话框的OnInitDialog函数中添加上两个函数,在函数OnInitDialog中:
    ///////////////////
    CRect rectparent,rectdlg;
    theApp.m_pMainWnd->GetWindowRect(&rectparent);
    GetClientRect(&rectdlg);rectdlg.left = rectparent.left+4;
    rectdlg.top = rectparent.Height()/2+rectparent.top;
    rectdlg.right = rectparent.right-3;
    rectdlg.bottom = rectparent.bottom-3;
    SetWindowPos(&wndTopMost,rectdlg.left,rectdlg.top,rectdlg.Width(),rectdlg.Height(),NULL);
    ///////////////////控制对话框显示在SDI的底部,并且一直为TopMost
      

  5.   

    使用CControlBar,你可以先派生一个类从CControlBar下来。假定为CMyControlBar。
    然后你添加Dialog作为CMyControlBar的Member,然后再CMyControlBar的OnCreate里面Create Dialog。
    SDI的FrameWnd中定义CMyControlBar的对象作为FrameWnd的一个Member。
    使用DockControlBar对CMyControlBar的对象进行停靠。
    DockControlBar中就有参数决定停靠在框架窗口的那一个部分。