02-25-2015 01:05 PM
i want to write a code which consists of many text messages and two command buttons named "Next Instruction" and "Previous Instruction". Text messages are already written and will hide when program will start. when i press next instruction button the second instruction will appear and first one will hide, when i press the button second time third instruction will come and second will hide. when i press previous instruction button it will go backwards. Kindly help me in writing this code. I am stuck here.
Solved! Go to Solution.
02-26-2015 12:44 AM
Hi,
why not start
For some more specific questions / problems people here on the forum will help you further
02-26-2015 02:18 AM
#include <cvirte.h>
#include <userint.h>
#include "instructions.h"
static int panelHandle;
/************************************************************************/
// Panel Initialization//////////////////////////////////////////////////
//***********************************************************************/
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "instructions.uir", PANEL)) < 0)
return -1;
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_2, ATTR_VISIBLE, 0);//Instruction 2 not visible
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_3, ATTR_VISIBLE, 0);//Instruction 3 not visible
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_4, ATTR_VISIBLE, 0);//Instruction 4 not visible
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
/************************************************************************/
// Next_Instruction Callback Function/////////////////////////////////////
//***********************************************************************/
int CVICALLBACK Next_Instruction (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_2, ATTR_VISIBLE, 1);//Instruction 2 visible
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_1, ATTR_VISIBLE, 0);//Instruction 1 not visible
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
/************************************************************************/
// Previous_Instruction Callback Function/////////////////////////////////
//***********************************************************************/
int CVICALLBACK Previous_Instruction (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_1, ATTR_VISIBLE, 1);//Instruction 1 visible
SetCtrlAttribute (panelHandle, PANEL_INSTRUCTION_2, ATTR_VISIBLE, 0);//Instruction 2 not visible
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
/************************************************************************/
// Quit Callback Function////////////////////////////////////////////////
//***********************************************************************/
int CVICALLBACK QuitCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
I wrote the code but i dont know how to execute third instruction when user click the next instruction button second time. Plz help me out
02-26-2015 02:28 AM
So it looks like you have to handle 3 situations and display message 1-2-3 depending on the case you are.
You could put a hidden numeric on the panel and in button callbacks read the numeric, increment/decrement as required and then display the appropriate message depending on counter value, hiding the others.
02-26-2015 04:02 AM
Thanks a lot Roberto. Your suggestion will be more helpful for me.