dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 7 FirstFirst 123456 ... LastLast
Results 31 to 45 of 92

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

  1. #31
    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
    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()
    };
    Your code does NOT compile. There is o lot of errors.
    Please, fix the errors an post the compilable code!
    Victor Nijegorodov

  2. #32
    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

    Does SetDlgItemText set the button text to "OKAY" for button with the id if IDOK?

  3. #33
    Join Date
    Sep 2019
    Posts
    24

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

    Yes Arjay it sets the button text to OKAY,even button font is also getting bold if i use CFont concept,even position of button is also changing if i use Movewindow..Only thing and most painful for me button Color which is not changing.

  4. #34
    Join Date
    Sep 2019
    Posts
    24

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

    Victor ,you may see compilation errors coz i am writing manually ,i cant copy paste as it is due to some norms..But code is 100% compilable and i have shared both cpp and header files above with you.so please ignore spelling mistakes ...just tell where color change logic is getting failed

  5. #35
    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
    Victor ,you may see compilation errors coz i am writing manually ,i cant copy paste as it is due to some norms..But code is 100% compilable and i have shared both cpp and header files above with you.so please ignore spelling mistakes ...just tell where color change logic is getting failed
    1. Yes, you have to copy/paste your code, not just "rewrite" it from scratch!
    2. Since you did not provide the correct code I could not test it. Instead I had to create a test App, add a button (CMFCButton testButton) and use your code
    Code:
    	testButton.SetFaceColor(RGB(255, 102, 0));
    Attached Images Attached Images  
    Last edited by VictorN; October 8th, 2019 at 05:32 AM. Reason: the "corrupted" attachment was removed
    Victor Nijegorodov

  6. #36
    Join Date
    Sep 2019
    Posts
    24

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

    So were you able to see the color change of button? Image attached is not getting opened

  7. #37
    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
    So were you able to see the color change of button?
    Yes.

    Quote Originally Posted by Sparsh_21j View Post
    ... Image attached is not getting opened
    I have no idea why... I do see it within my post in this thread.

    If you posted your (test) project I could see what and why does not work in it.
    Victor Nijegorodov

  8. #38
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,900

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

    I have no idea why... I do see it within my post in this thread.
    When trying to open, get the message 'Invalid Attachment specified. If you followed a valid link, please notify the administrator'
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.3.9)

  9. #39
    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

    Name:  CMFCButton.jpg
Views: 17
Size:  25.5 KBHow about this one?
    Victor Nijegorodov

  10. #40
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,900

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

    How about this one?
    There doesn't appear to be an attachment with that post?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.3.9)

  11. #41
    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

    I can see the attachment, but that's not exactly what the OP is trying to do. He has a CPropertySheet which has the OK button on it and he's trying to change its face color. I've duplicated what I think his code is supposed to be and it doesn't work for me other.

    Ok, I figured it out. The problem is CPropertySheet::OnInitDialog doesn't call UpdateData, so his control variable isn't mapped to the OK button. If you call UpdateData(FALSE) before SetFaceColor, the call works.
    Last edited by GCDEF; October 8th, 2019 at 10:01 AM.

  12. #42
    Join Date
    Sep 2019
    Posts
    24

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

    GCDEF I tried what you said but unfortunately it didn't changed the color,instead after that my button became invisible but clickable

  13. #43
    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
    GCDEF I tried what you said but unfortunately it didn't changed the color,instead after that my button became invisible but clickable
    Again: post the test-project with such a behavior, so we'll be able to investigate/solve the problem
    Victor Nijegorodov

  14. #44
    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
    GCDEF I tried what you said but unfortunately it didn't changed the color,instead after that my button became invisible but clickable
    Worked for me. This is the code in my CPropertySheet derived class.
    Code:
    	BOOL bResult = CPropertySheet::OnInitDialog();
    	UpdateData(FALSE);
    	m_OK.SetFaceColor(RGB(255, 0, 0));
    and
    Code:
    	CPropertySheet::DoDataExchange(pDX);
    	DDX_Control(pDX, IDOK, m_OK);
    int the DoDataExchange function

  15. #45
    Join Date
    Sep 2019
    Posts
    24

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

    I did exactly the same..

Page 3 of 7 FirstFirst 123456 ... 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)