|
-
Jun 21st, 2001, 11:30 PM
#1
Thread Starter
Hyperactive Member
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
Amon Ra
The Power of Learning.
-
Jun 22nd, 2001, 05:59 AM
#2
Frenzied Member
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.
-
Jun 22nd, 2001, 06:01 AM
#3
Frenzied Member
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
-
Jun 22nd, 2001, 02:48 PM
#4
Frenzied Member
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);
-
Jun 22nd, 2001, 03:03 PM
#5
Thread Starter
Hyperactive Member
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
Amon Ra
The Power of Learning.
-
Jun 22nd, 2001, 03:06 PM
#6
Thread Starter
Hyperactive Member
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
Amon Ra
The Power of Learning.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|