LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Main-Panel cannot be maximized, when minimized while a popup was open

hi,

 

i've a problem with Messagepopups. If i call a Messagepopup with "MessagePopup" or "GenericMessagePopup" from a separate Thread, and then minimize my main User Interface, i can't maximize my window!

 

I hope the following code-snippet figures my problem out:

 

status = 0;
CreateThread(0,0,(void*)(funktion1),0,0,0);
 while(!status) {
//Here i'm minimizing my application, before i confirm the popup
Sleep(10);
ProcessSystemEvents();
}

 

void funktion1(void)
{
 status = GenericMessagePopup("Titel","Nachricht","but1","but2",0,0,0, 0,VAL_GENERIC_POPUP_BTN1,VAL_GENERIC_POPUP_BTN1,VAL_GENERIC_POPUP_NO_CTRL);
 return;  
}

 

Does somebody have a Solution for this Problem?

 

P.S. I use Win 7 and CVI2012

 

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

Hello Rapha123,

 

to make sure that we are on the same page, I attached a file containing the code with the issue you described.

Please try it out and let me know whether this is what you meant so that we can think about how to further proceed.

 

Thank you

 

Eleni 

Applications Engineer

National Instruments

 

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

Hello Eleni,

 

thank you for your Reply. I tried your example, and yes, the problem is there as well. Is there a problem with forwarding my Button-Events or something like that, or is it something else? Do you also have this behavior with your Testcode? 

 

I've figured out that it works, when i use the MessageBox from WinUser.h (including in windows.h) (see attachment)

0 Kudos
Message 3 of 5
(4,602 Views)

Hello Rapha, 

 

yes I observed the same behavior with my testcode. I am not sure yet, whether it is a bug or something is wrong with the programming, but I am on it.

Meanwhile I found this example: Multithreading with a Modal Dialog Pop-up in LabWindows/CVI http://www.ni.com/example/29721/en/.

Does this help?

 

Eleni

Applications Engineer

National Instruments

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

Hello Rapha123,

 

after talking to a colleague I have some new information that might be helpful:

 

As a workaround, maybe try to use schedule thread pool functions instead of the "CreateThread" function: http://www.howtocvi.net/2011/05/multithreading-with-cvi-part-1.html

If this does not work, try to use a second panel with two buttons rather than using the MessagePopup

 

Regarding the testfile I sent:

 

The taskbar has a single button, which is for the running application. So, the button you see in the taskbar is for all of test.exe when it’s running.

 This does not differentiate between different panels—all of the panels in your program are contained in that single taskbar button.

When you hover your mouse over the taskbar button, the preview you see is whichever panel has “focus,” which is the active panel in the application.

 

As such, when you minimize a panel after launching the popup, the taskbar still associates that button with the application, which has a visible/active pop up message. There really is no way to restore the minimized window. (You could do it programmatically, but that would not solve the problem.) This is just kind of an unfortunate side effect of the way that panels work in the application, but it is not unexpected behavior.

 

The solution to this is the panel property “Has Taskbar button.” You can set it through the Edit Panel dialog if you click on Other Attributes. If you enable that option, you will always have a separate task bar button for the panel when you minimize it.

 

This does something kind of weird, though. You end up with two task bar buttons—one for the whole application and one for that panel. The one for the application corresponds to whatever the active window is. The “preview” you see when you hover the mouse over it in the taskbar will show whatever the active panel or window is. The other item in the taskbar always just goes with the panel that you enabled the “Has taskbar button” attribute for.

 

What I would recommend is selectively enabling that attribute when you minimize the window. I have attached a new test programm with following modifications:

  1. Double-click on the panel to open its properties, the “Edit Panel” dialog box
  2. Add a callback name in the Callback function field.
  3. Click OK to close the panel properties
  4. Generate the panel callback from Code>>Generate>>Panel callback
  5. In EVENT_PANEL_MINIMIZE, I set ATTR_HAS_TASKBAR_BUTTON to True
  6. In EVENT_PANEL_MAXIMIZE and EVENT_PANEL_RESTORE, the same attribute is set back to false.

It’s not perfect. If you minimize the main panel before opening the popup, you get the weird behavior with two taskbar buttons for the same panel (one called test.exe, one called Untitled Panel). But, it works much better than before. 

 

I hope this helps. 

 

Regards

 

Eleni 

Applications Engineer

National Instruments

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