要完成一个类似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);
}
}
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);
}
}
解决方案 »
- VC MFC中如何将数据库查询结果输出到WORD和Excel中并绘制成表格
- 请问下,在VC下,要实现可编辑表格的功能该用什么控件
- 关于ActiveX引入FormView结构技术出错?????
- 请问Product Development Engineer(产品开发工程师)主要做什么??
- 自动更新EditBox时间的方法????
- 如何将24位位图转换为4位、2位和1位位图?
- 在调试记录集类(RecordSet)出现的问题,如何调试在哪里出错的,详见代码
- 如何处理透明色
- getscrollinfo应该怎么用呀?
- vc中嵌入汇编程序怎么声明汇编代码中的函数?
- Mscomm控件,接收数据时不能触发oncomm消息?急问
- 怎样改变MFC对话框的 classname
对话框用的是非模态对话,在工具栏按钮响应函数中:
//////////////////
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
然后你添加Dialog作为CMyControlBar的Member,然后再CMyControlBar的OnCreate里面Create Dialog。
SDI的FrameWnd中定义CMyControlBar的对象作为FrameWnd的一个Member。
使用DockControlBar对CMyControlBar的对象进行停靠。
DockControlBar中就有参数决定停靠在框架窗口的那一个部分。