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. HHeelp

HHeelp

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 Posts 3 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.
  • U Offline
    U Offline
    User 423850
    wrote on last edited by
    #1

    hello friends.. I am writing a Wizard application. now i want to change the default focus i.e if i press enter then the wizard automatically set the Next as default button and as this button gets press the app moves to the next Wizard page. But in between this i want to change the Default button to Cancel. that means when the user clicks the enter key then instead of the Next the Cancel key should be pressed. In short i want to change the Default button to Cancel instead of next.. Help Thanx TAKE CARE

    V P 2 Replies Last reply
    0
    • U User 423850

      hello friends.. I am writing a Wizard application. now i want to change the default focus i.e if i press enter then the wizard automatically set the Next as default button and as this button gets press the app moves to the next Wizard page. But in between this i want to change the Default button to Cancel. that means when the user clicks the enter key then instead of the Next the Cancel key should be pressed. In short i want to change the Default button to Cancel instead of next.. Help Thanx TAKE CARE

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      One solution is SendMessage(). if (pFromButtom->GetSafeHwnd() && pToButton->GetSafeHwnd()) { DWORD style = pToButton->GetStyle(); if ((style & BS_DEFPUSHBUTTON) != 1) { style = pFromButtom->GetStyle(); // Remove default push button style. style &= ~BS_DEFPUSHBUTTON; // Set the new style. ::SendMessage(pFromButtom->GetSafeHwnd(), BM_SETSTYLE, static_cast(style), static_cast(TRUE)); // Inform the dialog about the new default control ID. ::SendMessage(hWnd, DM_SETDEFID, pToButton->GetDlgCtrlID(), 0); // Get the style. style = pToButton->GetStyle(); // Add the default push button style. style |= BS_DEFPUSHBUTTON; // Set the new style. ::SendMessage(pToButton->GetSafeHwnd(), BM_SETSTYLE, static_cast(style), static_cast(TRUE)); } } Kuphryn

      U 1 Reply Last reply
      0
      • U User 423850

        hello friends.. I am writing a Wizard application. now i want to change the default focus i.e if i press enter then the wizard automatically set the Next as default button and as this button gets press the app moves to the next Wizard page. But in between this i want to change the Default button to Cancel. that means when the user clicks the enter key then instead of the Next the Cancel key should be pressed. In short i want to change the Default button to Cancel instead of next.. Help Thanx TAKE CARE

        P Offline
        P Offline
        Phil Hamer
        wrote on last edited by
        #3

        I'm not sure, but I think SetDefID(IDCANCEL) would work.

        U 1 Reply Last reply
        0
        • P Phil Hamer

          I'm not sure, but I think SetDefID(IDCANCEL) would work.

          U Offline
          U Offline
          User 423850
          wrote on last edited by
          #4

          sorry friend Philnessosity this doesnt Work !!!! Thanx TAKE CARE

          1 Reply Last reply
          0
          • V valikac

            One solution is SendMessage(). if (pFromButtom->GetSafeHwnd() && pToButton->GetSafeHwnd()) { DWORD style = pToButton->GetStyle(); if ((style & BS_DEFPUSHBUTTON) != 1) { style = pFromButtom->GetStyle(); // Remove default push button style. style &= ~BS_DEFPUSHBUTTON; // Set the new style. ::SendMessage(pFromButtom->GetSafeHwnd(), BM_SETSTYLE, static_cast(style), static_cast(TRUE)); // Inform the dialog about the new default control ID. ::SendMessage(hWnd, DM_SETDEFID, pToButton->GetDlgCtrlID(), 0); // Get the style. style = pToButton->GetStyle(); // Add the default push button style. style |= BS_DEFPUSHBUTTON; // Set the new style. ::SendMessage(pToButton->GetSafeHwnd(), BM_SETSTYLE, static_cast(style), static_cast(TRUE)); } } Kuphryn

            U Offline
            U Offline
            User 423850
            wrote on last edited by
            #5

            Hi kuphryn Where this code should be written i mean in Initdialog or in PreCreate window ?? Thanx TAKE CARE

            V 1 Reply Last reply
            0
            • U User 423850

              Hi kuphryn Where this code should be written i mean in Initdialog or in PreCreate window ?? Thanx TAKE CARE

              V Offline
              V Offline
              valikac
              wrote on last edited by
              #6

              Put in it stdafx.h. Call it whenever you want to change the default button. Kuphryn

              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