一个基于对话框的工程
界面上有一个属性页CPropertySheet m_sheet
另外设计了3个CPropertyPage m_Page1, m_Page2, m_Page3
然后在Dlg的InitDialog里面加入如下的代码,试图显示成属性页的样子,
m_sheet.AddPage (&m_Page1);
m_sheet.AddPage (&m_Page2);
m_sheet.AddPage (&m_Page3);
m_sheet.Create(this, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT);
RECT rect;
GetWindowRect(&rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
m_sheet.SetWindowPos(NULL, 0, 0, width, height, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);的确是成功了,但是m_sheet在dlg的界面上显示的太小了,最后一句话似乎没有让m_sheet尽量撑满dlg的界面,请问高手,
该怎么写才能控制m_sheet的大小呢?
界面上有一个属性页CPropertySheet m_sheet
另外设计了3个CPropertyPage m_Page1, m_Page2, m_Page3
然后在Dlg的InitDialog里面加入如下的代码,试图显示成属性页的样子,
m_sheet.AddPage (&m_Page1);
m_sheet.AddPage (&m_Page2);
m_sheet.AddPage (&m_Page3);
m_sheet.Create(this, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT);
RECT rect;
GetWindowRect(&rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
m_sheet.SetWindowPos(NULL, 0, 0, width, height, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);的确是成功了,但是m_sheet在dlg的界面上显示的太小了,最后一句话似乎没有让m_sheet尽量撑满dlg的界面,请问高手,
该怎么写才能控制m_sheet的大小呢?
解决方案 »
- Visual 2005\VC\PlatformSDK\include\winnt.h(256) : error C2144: 语法错误 : “char”的前面应
- def文件报错。。
- IME(输入法)设计问题,编码通过字典转换,但怎么在ime中设置字典?
- 硬盘中安装MSDN2004,它提示要插入盘怎么办?
- Hotmail 升级到25M ,爽!大家顶住啊~
- 求助客户端连接线程,如何为客户端分配资源!
- 请问如何获取TreeCtrl控件中某项处在第几个子项和偏移量是多少?
- ******100分请教高手最简单的界面问题,超级简单,拿分太容易了,谢谢帮助******
- vc 2个字符串能否用逻辑运算符&&
- 请教高手一个非常菜的问题????请求高手一定要回答我呀~~~!!
- 急问,网络通信中有关文件的问题。多谢各位了
- 内存DC的问题
在初始化的时候使用MoveWindow或者SetWindowPos
从CPropertyPage 派生自己的CMyPropertyPage类
在初始化的时候使用MoveWindow或者SetWindowPos
你说的我听不懂啊,我的m_Page1,m_Page2,3都是从CPropertyPage派生来的,
怎么给它们写movewindow或者setwindowpos啊?
我尝试在它们的wm_initdialog消息里加入movewindow,可是没成功啊
能否给我一个完整的代码示例啊?
CPropertySheet中不设置大小,而是通过CPropertyPage派生类来处理设置大小的事务,重载OnShowWindow:
void CMyProp::OnShowWindow(BOOL bShow, UINT nStatus)
{
CPropertyPage::OnShowWindow(bShow, nStatus);
int nWidth = ///;
int nHeight = ///; if(bShow)
{
GetParent()->ShowWindow(SW_HIDE);
GetParent()->SetWindowPos(NULL,0,0,nWidth,nHeight,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
GetParent()->ShowWindow(SW_SHOW);
}
}
GetTabControl()->MoveWindow();
对于Page,可以在OnInitDialog中MoveWindow
你说的代码我试过了,这回不是m_sheet小了
而是太大了,显示的边框都没有,只有左边界和上边界,而下边和右边都消失了,界面里的按钮也是不能完全显示,半个半个的。
下面的全部代码:
在dlg的那oninitdialog函数里
m_sheet.AddPage(&m_page1);
m_sheet.AddPage(&m_page2);
m_sheet.Create(this, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT);
在page的onshowwindow函数里
CPropertyPage::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
RECT rect;
GetParent()->GetWindowRect(&rect);
int nWidth =rect.right-rect.left;
int nHeight =rect.bottom-rect.top;
if(bShow)
{
GetParent()->ShowWindow(SW_HIDE);
GetParent()->SetWindowPos (NULL,0,0,nWidth,nHeight,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
GetParent()->ShowWindow(SW_SHOW);
}
现在结贴。谢谢。