NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

hInstance

Is it possible to get the hInstance from the TestStand sequence context of TestStand engine?

The hInstance variable is a handle to the instance associated with the TestStand window. People familiar with the Win32 SDK knows how and when this variable is used.
0 Kudos
Message 1 of 6
(3,872 Views)
Ke - An hInstance is usually the handle to a DLL that was acquired from calling LoadModule or the handle that is given to DLLMain in a DLL that is loaded. TestStand is comprised of many DLLs so I am not sure what you are looking for. If you are interested in the main window handle for the applicaiton that is hosting the TestStand engine, the application should have set the Engine.AppMainHwnd property on startup. The TestStand sequence editor does this and so do the default TestStand OIs.

Does this answer your question?
Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 6
(3,863 Views)
Thanks Scott for your response. I have some more concerns though about the AppMainHwnd property.

Im trying to fetch the TestStand hInstance (hInstance = (HINSTANCE) engine->AppMainHwnd). Then I create a Window (using Win32 SDK), with the hInstance variable. But Windows XP does not group the created window with the TestStand operator window. The window is instead floating. That might indicate that the hInstance variable is not correct from TestStand.

I would also like to dock the window to TestStand, thus is it possible to find out the TestStand window size?
0 Kudos
Message 3 of 6
(3,850 Views)
Ke -
According to the SDK, the hInstance parameter on the CreateWindow function says:

Windows 95/98/Me: Handle to the instance of the module to be associated with the window.
Windows NT/2000 or later: This value is ignored.

So I do not think that this matters.

The key issue to understand is are you trying to make the new window have the TestStand application window as its owner or as its parent?

The window size of a hWnd can be determined by GetClientRect.
Scott Richardson
https://testeract.com
0 Kudos
Message 4 of 6
(3,834 Views)
The window I create should have TestStand as its parent.
0 Kudos
Message 5 of 6
(3,823 Views)
Ke -
Trying to make a window a child of another window can be problematic since the hosting window does not know about the child window. You are welcome to try. In the case of the sequence editor the main hWnd registered with TestStand is the main application. The MDI area is a child of that and you could use FindWindowEx to get it.

Your code might look something like

TS::IEnginePtr engine = context->GetEngine();
HWND hParent = (HWND)engine->GetAppMainHwnd();
hParent = FindWindowEx(hParent, NULL, "MDIClient", "");
HWND hChild = CreateWindowEx(
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_MDICHILD | WS_EX_WINDOWEDGE,
"ChildWClass", "WindowName",
WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_VISIBLE,
200, 200, 400, 200,
hParent, NULL, NULL, NULL);

If you are creating this window using an call to a DLL in an execution, you need to make sure thae DLL that creates your child window stays in memory by calling LoadLibrary on itself.
Scott Richardson
https://testeract.com
0 Kudos
Message 6 of 6
(3,809 Views)