LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LoadPanel in a thread the application cannot be maximized from taskbar

Solved!
Go to solution

Hello,

I've got the following problem, and I can't see an answer in the previous threads:

When an application loads a panel from a thread, it works but if it is minimized, it cannot be maximized from the taskbar.

Any idea?

I join a sample application that focus on the problem.

Best regards,

Serge

0 Kudos
Message 1 of 8
(256 Views)

Checking the Has taskbar button option in panel settings will permit you to click on the taskbar icon and restore the panel.

But calling HidePanel will leave you with no panel on screen after the second panel has been closed: you can leave the panel on screen, minimize it or display it again when the second thread terminates.

I am adding a revised version of your example.



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?
0 Kudos
Message 2 of 8
(245 Views)

Thank you for your quick reply, In fact this is not the behaviour expected (for my end user) They want only one icon. And even if I modify the source code to discard the panel1 there are 2 icons in one : "user interface application" and "panel2"

int CVICALLBACK OnGoToPanel2 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)

{

    if (event == EVENT_COMMIT)

    {

        SetPanelAttribute(panelHandle1, ATTR_HAS_TASKBAR_BUTTON, 0); // Try to remove 1st panel icon

        DiscardPanel(panelHandle1);

        panelHandle1 = 0;

        StartMainThread(gMainPoolHandle, &IdThreadMain);

     }

     return 0;

}

0 Kudos
Message 3 of 8
(233 Views)

It is not clear to me why you want to spawn a second thread and handle the entire UI in that thread instead of the main thread (at least this is what I have understood from your posts).



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?
0 Kudos
Message 4 of 8
(209 Views)

In fact, I wanted to move a long treatment (loop on a finite state machine) started by a button.

the fact is that if I let it in the callback (which is not suitable for long treatment) it works correctly, and if I move the loop in a thread it doesn't, for unknown reason.

0 Kudos
Message 5 of 8
(169 Views)

This is normally achieved by separating the operative code from the user interface: the panel and the start button remain in the main thread and the operative task passes data to it to let the user know what's happening.

Passing data can be obtained via thread safe queues or by issuing a PostDeferredCall (which is executed in the main thread) or by other means leaving the running thread unaffected.

This framework permits also to handle a stop button in case the operator wants to abort the process



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?
0 Kudos
Message 6 of 8
(165 Views)
Solution
Accepted by topic author Zergios26

There are a number of examples installed in CVI folder that may help you in designing your application, you can search into shipping examples by means of the Example Finder (Help >> Find examples... menu function): search for "thread" in the search tab and you will seen a bunch of projects listed.

MultiPanel.cws shows how to handle a panel in a separate thread

BuffNoDataLoss.cws shows how to pass data using thread safe queues

Other examples can offer you useful hints on the subject.



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 7 of 8
(161 Views)

Thank You very much Roberto

0 Kudos
Message 8 of 8
(149 Views)