Changing the Text of Apply Now Bt
Ravi -- pakalr50@lnhdent.agw.bt.co.uk Thursday, April 11, 1996 Ravi Writes : VC++ (2.0) and Windows NT(3.5) In my application I need to add a Bt to the Property Sheet (This bt handles the command for all the Property Pages). I thought of changing the ApplyNow Bt's Text . I could not locate how I can achieve this. Can anybody help me in doing this. Thanks in Advance Ravi
Erik Heuer -- erik.heuer@ks-t.no Sunday, April 14, 1996 [Mini-digest: 3 responses] At 07:13 11.04.96 GMT, Ravi wrote: > >Ravi Writes : > VC++ (2.0) and Windows NT(3.5) > >In my application I need to add a Bt to the Property Sheet (This bt handles >the command for all the Property Pages). I thought of changing the > ApplyNow Bt's Text . I could not locate how I can achieve this. Can anybody >help me in doing this. Thanks in Advance > >Ravi > Override (using ClassWizard) CPropertySheet::OnCreate if you are using MFC3 or CPropertySheet::OnInitDialog if MFC4. Add the following: CWnd *pWnd = GetDlgItem(ID_APPLY_NOW); if (pWnd) pWnd->SetWindowText("Save"); // or whatever text you'd like However, I would not recommend using this method. Read the Books Online article about using property sheets and especially the part about adding controls to it, and add your own button in OnCreate. Erik Heuer, Kongsberg Simulation & Training, 3600 Kongsberg, Norway E-mail: erik.heuer@ks-t.no Phone:(+47) 32735766 Fax:(+47) 32736965 -----From: beriksen@cda.com given that pPropertySheet is a pointer to your property sheet, you can use the following code (I think): CString strApplyNowButtonText; strApplyNowButtonText = "My Apply Now Button Text"; pPropertySheet->SetDlgItemText(ID_APPLY_NOW,strApplyNowButtonText); This works in VC++4.0/Win95/WinNT/Win32s, but I'm not sure that it'll work in vc++2.0. You can grep the msdev\include directory for ID_APPLY_NOW and see if it's there. If it is, this should all work. Brian Eriksen CDA/Wiesenberger beriksen@cda.com -----From: Charles JowettI use the following code to rename the apply button in my application. BOOL CHistorianPropertySheet::OnInitDialog() { // Activate and change the title of the apply button. CWnd *RefreshButton = GetDlgItem( ID_APPLY_NOW ); RefreshButton->SetWindowText( "Refresh" ); RefreshButton->EnableWindow( TRUE ); return CPropertySheet::OnInitDialog(); } Charles jowett_charles@waters.com
Vincent Mascart -- 100425.1337@compuserve.com Tuesday, April 16, 1996 >From: "Pakala, Ravi" >Sent: dimanche 14 avril 1996 2:05 >Subject: Changing the Text of Apply Now Bt > >Ravi Writes : > VC++ (2.0) and Windows NT(3.5) > >In my application I need to add a Bt to the Property Sheet (This bt handles >the command for all the Property Pages). I thought of changing the > ApplyNow Bt's Text . I could not locate how I can achieve this. Can anybody >help me in doing this. Thanks in Advance > >Ravi Here is a sample code I use to change the apply button to a preview button. I placed the code in the .cpp file of my CPropertySheet derived class (CPESheet) : #ifndef IDC_PREVIEW #define IDC_PREVIEW 100 #endif ... BEGIN_MESSAGE_MAP(CPESheet, CPropertySheet) //{{AFX_MSG_MAP(CPESheet) ON_BN_CLICKED(IDC_PREVIEW, OnPreview) ON_WM_ACTIVATE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPESheet message handlers void CPESheet::OnPreview() { // Execute preview code ... } void CPESheet::UpdateButtons() { CWnd* pApply = GetDlgItem(ID_APPLY_NOW); if(pApply!=NULL) { CRect rect; pApply->GetWindowRect(&rect); ScreenToClient(&rect); m_PreviewBtn.Create("&Preview", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, rect, this, IDC_PREVIEW); m_PreviewBtn.SetFont(pApply->GetFont()); pApply->DestroyWindow(); } } void CPESheet::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { CPropertySheet::OnActivate(nState, pWndOther, bMinimized); UpdateButtons(); } HTH. Vincent Mascart - Little Indian sprl 100425.1337@compuserve.com
David Ohlssen -- DAVIDO@COMMERCE.CTECH.AC.ZA Friday, April 19, 1996 Vincent, I like your idea (seems brilliant), but just a tiny 2c: It looks like you have edited between the forbidden comments! You may not see a problem until the day you have to delete and rebuild the .clw file. Meantime, class wiz thinks that the code is still the way it left it :<. Also it maybe doesn't know what IDC_PREVIEW is. Suggest move the OnPreview line to below the //}}AFX_MSG_MAP but still within the message map. (One should obviously not override the Apply function, or delete it officially in the wiz if you have overridden it.) > Here is a sample code I use to change the apply button to a preview button. I > placed the code in the .cpp file of my CPropertySheet derived class (CPESheet) : > > #ifndef IDC_PREVIEW > #define IDC_PREVIEW 100 > #endif > > ... > > BEGIN_MESSAGE_MAP(CPESheet, CPropertySheet) > //{{AFX_MSG_MAP(CPESheet) > ON_BN_CLICKED(IDC_PREVIEW, OnPreview) > ON_WM_ACTIVATE() > //}}AFX_MSG_MAP > END_MESSAGE_MAP() David O. Ohlssen I _____________________________________ I I | Davido@Commerce.CTech.ac.ZA | I I | __ ____________ | I I | / \/ Cape Town \ _ | I I |__/ South Africa \/ \__________| I I_________________________________________I
| Вернуться в корень Архива |