dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 7 FirstFirst 12345 ... LastLast
Results 16 to 30 of 92

Thread: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

  1. #16
    Join Date
    Sep 2019
    Posts
    24

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    CMFCBUTTON is a MFC class provided by miceosoft.i am just using it by including a header "afxbutton.h"

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    I tried that too by using create() method but unfortunately my button was not displayed on Sheet.."
    What exactly did you try?
    You never showed you actual code!
    So we have no idea how you implemented what are talking about!
    Victor Nijegorodov

  3. #18
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    CMFCBUTTON is a MFC class provided by miceosoft.i am just using it by including a header "afxbutton.h"
    MFC does NOT provide the CMFCBUTTON class. It does provide the CMFCButton class!
    Last edited by VictorN; October 1st, 2019 at 02:28 AM.
    Victor Nijegorodov

  4. #19
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,146

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    I tried that too by using create() method but unfortunately my button was not displayed on Sheet.. and can you please tell with line of code what you want to say above "you may have to use <pointer to the property sheet>::GetDlgItem()."
    How about you first try what I suggested? That is, put a button on one of the property pages and change its color.

    When you get that to work, we can show you how to do the same for a button on the property sheet.

  5. #20
    Join Date
    Sep 2019
    Posts
    24

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Its i think better to leave the loop.Please google CMFCBUTTON class you will find its a class provided by the Microsoft by just including a header afxbutton.h

  6. #21
    Join Date
    Sep 2019
    Posts
    24

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Ok arjay i will try that.bdw i have one button there on property page already and i am able to change its background color using setfacecolor() .You want me to add one new button on this propertypage and change its background color.Right?

  7. #22
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    Its i think better to leave the loop.Please google CMFCBUTTON class you will find its a class provided by the Microsoft by just including a header afxbutton.h
    Are you kidding?
    It is the quote from Microsoft afxbutton.h file:
    Code:
    // This is a part of the Microsoft Foundation Classes C++ library.
    // Copyright (C) Microsoft Corporation
    // All rights reserved.
    //
    // This source code is only intended as a supplement to the
    // Microsoft Foundation Classes Reference and related
    // electronic documentation provided with the library.
    // See these sources for detailed information regarding the
    // Microsoft Foundation Classes product.
    
    #pragma once
    
    #include "afxcontrolbarutil.h"
    #include "afxmenuimages.h"
    
    #ifdef _AFX_PACKING
    #pragma pack(push, _AFX_PACKING)
    #endif
    
    #ifdef _AFX_MINREBUILD
    #pragma component(minrebuild, off)
    #endif
    
    /*============================================================================*/
    // CMFCButton window
    
    class CMFCButton : public CButton
    {
    	DECLARE_DYNCREATE(CMFCButton)
    
    // Construction
    public:
    	CMFCButton();
    
    // Attributes
    There is a class CMFCButton, not CMFCBUTTON!
    Or you don't know the difference between capital and small (upper-/lower-case) letters?
    Victor Nijegorodov

  8. #23
    Join Date
    Sep 2019
    Posts
    24

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Yes its CMFCButton but please i am here looking for solution ,please tell that.already told you code is compiling successfully but not reflecting result by using setfacecolor() .if you can help than plz tell asap coz i am stucking in one of GUI redesign

  9. #24
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    Yes its CMFCButton but please i am here looking for solution ,please tell that.already told you code is compiling successfully but not reflecting result by using setfacecolor() .if you can help than plz tell asap coz i am stucking in one of GUI redesign
    Well, we could help you if you provided the meaningful info about what and how you tried

    Note that "code" you have posted:
    Quote Originally Posted by Sparsh_21j View Post
    Code:
    Bool MyPropertysheet :: OnInitDialog()
    {
        Bool bResult = Cpropertysheet :: OnInitDialog();
    
        CMFCBUTTON * but1 = (CMFCBUTTON *)GetDlgItem(IDOK);
        but1->MoveWindow(8,596,58,25) ;
    
        CMFCBUTTON * but2 = (CMFCBUTTON *)GetDlgItem(IDHELP);
        but2->MoveWindow(250,596,58,25) ;
    
        CMFCBUTTON * but3 = (CMFCBUTTON *)GetDlgItem(IDCANCEL);
        but3->MoveWindow(8,596,58,25) ;
    
        // Above code is successfully moving the buttons position 
    
        m_ok.SetFaceColor(RGB(255,102,0);
    
        /*m_ok has been declared of type CMFCBUTTON in header file of MyPropertysheet */
    
        return bResult ;
    }
     
    Void MyPropertysheet ::DoDataExchange(CDataExchange* pDX) 
    {
        Cpropertysheet:: DoDataExchange(pDX)
    
        DDX_Control(pDX, IDOK, m_ok);
    }
    
    //DoDataExchange(CDataExchange* pDX) declared in header file of MyPropertysheet
    is not a real code.
    What is Void?
    What is Bool?
    What is Cpropertysheet?
    What is CMFCBUTTON ?

    BTW, did you read the Microsoft Docs about CMFCButton::SetFaceColor (I posted you a link)?
    Victor Nijegorodov

  10. #25
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,146

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    Yes its CMFCButton but please i am here looking for solution ,please tell that.already told you code is compiling successfully but not reflecting result by using setfacecolor() .if you can help than plz tell asap coz i am stucking in one of GUI redesign
    We're trying to help, but you need to post real code. Spelling matters and where you put the code matters. For example, when you attempt to change the color on m_ok, it may not be a valid variable at the time you try to change its color or it may not be mapped to the property sheet ok button.

  11. #26
    Join Date
    Sep 2019
    Posts
    24

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Bool is the return type of OnInitDialog() method // declared in header file i.e MyPropertysheet.h

    Void is returne type of DoDataExchange() method //declared in header file i.e MyPropertysheet.h
    //DoDataExchange() basically maps m_ok to IDOK
    //m_ok is of type CMFCButton ,this is also declared in header file MyPropertysheet.h

    //Cpropertysheet is nothing ,i have spelled it here wrong but in my code it is CpropertySheet i.e an MFC class

    //CMFCBUTTON is nothing ,i have spelled it here wrong ,its CMFCButton in my code.

    //Simple explanation is that i have one variable m_ok of type CMFCButton and m_ok is mapped to IDOK ,but when i am using m_ok.SetFaceColor(RGB(255,102,0),Code is compiling successfully but result is not reflected.

  12. #27
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,554

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    Bool is the return type of OnInitDialog() method // declared in header file i.e MyPropertysheet.h

    Void is returne type of DoDataExchange() method //declared in header file i.e MyPropertysheet.h
    //DoDataExchange() basically maps m_ok to IDOK
    //m_ok is of type CMFCButton ,this is also declared in header file MyPropertysheet.h

    //Cpropertysheet is nothing ,i have spelled it here wrong but in my code it is CpropertySheet i.e an MFC class

    //CMFCBUTTON is nothing ,i have spelled it here wrong ,its CMFCButton in my code.

    //Simple explanation is that i have one variable m_ok of type CMFCButton and m_ok is mapped to IDOK ,but when i am using m_ok.SetFaceColor(RGB(255,102,0),Code is compiling successfully but result is not reflected.
    You've been asked several times to post real code. Not sure why you'd retype a bunch of invalid code rather than copy and paste the real thing.

  13. #28
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    Bool is the return type of OnInitDialog() method // declared in header file i.e MyPropertysheet.h
    It is wrong!
    OnInitDialog() mehod returns BOOL.

    Quote Originally Posted by Sparsh_21j View Post
    //m_ok is of type CMFCButton ,this is also declared in header file MyPropertysheet.h

    //Cpropertysheet is nothing ,i have spelled it here wrong but in my code it is CpropertySheet i.e an MFC class

    //CMFCBUTTON is nothing ,i have spelled it here wrong ,its CMFCButton in my code.

    //Simple explanation is that i have one variable m_ok of type CMFCButton and m_ok is mapped to IDOK ,but when i am using m_ok.SetFaceColor(RGB(255,102,0),Code is compiling successfully but result is not reflected.
    Just post your real code!
    Victor Nijegorodov

  14. #29
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,146

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Quote Originally Posted by Sparsh_21j View Post
    //Simple explanation is that i have one variable m_ok of type CMFCButton and m_ok is mapped to IDOK ,but when i am using m_ok.SetFaceColor(RGB(255,102,0),Code is compiling successfully but result is not reflected.
    Yes. I said the variable may not be valid at the time you set the color - it depends on where you do this.

    If you post your real code, we may be able to help.

  15. #30
    Join Date
    Sep 2019
    Posts
    24

    Re: Changing background Color of standard buttons (ok,cancel,help) of Cpropertysheet

    Code:
    //----------------------------------------------------------------//
    //Below is the code for .cpp file
    //----------------------------------------------------------------//
    //MyPropertySheet.cpp
    
    #include "stdafx.h"
    #include "MyPropertysheet.h"
    #include <ts/texttrans.h>
    #include <ts/mfc/tsmfcwinstack.h>
    
    IMPLEMENT_DYNAMIC(MyPropertysheet,CPropertySheet)
    
    MyPropertySheet :: MyPropertySheet(UINT nIdCaption,  Cwnd * pParentWnd,  UINT iSelectPage): CPropertySheet(pszCaption, pParentWnd, iSelectpage)
    {
        TSMFCWinStack :: winStack.push(this);
        AddPage(&mypage); 
        m_psh.dwFlags = m_psh.dwFlags | PSH_NOAPPLYNOW;
    }
    
    MyPropertySheet :: ~MyPropertySheet()
    {
        TSMFCWinStack :: winStack.pop(this);
    }
    
    Void MyPropertySheet:: DoDataExchange(CDataExchange* pDX)
    {
        CPropertySheet :: DoDataExchange(pDX);
        DDX_Control(pDX, IDOK, m_ok);
    }
    
    BEGIN_MESSAGE_MAP(MyPropertySheet, CPropertySheet)
    END_MESSAGE_MAP()
    
    BOOL MyPropertysheet:: OnInitDialog()
    {
        BOOL bResult = CPropertySheet:: OnInitDialog();
    
        m_ok.SetFaceColor(RGB(255,102,0);
        SetDlgItemText(IDOK,("OKAY"));
    
        return bResult;
    }
    Code:
    //----------------------------------------------------------------//
    //Below is the code for Header file
    //----------------------------------------------------------------//
    //MyPropertySheet.h
    
    #include "MyPropertyPage.h"
    #include "afxbutton.h"
    
    class MyPropertySheet : public CPropertySheet 
    {
        DECLARE_DYNAMIC(MyPropertySheet)
    
        public:
        //Constructors
        MyPropertySheet(UINT nIdCaption,  CWnd* pParentWnd = NULL ,UINT iSelectPage = 0);
        MyPropertySheet(UINT pszCaption,  CWnd* pParentWnd = NULL ,UINT iSelectPage = 0);
    
        //Destructors
        virtual ~MyPropertySheet();
        virtual void DoDataExchange(CDataExchange* pDX);
    
        public:
        MyPropertyPage  mypage;
        CMFCBUTTON  m_ok;
    
        public:
        virtual BOOL OnInitDialog();
    
        protected:
        DECLARE_MESSAGE_MAP()
    };
    Last edited by 2kaud; October 7th, 2019 at 05:10 AM. Reason: Added code tags

Page 2 of 7 FirstFirst 12345 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)