-
Annoying...
Code:
if(LOWORD(wParam) == BN_CLICKED && (HWND)lParam == hbtnGetHandle)
{
int input_len = GetWindowTextLength(htxtGetWindow);
TCHAR *pcBuf = new TCHAR[input_len];
GetWindowText(htxtGetWindow, pcBuf, input_len);
new_hwnd = NULL;
new_hwnd = FindWindow(NULL, pcBuf);
if(new_hwnd == NULL)
{
MessageBox(hwnd,"No window with that title found!" ,"Hrmmm..." ,
MB_OK | MB_ICONEXCLAMATION);
}
}
Why does not this recognize the "string" pcBuf?? It seems like the result of the line where it is filled(pcBuf) does not do anything, because when I pass to FindWindow, nothing happend. Notice the check after, to see if a handle was actually found. When i run the program, it always pops up the Message box, meaning something went wrong. But what?? Would it be the TCHAR stuff?
Thanks for helping me fixing this :)
-
I have a working example if you want it.
http://www.planetsourcecode.com/vb/s...txtCodeId=1944
Sorry that one isn't commented too well but the one on my computer is, just ask me and I'll mail it or upload it. :)
-
but I don't really understand what you are doing...this is what worked basically for me.
PHP Code:
char buffer[100];
GetWindowText(txtTitle, buffer, 100);
FindWindow(NULL, buffer);
//now you have your handle
-
I think the problem is in here :
PHP Code:
new_hwnd = NULL;
new_hwnd = FindWindow(NULL, pcBuf);
try this:
PHP Code:
new_hwnd = NULL;
FindWindow(NULL, pcBuf);
sprintf(new_hwnd, pcBuf);
-
ok...
Can you explain what this does? and apparently, i need a header with the declaration of sprintf. with the arguments, i think it is a conversion, but from what to what? Thanks
-
ok...
I looked in the msdn, and found the header, but when i run the program, it says:
Code:
C:\My Documents\VC++ Projects\WinProg\Handle Fun\h_fun.cpp(44) : error C2664: 'sprintf' : cannot convert parameter 1 from 'struct HWND__ *' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast