LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

square command button

Solved!
Go to solution

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. 

0 Kudos
Message 1 of 5
(4,588 Views)

Hi,

 

why not start 

  • working through the Getting Started Manual
  • and then exploring some of the examples provided with CVI? You can use the example finder (Help / Find examples) and search for 'Building User Interfaces'

For some more specific questions / problems people here on the forum will help you further

0 Kudos
Message 2 of 5
(4,571 Views)

#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

0 Kudos
Message 3 of 5
(4,568 Views)
Solution
Accepted by Kazuya_Mishima

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 5
(4,566 Views)

Thanks a lot Roberto. Your suggestion will be more helpful for me.

0 Kudos
Message 5 of 5
(4,555 Views)