In noticed one of the error codes for this function is:
| -1 | == You are running on a platform other than Windows 2000/NT/9x. |
This may be a problem in your case.
Try checking duplicateInstance as shown in the following code and see if that works.
if (CheckForDuplicateAppInstance (ACTIVATE_OTHER_INSTANCE, &duplicateInstance ) < 0)
{
return -1;
}
if (duplicateInstance )
{
return 0;
}
robskii
Thanks for the suggestion. I tried it, but it did not make any difference. It is better coding practice, so I left your suggesting in. The CheckForDuplicateAppInstance function is returning 0 (success) with the duplicate instance variable is set to 1 (TRUE) as expected. The function appears to be activating an additional panel when processing the ACTIVATE_OTHER_INSTANCE parameter. The correct (main) panel of the original instance is activated as expected, but a child panel (that has been loaded, but never displayed in the original instance) also appears. It would be very confusing to the user because the panel that appears is used to input data under only very specific circumstances.
By the way, I first noticed this problem in another executable and thought that the last panel loaded was being displayed, but that does not appear to be the case. The exteraneous panel in both cases is one of several child panels of the main panel that is correctly activated by the function. Orignal instance had been active, without any child panels displayed when the 2nd instance was exectuted, so I would expect that to be the case when it is reactivated.
Any more ideas???
Hello kfourroux,
To test this behavior, I created a main panel and child panel and created the following source code:
int main(void)
{
panel1 = LoadPanel (0, "test.uir", PANEL);
panel2 = LoadPanel (panel1, "test.uir", PANEL_2);
DisplayPanel (panel1);
if (CheckForDuplicateAppInstance (ACTIVATE_OTHER_INSTANCE, &duplicateInstance ) < 0)
{
DiscardPanel (panel1);
return -1;
}
if (duplicateInstance )
{
DiscardPanel (panel1);
return 0;
}
RunUserInterface();
DiscardPanel (panel1);
}