|
| ||||||||||
| Tags: dll, findwindows, get handle |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| how to get control handle from dll
|
|
#2
| ||||
| ||||
| Re: how to get control handle from dll
You can try to call FindWindows, which is explained more here on this link, with the name of window to get the handle on the main dialog window or even if you call the classname, which should be known by you, with Spy++ you can easily grab it as an argument. After that you can call EnumChildWindows, code for it is here, to search for the handles to the controls within the main dialog. |
|
#3
| |||
| |||
| Re: how to get control handle from dll
You can also use IntPtr type to pass Handle. IntPtr type is being used in the Control.Handle Property, if you can see for example. C# functions that is the API can used by C++ classes but it can used directly in C#. You can use C++/CLI wrapper that calls C++ classes directly and exposes .NET interface to C# client, which will be the best way to use C++ code. Although C++/CLI is a better way, there are other way to C wrapper for C++ classes and using it from C# |
|
#4
| ||||
| ||||
| Re: how to get control handle from dll
Check out the below sample code that will help you to get started: Code: #define Title 0x130
BOOL CALLBACK EnumChildProc
(
HWND hwnd,
LPARAM lParam
)
{
TCHAR szWindowText[256];
HWND* lpHwndReceiver = (HWND*)lParam;
GetWindowText
(
hwnd,
szWindowText,
sizeof(szWindowText)
);
if (_tcscmp(szWindowText, TEXT("start")) == 0)
{
LONG_PTR lValTemp = GetWindowLongPtr
(
hwnd,
GWLP_ID
);
if (lValTemp == Title)
{
*lpHwndReceiver = hwnd;
return FALSE;
}
}
return TRUE;
}
void GetStartButton1(HWND& hWndStartButtonReceiver)
{
hWndStartButtonReceiver = NULL;
HWND hWndShellTrayWindow = NULL;
hWndShellTrayWindow = FindWindow(TEXT("Shell_TrayWnd"), NULL);
if (hWndShellTrayWindow)
{
EnumChildWindows
(
hWndShellTrayWindow,
EnumChildProc,
(LPARAM)&hWndStartButtonReceiver
);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
HWND hWndStartButton = NULL;
GetStartButton1(hWndStartButton);
return 0;
}
__________________ The FIFA Manager 2009 PC Game |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "how to get control handle from dll" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Would an 850 PSU can handle with GTX 580 in SLI | Antton | Monitor & Video Cards | 5 | 18-03-2011 10:17 PM |
| How to handle the virus | Sandal wood | Networking & Security | 3 | 03-02-2011 06:37 PM |
| How to handle .net passport | Eleeazar | Windows Software | 3 | 12-11-2009 07:11 PM |
| How to Handle the Error Control Operator in PHP | Fragman | Software Development | 3 | 10-09-2009 01:19 PM |
| How to handle exception in VBA | afidelino | Software Development | 3 | 03-09-2009 03:30 PM |