dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 5 1234 ... LastLast
Results 1 to 15 of 73

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

  1. #1
    Join Date
    Sep 2019
    Posts
    24

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

    I have one Cpropertysheet which contains two Cproperty page.I am able to change the background color of page and sheet as well using onctlcolor() but i am not able to change background color of standard buttons (ok,cancel,help), i tried setfacecolor, dc.setbkcolor ,code is compiling successfully but nothing is reflecting the result.Please please provide the solution with a code snippet

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

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

    Victor Nijegorodov

  3. #3
    Join Date
    Sep 2019
    Posts
    24

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

    Yes victor i tried setfacecolor ,code is compiling but result is not reflected..please help me out

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

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

    Please post the code you have to change the button color.

  5. #5
    Join Date
    Sep 2019
    Posts
    24

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

    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
    Last edited by 2kaud; September 29th, 2019 at 10:42 AM. Reason: Added code tags

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

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

    What is CMFCBUTTON ?
    Victor Nijegorodov

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,100

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

    What is m_ok? Where is it set?

  8. #8
    Join Date
    Sep 2019
    Posts
    24

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

    m_ok has been there in DDX_Exchange() see..second last line of code.and m_ok has been declared in header file

  9. #9
    Join Date
    Sep 2019
    Posts
    24

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

    CMFCBUTTON is derived from CButton and provide setfacecolor() function to color background of button

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

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

    Quote Originally Posted by Sparsh_21j View Post
    CMFCBUTTON is derived from CButton and provide setfacecolor() function to color background of button
    Who created this CMFCBUTTON class?
    How is this setfacecolor() function implemented?
    Victor Nijegorodov

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,100

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

    Back up a step and add your own button to a single page (i.e. a button that is not one of the CPropertySheet buttons).

    Then use one if your methods to change the color of the button. Once you get that working, use the same approach for one of the property sheet buttons. Btw, m_ok may not be working for you - instead, from the page, you may have to use <pointer to the property sheet>::GetDlgItem().

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

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

    Quote Originally Posted by Sparsh_21j View Post
    CMFCBUTTON is derived from CButton and provide setfacecolor() function to color background of button
    There's an MFC class CMFCButton. Is that what you're using or did you create your own CMFCBUTTON class?

  13. #13
    Join Date
    Sep 2019
    Posts
    24

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

    Yes you are right i am using MFC class provided by Microsoft

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

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

    Quote Originally Posted by Sparsh_21j View Post
    Yes you are right i am using MFC class provided by Microsoft
    Then it must be either CMFCButton or some class derived from CMFCButton. Is your class CMFCBUTTON derived from CMFCButton class?
    Victor Nijegorodov

  15. #15
    Join Date
    Sep 2019
    Posts
    24

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

    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()."

Page 1 of 5 1234 ... 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)