如何在CFormView中修复大小 [英] How can fix size in CFormView

查看:89
本文介绍了如何在CFormView中修复大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用文档模板技术编写了一个MDI应用程序.我的表单之一必须以固定大小"创建(我的视图类是从CFormView派生的),如何强制我以固定大小创建视图,而又没有受到尊重?
谢谢...

I wrote a MDI application with document-template technique. One of my form must be created in ''fixed size'' (my view class is derived from CFormView), how can I force my view create in fix size & no respectable?
thank you...

推荐答案

MDI应用程序中固定大小的子窗体没有任何意义,尤其是当您考虑Tile/Cascade或最小化时/normalize/最大化MDI子窗体的能力.

您应该考虑使用无模式对话框.此时,可以通过简单的属性设置使对话框的大小无法重新调整.

如果您坚持不遵循标准的MDI-child功能,则可以简单地处理各种组织事件,并从事物的自然顺序中忽略该窗口.我个人认为这是个坏主意.
A fixed-size child form in a MDI application doesn''t make any sense, especially when you consider the Tile/Cascade or minimize/normalize/maximize abilites of a MDI child form.

You should be considering the use of a modeless dialog box instead. At that point, you can make the dialog box not re-sizable by simple property settings.

If you insist on not adhering to the standard MDI-child functionality, you may be able to simply handle the various organizing events and omit that window from the natural order of things. Personally, I think that''s a bad idea.


:-O
我找到了答案和测试代码,这是正确的,
//==================================
//大小和修复模式
//我的子框架类是:
类CDBChild:公共 CMDIChildWnd

//在我的表单视图类中:
CDBView类:public CFormView

//在函数中:
无效的CDBView :: OnInitialUpdate ()

//使用以下代码:
RECT sz_window,sz_panel;
GetDlgItem(IDC_STATIC_DB_PANEL)-> GetWindowRect(& sz_panel);
GetParent()-> ModifyStyle(WS_OVERLAPPEDWINDOW,WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);

CDBChild * pChild =(((CDBChild *)GetParent());
ScreenToClient((LPRECT)& sz_panel);
//sz_window =(((CDBChild *)GetParent())-> m_Rect;
const int nHashie = 9;
sz_window = sz_panel;
sz_window.bottom + =(2 * nHashie + 2 * 8 + 1 * 28);//sz_panel.bottom-sz_panel.top + 10;
sz_window.right + =(2 * nHashie + 2 * 8);//= sz_panel.right-sz_panel.left + 10;

GetParent()-> MoveWindow(& sz_window);
((CDBChild *)GetParent())-> ShowWindow(SW_RESTORE);
(((CDBChild *)GetParent())-> BringWindowToTop();


//使新窗口具有固定大小&无法调整大小.
//===================================
Hi, :-O
I found my answer and test code, it''s correct,
// ====================================
// Size & Fix Mode
// my child frame class is:
class CDBChild : public CMDIChildWnd

// in my form view class:
class CDBView : public CFormView

// in function:
void CDBView::OnInitialUpdate()

// with this code:
RECT sz_window,sz_panel;
GetDlgItem(IDC_STATIC_DB_PANEL)->GetWindowRect(&sz_panel);
GetParent()->ModifyStyle(WS_OVERLAPPEDWINDOW ,WS_BORDER |WS_CAPTION |WS_SYSMENU |WS_MINIMIZEBOX);

CDBChild* pChild = ((CDBChild*)GetParent());
ScreenToClient((LPRECT)&sz_panel);
// sz_window = ((CDBChild*)GetParent())->m_Rect;
const int nHashie = 9;
sz_window = sz_panel;
sz_window.bottom += (2*nHashie + 2*8 + 1*28);// sz_panel.bottom - sz_panel.top + 10;
sz_window.right += (2*nHashie + 2*8);// = sz_panel.right - sz_panel.left + 10;

GetParent()->MoveWindow(&sz_window);
((CDBChild*)GetParent())->ShowWindow(SW_RESTORE);
((CDBChild*)GetParent())->BringWindowToTop();


// make new window have fix size & not resizable.
// ====================================


这篇关于如何在CFormView中修复大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆