strange... SetWindowPos

This window is created when is executed an application that i launch in my code with shellexecute...

HINSTANCE hHaptek;
HWND wHaptek;
HWND wHaptekC;

hHaptek= ShellExecute(NULL, "open","haptek.exe","", "c:\\",SW_SHOW);

Sleep(3000);
wHaptek= FindWindow("ThunderRT6Main", "Wrapper Haptek");


if (wHaptek!=NULL)
MessageBox(wHaptek,"Esiste","on",MB_OK);


wHaptekC=SetParent(wHaptek,hWndP); //is child of another window

if (wHaptekC!=NULL)
MessageBox(wHaptek,"EsisteFiglio","on",MB_OK);

Sleep(2000);
ShowWindow(wHaptekC,SW_MAXIMIZE);

The handle exist but...
I try function SetWindowPos, ShowWindow, SetWindowText and no one work.

Excuse me for my bad english......... :).... I'm italian!

Help me!
[835 byte] By [Nikon82] at [2007-11-18 19:16:41]
# 1 Re: strange... SetWindowPos
What are you trying to do ?
Can you give one example of how you call the function and what you expect to happen because of that ?
kirants at 2007-11-9 13:10:00 >
# 2 Re: strange... SetWindowPos
ShellExecute(NULL, "open","haptek.exe","", "c:\\",SW_SHOW);
wHaptek= FindWindow("ThunderRT6Main", "Wrapper Haptek");
ShowWindow(wHaptek,SW_MAXIMIZE);

The window isn't SW_MAXIMIZE... Why?

THANKS
Nikon82 at 2007-11-9 13:11:00 >
# 3 Re: strange... SetWindowPos
Probably because wHaptek isn't a handle to the correct window.
When you do ShellExecute, the haptek.exe process is started in the background. ShellExecute return immediately. So, if you immediately call FindWindow, you won't find the window because it isn't created yet.
Check if wHaptek contains the handle to the correct window.
Marc G at 2007-11-9 13:11:59 >
# 4 Re: strange... SetWindowPos
Yes... i have yet thought it... in my code there is spleep(2000)... read the previous post...

however thanks...

help me...
Nikon82 at 2007-11-9 13:13:02 >
# 5 Re: strange... SetWindowPos
Does the maximizing stuff works when you leave out the line SetParent(wHaptek,hWndP)?
Marc G at 2007-11-9 13:14:01 >
# 6 Re: strange... SetWindowPos
GREAT GREAT GREAT

THANKS A LOT...

the problem is there

wHaptekC=SetParent(wHaptek,hWndP);

i must use e.g.

SetWindowText(wHaptek) and NOT SetWindowText(wHaptekC)

I don't understand... Why?

YOU ARE GREAT!!!!!!!!!!!!!!!!!!!!!!!! :cool:
Nikon82 at 2007-11-9 13:15:01 >
# 7 Re: strange... SetWindowPos
wHaptekC is the old parent of wHaptek.
Marc G at 2007-11-9 13:16:05 >