After reading the answer that Annette originally posted to your question, I will try to clarify what she meant a little.
Annette was not trying to say that you should double-click the .exe file for the program 8 times in order to configure 8 different com ports, she said specifically that you would have one application that called the LaunchExecutable function to launch the same application 8 times. The only real drawback to this is that you won't have much control over the 8 instances of the app from the launching application, except that you can call TerminateExecutable to close them. This is probably the easiest way to obtain what you want.
If you truly do want to have one application that shows multiple identical windows and has a bit more control over each of them, then you will have to make a multithreaded application that spawns a new thread each time the user wants to open a new com port from a new configuration window. Each thread would then have its own event queue for the window instance that it loaded, therfore making each window's interaction independent of the other. If you would like more information on this, I highly suggest reading the MultithreadingOverview.pdf found in your cvi\bin directory.
**Note CVI 5.5 and up come with a multithreading library and support multithreaded debugging, earlier versions than 5.5 do not. You can use Windows SDK functions to perform multithreading in CVI 5.0.1 and earlier, but National Instruments will not provide technical support for this.
Here is a small code snippet that shows how to load and display the same panel from different threads (note: the threads will share the same callback functions, so be wary of using global or static local variables in the callback definitions):
#include
#include
#include
#include "multithreadsinglepanel.h"
int CVICALLBACK ThreadFunction (void *functionData);
static int panelHandle;
static int panelHandle2;
static int threadID;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE,
ThreadFunction, NULL, &threadID);
if ((panelHandle = LoadPanel (0, "multithreadsinglepanel.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE,
threadID,
OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event) {
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
int CVICALLBACK ThreadFunction (void *functionData)
{
if ((panelHandle2 = LoadPanel (0, "multithreadsinglepanel.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle2);
RunUserInterface ();
DiscardPanel (panelHandle2);
return 0;
}
Jason F.
Applications Engineer
National Instruments
www.ni.com/ask