15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Button in a Property sheet

Gladys Chan -- Gladys@btw.com
Friday, June 21, 1996


MFC4.0/VC++4.1; Win95

CPropertySheet provides four default buttons (OK, Cancel, Apply and   
Help).  I want to add an additional button placing on the left of the OK   
button but have hard time finding the correct CRect position.  Does   
anyone know how?
TIA!

Gladys  



Rob den Breejen -- robb@and.nl
Monday, June 24, 1996

[Mini-digest: 2 responses]
[There was a third answer, but the sender didn't try it, and it definitely
didn't work.]

I always use the following code to locate a control with the given ID:

CWnd *CMainFrame::GetRectPosition(CRect *rcRect, int nID, CWnd *pParentWnd)
{
    CRect   rcParent;
    CWnd    *pWnd;
    
    pWnd = pParentWnd->GetDlgItem(nID);
    if(pWnd)
    { 
        pParentWnd->GetClientRect(&rcParent);
        pParentWnd->ClientToScreen(&rcParent);
        CPoint Offset=rcParent.TopLeft();        
               
        pWnd->GetWindowRect(rcRect);
        rcRect->OffsetRect(-Offset);
        
        return pWnd;
    }           
    
    return NULL;                   
    
}   // GetRectPosition()

--Rob den Breejen.
-----From: Akshay_Patel@pcmailgw.ml.com

     MFC 2.5/VC++1.52C; Windows 3.1
     
     Following code I used to move Cancel button on propety sheet at perticular 
     position.

     CButton *pCancelButton = (CButton *)GetDlgItem(IDCANCEL);
     
     CRect rcPropSht, rcBtn, rcBtnPos;
     GetWindowRect(&rcPropSht);
     pCancelButton->GetWindowRect(&rcBtn);
        
     //move cancel button to left
     rcBtnPos.left  = int(rcPropSht.Width()/6) - int(rcBtn.Width()/2);
     rcBtnPos.top   = rcBtn.top - rcPropSht.top -                               
                     GetSystemMetrics(SM_CYCAPTION) -                           
                     GetSystemMetrics(SM_CYDLGFRAME);
     rcBtnPos.right = rcBtnPos.left + 10;
     rcBtnPos.bottom= rcBtnPos.top + 10;
     pCancelButton->MoveWindow(&rcBtnPos, FALSE);

     This sample code might be helpful to move any button on property sheet.

     Akshay Patel


______________________________ Reply Separator _________________________________
Subject: Button in a Property sheet
Author:  mfc-l@netcom.com at UNIXGTWY
Date:    6/21/96 11:22 AM


     
MFC4.0/VC++4.1; Win95
     
CPropertySheet provides four default buttons (OK, Cancel, Apply and   
Help).  I want to add an additional button placing on the left of the OK   
button but have hard time finding the correct CRect position.  Does   
anyone know how?
TIA!
     
Gladys  





| Вернуться в корень Архива |