LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SetStdioWindowVisibility - Not working well without printf or FmtOut

Hey all,

 

I am trying to accept some keys from the user and hence using the GetKey() command as follows:

 

char letter;

letter = GetKey (); 

SetStdioWindowVisibility(0); 

 

So I am trying to accept a key and then hide the I/O console. But SetStdioWindowVisibility(0) is not hiding it. It still stays there.

 

So I tried playing around and found that having a printf or FmtOut either before or after the GetKey() did the job. That is,

 

//printf or FmtOut before GetKey()

char letter;

printf ("\n"); 

letter = GetKey (); 

SetStdioWindowVisibility(0); 

 

or

 

//printf or FmtOut after GetKey()

char letter;

letter = GetKey (); 

SetStdioWindowVisibility(0); 

printf ("\n"); 

 

Another solution is to change the console to "CVI Studio Window" also does the job.

 

SetStdioPort (CVI_STDIO_WINDOW);

char letter;

letter = GetKey (); 

SetStdioWindowVisibility(0); 

 

I checked and saw that the default option, if we do not do SetStdioPort(), is "Host System's Stdio".

 

So can someone explain why SetStdioWindowVisibility(0) does not work without the printf or FmtOut()

 

Thanks in advance! 🙂

0 Kudos
Message 1 of 4
(3,056 Views)

Shailesh:

 

What version of CVI are you using?  I didn't have any problem using SetStdioWindowVisibility() to hide or display either stdio window in eother CVI 6.0 or 9.0.1.

 

Here's the simple code I tested.

 

#include <utility.h>
main()
{
char letter;

SetStdioPort (HOST_SYSTEM_STDIO);
letter = GetKey ();

SetStdioWindowVisibility(0);

Delay(1);

SetStdioWindowVisibility(1);

Delay(1);

SetStdioWindowVisibility(0);

Delay(1);

SetStdioPort (CVI_STDIO_WINDOW);

letter = GetKey ();

SetStdioWindowVisibility(0);

Delay(1);

SetStdioWindowVisibility(1);

Delay(1);

SetStdioWindowVisibility(0);

Delay(1);

}

 

 

If you search this forum for SetStdioWindowVisibility, you'll find that other people have had problem with SetStdioWindowVisibility.

Look at this post, where I suggested moving the window off screen.

http://forums.ni.com/t5/LabWindows-CVI/How-to-Close-Standard-IO-Window/m-p/978009

 

Why are you using the stdio window to get user input?  Why not have a user interface created with the UI editor and have a text box or string control for user entry?  Or use a PromptPopup, if you don't want to use a UIR?

 

0 Kudos
Message 2 of 4
(3,029 Views)
Hey thanks for the reply. I am using LabWindows 7.1. Yeah I too never use the stdio console and prefer pop-ups generally. But in this case it is more for an educational purpose (as I am teaching some others). The batch faced this problem and I could suggest this workaround by using printf amd FmtOut but couldn't reason out what was causing it to behave so. Your example was working fine. But I have attached a sample project showing my problem. Quick glance at the code: int CVICALLBACK CMD_Key_Code (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char k; switch (event) { case EVENT_COMMIT: //It works fine with this printf here, but if it is commented then the screen does not hide //printf("\n"); k = GetKey (); if ((k == 0x0051) || (k == 0x0071)) /* q or Q */ { exit (0); } else { SetStdioWindowVisibility(0); } break; } return 0; }
0 Kudos
Message 3 of 4
(3,022 Views)
Quick glance at the code: int CVICALLBACK CMD_Key_Code (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char k; switch (event) { case EVENT_COMMIT: //It works fine with this printf here, but if it is commented then the screen does not hide //printf("\n"); k = GetKey (); if ((k == 0x0051) || (k == 0x0071)) /* q or Q */ { exit (0); } else { SetStdioWindowVisibility(0); } break; } return 0; }
0 Kudos
Message 4 of 4
(3,011 Views)