Click to See Complete Forum and Search --> : Accessing VB Form from C++


prmsaic
September 29th, 2004, 01:04 PM
I'm trying to fix a refresh problem in an application that creates a VB form with a large circle with a sweep hand (cursor looks and moves like a clock hand. It's trying to simulate the look of a radar sweep). The VB app then spawns a C++ app which grabs the form handle, calculates and then draws airplane info to the same form. When the sweep arm is moved, the rectangle defining it wipes out a large area drawn by C++, and the refresh is very slow. Is there any way to fix the contention between C++ and VB writing to the same form to get rid of the refresh problem?

It is problematic at this point to put the sweep hand in the C++ app, so hopefully there is another way. Can I create a separate frameless window in C++ and overlay it on top of the VB form? How would I do something like that?

The C++ code is using GDI. Would GDI+ buy me anything with window shape, refresh and/or transparency? I think DirectX would be huge overkill, but maybe there is some advantage in this area?

prmsaic
September 29th, 2004, 05:59 PM
I have been screwing around with this a little bit, and have some more info.

I tried writing directly to the screen (with a call to GetDC(NULL) ), and I get the exact same behavior. The C++ code is in a loop that refreshes at a certain interval, which is too slow, but is correct for the data it handles. There is no additional refresh going on (no call to OnPaint, or anything like that), so the behavior may be correct.

If I stick any random control on the VB form, it is rock solid with the sweep moving behind it. The graphics look like they are on two planes. The sweep never comes on top of the other control. That is how I want this to act. How can I keep the sweep hand from carving a huge rectangle out of the window with my data?

TheCPUWizard
September 30th, 2004, 09:06 AM
Have C++ code paint ot a virtual DC, plit this onto the VB shape and bingo!

prmsaic
September 30th, 2004, 12:08 PM
Thanks, you are exactly right.

I started to figure that out last night after extensive reading through this forum. I am a definite newbie trying to figure this out quickly to save this app, and I really appreciate the expertise shared on this forum.