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. add two functions for a button

add two functions for a button

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 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
    meiyueh
    wrote on last edited by
    #1

    i'm using dialog based application as my own gui. i'm facing problem in button. i want a button with two function. that means the button can resemble start recording and stop recording. what are the source code for that? thx a lot for your help.

    D L T 3 Replies Last reply
    0
    • M meiyueh

      i'm using dialog based application as my own gui. i'm facing problem in button. i want a button with two function. that means the button can resemble start recording and stop recording. what are the source code for that? thx a lot for your help.

      D Offline
      D Offline
      Dreamz
      wrote on last edited by
      #2

      You can implement both the logic in the same function. Eg: Create a state member varible, which will identify it is recording or not. Initialize the state to STOP CYourClass::OnButton() { if(STATE_STOP == m_enState) { //Start the Recording //Set the state m_enState = STATE_REC; //Change the button image/text } else if(STATE_REC == m_enState) { //Stop the recording //Set the state m_enState = STATE_STOP; //Change the button image/text } }

      M 1 Reply Last reply
      0
      • M meiyueh

        i'm using dialog based application as my own gui. i'm facing problem in button. i want a button with two function. that means the button can resemble start recording and stop recording. what are the source code for that? thx a lot for your help.

        L Offline
        L Offline
        logicaldna
        wrote on last edited by
        #3

        just declare a flag to check which function you want to call

        1 Reply Last reply
        0
        • D Dreamz

          You can implement both the logic in the same function. Eg: Create a state member varible, which will identify it is recording or not. Initialize the state to STOP CYourClass::OnButton() { if(STATE_STOP == m_enState) { //Start the Recording //Set the state m_enState = STATE_REC; //Change the button image/text } else if(STATE_REC == m_enState) { //Stop the recording //Set the state m_enState = STATE_STOP; //Change the button image/text } }

          M Offline
          M Offline
          meiyueh
          wrote on last edited by
          #4

          is it i jst copy this code into the programming and no need right click the button and set its properties anymore? i'm newbie, hope you can help. thx.

          D 1 Reply Last reply
          0
          • M meiyueh

            is it i jst copy this code into the programming and no need right click the button and set its properties anymore? i'm newbie, hope you can help. thx.

            D Offline
            D Offline
            Dreamz
            wrote on last edited by
            #5

            You have to add the message handler for the buton first. Double click on the button, a message handler for "BN_CLICKED" will be created. Inside the function you can use the logic that i have specified. For that you have to create a State member varible. Go to the header file and declare int m_State; Declare the states also.... #define STATE_REC 1 #define STATE_STOP 0 then proceed with your coding.....

            1 Reply Last reply
            0
            • M meiyueh

              i'm using dialog based application as my own gui. i'm facing problem in button. i want a button with two function. that means the button can resemble start recording and stop recording. what are the source code for that? thx a lot for your help.

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              just create two buttons perfectly overlapping, but being hidden once at a time. this way, you have once handler per button, and just have to ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW) the buttons


              TOXCCT >>> GEII power
              [toxcct][VisualCalc]

              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