LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

repaint errors when returning from thread in lab windows

I am running LabWindow 6.0 and have a main panel that Launchs and executable (using CreateProcess and WaitForSingleObject from the SDK). The data is then loaded. The data is being loaded correctly however the main panel does not repaint to reflect the change.

Further the problem occurs on WinXP and it works fine on Win2k. Is this a problem with LabWindows or am I missing something?

In either case is there anyway I can force a repaint? I have tried using sending a WM_PAINT and WM_PRINTCLIENT message (using both GetCviWindowHandle() and GetFocus() to get the windows handle) and it still does not respond.
0 Kudos
Message 1 of 6
(2,824 Views)
Have you tried ProcessDrawEvents()? While your program is in a callback, draw events are not processed unless you call RunUserInterface(), GetUserEvent(), or ProcessDrawEvents().
Here's some other info from the function help for ProcessDrawEvents(): "If you call this function in a multithreaded program, only the panels created in the current thread are guaranteed to be updated fully."
0 Kudos
Message 2 of 6
(2,824 Views)
I am calling ProcessSystemEvents, ProcessDrawEvents and the speal of them, from the correct thread. Here is a example of what my code looks like:

//Convert Data before loading
if (!CreateProcess(NULL,path,NULL,NULL,FALSE,0,0,NULL, &si,π))
....
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
ProcessDrawEvents();
ProcessSystemEvents();
//Load the converted Data
...
ProcessDrawEvents();
ProcessSystemEvents();

It seems clear to me that the panel is not recieving a repaint message when it should be. What I really need to know is how to send I can force a reapaint none of the follwing work (as the next line of code in the example)

DisplayPanel(..);
SendMessage(GetCviWindow(), WM_PAINT
, 0, 0);
SendMessage(GetFocus(), WM_PAINT, 0, 0);
SendMessage(GetCviWindow(), WM_PRINTCLIENT, 0, 0);
SendMessage(GetFocus(), WM_PRINTCLIENT, 0, 0);
0 Kudos
Message 3 of 6
(2,824 Views)
WaitForSingleObject is a blocking function. You will not process any events while that wait is running. You should have this code in a separate thread in your application so that thread can wait while your main thread process events and updates the windows.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 6
(2,824 Views)
I know that, I want the program to block until the data has been properly converted. After it has been converted I then load the data this is where the repaint error occurs, after the block. I am sure that the reapint error is linked to the blocking but that does not change the need to block there.

Really I am not as interested in the thread management part as I am how to programatically force the panel to repaint. Is there not a message I can send (that will force a repaint of the panel or some function or something I can do to force a paint????
0 Kudos
Message 5 of 6
(2,824 Views)
Sorry, I thought you were wanting to redraw while the EXE was running. We don't expose a way to re-paint the client area of CVI panels manually with a function. One thing you could do is use SetPanelAttribute and set the color of the panel to something and then back to the original color. That will repaint the panel. SetPanelAttribute does not redraw on the function call, it just posts an event, so you would never see the interim color and would just re-paint once.

Chris
0 Kudos
Message 6 of 6
(2,824 Views)