Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. PropertySheet - possible to change style OK btn?

PropertySheet - possible to change style OK btn?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestionlearning
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michael thomas
    wrote on last edited by
    #1

    Hi, Thank you for checking out my post. I am writing a simple CPropertySheet (with property pages of course) VC++ 6 Doc/View application, and I want to change the look of the OK or CANCEL buttons. Trouble is that I don't seem to be able to create a control variable of either buttons. The buttons are provided by the framework I am thinking, but does anyone know how to access them? The only interaction I have with the Cancel or OK buttons is to check the return value when dlg.DoModal() returns and that is it. Thanks for any suggestions. Michael

    M 1 Reply Last reply
    0
    • M michael thomas

      Hi, Thank you for checking out my post. I am writing a simple CPropertySheet (with property pages of course) VC++ 6 Doc/View application, and I want to change the look of the OK or CANCEL buttons. Trouble is that I don't seem to be able to create a control variable of either buttons. The buttons are provided by the framework I am thinking, but does anyone know how to access them? The only interaction I have with the Cancel or OK buttons is to check the return value when dlg.DoModal() returns and that is it. Thanks for any suggestions. Michael

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      In the property sheet class, you can call GetDlgItem(IDOK) to get a CWnd* on the OK button. Change IDOK to IDCANCEL for the Cancel button. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

      M 1 Reply Last reply
      0
      • M Michael Dunn

        In the property sheet class, you can call GetDlgItem(IDOK) to get a CWnd* on the OK button. Change IDOK to IDCANCEL for the Cancel button. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

        M Offline
        M Offline
        michael thomas
        wrote on last edited by
        #3

        Hi Mike, Thank you so much for replying. I seem to recognize your name...I think you have kindly helped me in the past. Anyway, I did try GetDlgItem(ID_OK) before I posted my question and I couldn't get it to work. It must be the way I did it. It would compile ok but crash on running when doing the check "ASSERT(::IsWindow(m_hWnd));". Here's the code I used within my CPropertySheet class's constructor :- CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage) { //add each page to the propert sheet this->AddPage(&this->m_prop_page1); //get pointer to OK button so I can alter it CButton * pbutton = (CButton *)this->GetDlgItem(IDOK); } Actually, as I write this I realize that maybe the propertySheet is not a window (and that includes the OK button) until I run "property_sheet_obj.DoModal()", so that might be the problem right there. Do I have to alter the OK button after the DoModal().....I will try that. Thanks Mike and thank you all for any suggestions or confirmation. Michael

        M 1 Reply Last reply
        0
        • M michael thomas

          Hi Mike, Thank you so much for replying. I seem to recognize your name...I think you have kindly helped me in the past. Anyway, I did try GetDlgItem(ID_OK) before I posted my question and I couldn't get it to work. It must be the way I did it. It would compile ok but crash on running when doing the check "ASSERT(::IsWindow(m_hWnd));". Here's the code I used within my CPropertySheet class's constructor :- CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage) { //add each page to the propert sheet this->AddPage(&this->m_prop_page1); //get pointer to OK button so I can alter it CButton * pbutton = (CButton *)this->GetDlgItem(IDOK); } Actually, as I write this I realize that maybe the propertySheet is not a window (and that includes the OK button) until I run "property_sheet_obj.DoModal()", so that might be the problem right there. Do I have to alter the OK button after the DoModal().....I will try that. Thanks Mike and thank you all for any suggestions or confirmation. Michael

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          No windows are created until after DoModal(), so it might be easiest to do the change in the first page that gets shown:

          CPropertySheet* pSheet = (CPropertySheet*) GetParent(); // NOTE: temp CWnd ptr
          CWnd* pOKBtn = pSheet->GetDlgItem(IDOK);

          pOKBtn->SetWindowText ( _T("'Aight") );

          --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

          M 1 Reply Last reply
          0
          • M Michael Dunn

            No windows are created until after DoModal(), so it might be easiest to do the change in the first page that gets shown:

            CPropertySheet* pSheet = (CPropertySheet*) GetParent(); // NOTE: temp CWnd ptr
            CWnd* pOKBtn = pSheet->GetDlgItem(IDOK);

            pOKBtn->SetWindowText ( _T("'Aight") );

            --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER

            M Offline
            M Offline
            michael thomas
            wrote on last edited by
            #5

            Thanks Mike

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups