Click to See Complete Forum and Search --> : strange... SetWindowPos


Nikon82
April 20th, 2004, 09:15 AM
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!

kirants
April 20th, 2004, 12:46 PM
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 ?

Nikon82
April 21st, 2004, 01:01 AM
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

Marc G
April 21st, 2004, 07:56 AM
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.

Nikon82
April 21st, 2004, 08:31 AM
Yes... i have yet thought it... in my code there is spleep(2000)... read the previous post...

however thanks...


help me...

Marc G
April 21st, 2004, 08:59 AM
Does the maximizing stuff works when you leave out the line SetParent(wHaptek,hWndP)?

Nikon82
April 22nd, 2004, 01:54 AM
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:

Marc G
April 22nd, 2004, 07:45 AM
wHaptekC is the old parent of wHaptek.