From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CVI DLLs in VB

I am trying to us a CVI DLL through a Visual Basic program. It loads a couple of panels, and they work fine while I am inside the DLL code, but, unfortunately for me, when I am outside of the DLL, I can't seem to access the panels.

The basic functionality is that I load 2 panels one is a graph display using easytabs and the other is a settings panel. the settings panel works well when it is open (I never leave the DLL in this case), and the graphpanel too for that matter, but when I close the settings panel, I can no longer access the graphs panel easytabs or the one control button I have on it.

I started two threads to rectify the problem. One thread handles the settings panel, the other the graphs panel. This gets me access to the graphs pan
el, but only with the keyboard. The mouse doesn't work. At this point, I am at a loss at what possible problems may cause this.

I'm not very familiar with Visual Basic code calling the function, but I know that the graph panel is supposed to be a child parent of a VB panel (or at the very least they are to be used at the same time). Could the VB program be swallowing up all of the mouse events?

Thanks,

-matt
0 Kudos
Message 1 of 4
(2,880 Views)
Hi,
I am not clear on the problem, and I'd appreaciate it if you could give me more explanation. Are you exporting a panel handle or a function that accesses the panel handle in the dll, and trying to use that in your VB program? Are you saying that you cannot access the exported handle inside your VB program?

Mika Fukuchi
Application Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,880 Views)
Hey, I actually tried to both 1) export a panelhandle and 2) export a function call

the results of exporting just the panelHandle weren't so great. I expected the guy to writing the VB stuff to use it as a child panel in his code but it didn't seem to be working so I triecd to solve the problem on my end. This is the code I used (which I got from a sample on the NI site by the way).

//***
parent=*graphsHandle; //this is really the parent panel handle from the code that calls this function
//We will now set graphsHandle to the real graphsHandle
GetPanelAttribute (gPanelHandle[GRAPHS], ATTR_SYSTEM_WINDOW_HANDLE, graphsHandle);

/* Windows SDK function SetParent(..) changes the parent of the child handle so that the parent handle is now the parent of th
e child handle's window.
This will effectively embed the child panel into the parent panel while still potentially allowing the child panel to have its maximize, minimize, and close buttons on the upper right corner.
*/
oldparent=SetParent((HWND)*graphsHandle, (HWND)parent);
if (oldparent==NULL)
{
char errorStr[200];
error=GetLastError();
sprintf (errorStr, "Error number: %d has occurred while calling SetParent function.\nPanels will be displayed independently instead of nested", error);
MessagePopup ("Error in SetParent()", errorStr);
}
//***

Now this gets the panel to show, but still doesn't let us have access to the "graphPanel." He passes in the handle to his panel in the graphpanel pointer and I pass back the handle to the graphs panel in the same variable.

I'll tell you about another try in a different post
0 Kudos
Message 3 of 4
(2,880 Views)
Okay a second try to get the graphpanels to work was that when the VB code called the DLL exported function to bring up the panel I would start a second thread that would just look for events on the graphspanel that I was trying to load while the first thread gave control back to the original VB program.

This let me have access to the panel through the keyboard but not the mouse. For example, I could tab through the buttons and hit enter, but I couldn't click on them.
0 Kudos
Message 4 of 4
(2,880 Views)