add two functions for a button
-
-
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.
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 } }
-
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.
just declare a flag to check which function you want to call
-
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 } }
-
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.
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.....
-
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.