基于CFormView的单文本MFC程序框架,采用添加Property Page,为什么界面显示出来的page大小跟
我直接在VC编辑区资源的大小不一样呢??为了使显示大小跟我在VC的资源编辑区中的大小相近,我每次都要把资源对话框拉的很大才行??请教是为什么?有没有设置方法可以使用两者的大小保持一致呢??

解决方案 »

  1.   

    MoveWindow(.....) 
    或者
    SetWindowPos()
      

  2.   

    我解决过这个问题,这个是因为程序始终用的默认系统属性页。
    可以加入一些代码改变字体大小和属性页大小//////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////
    CXXProPage::CXXProPage(UINT nID) : CPropertyPage(nID)
    {
    m_FontSize = 20;
    m_Font.CreateFont(m_FontSize, 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 0, 0, _T("宋体"));
    }CXXProPage::~CXXProPage()
    {
    }
    /////////////////////////////////////////////////////////////////////////////
    // CXXProPagemessage handlers
    CXXProPage::OnInitDialog()
    {
    CPropertyPage::OnInitDialog(); GetClientRect(m_Rect);//窗口客户区大小,调整窗口大小时用
    return TRUE;// return TRUE unless you set the focus to a control
                // EXCEPTION: OCX Property Pages should return FALSE
    }void CXXProPage::OnSize(UINT nType, int cx, int cy) 
    {
    int dw = cx - m_Rect.Width();
    int dh = cy - m_Rect.Height();
    if (dw <= 0 || dh <= 0 || m_Rect.Height() == 0|| m_Rect.Width() == 0)
    return;//窗口最小化,不予处理
    CPropertyPage::OnSize(nType, cx, cy); for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow(GW_HWNDNEXT)) 
    {
    CRect rectControlWnd;
    pChild->GetWindowRect(rectControlWnd);
    ScreenToClient(&rectControlWnd);
    int dl = rectControlWnd.left * dw/(m_Rect.Width());
    int dr = rectControlWnd.right * dw/(m_Rect.Width());
    int dt = rectControlWnd.top * dh/(m_Rect.Height());
    int db = rectControlWnd.bottom * dh/(m_Rect.Height());
    rectControlWnd.left +=dl;
    rectControlWnd.right +=dr;
    rectControlWnd.top +=dt;
    rectControlWnd.bottom +=db;
    pChild->MoveWindow(rectControlWnd);
    pChild->SetFont(&m_Font, true);
    }
    GetClientRect(m_Rect); //GetWindowRect
    }