CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2004
    Posts
    20

    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!

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354
    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 ?

  3. #3
    Join Date
    Apr 2004
    Posts
    20
    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
    Last edited by Nikon82; April 21st, 2004 at 01:06 AM.

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    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 Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Apr 2004
    Posts
    20
    Yes... i have yet thought it... in my code there is spleep(2000)... read the previous post...

    however thanks...


    help me...

  6. #6
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    Does the maximizing stuff works when you leave out the line SetParent(wHaptek,hWndP)?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  7. #7
    Join Date
    Apr 2004
    Posts
    20
    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!!!!!!!!!!!!!!!!!!!!!!!!

  8. #8
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    wHaptekC is the old parent of wHaptek.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured