Results 1 to 14 of 14

Thread: Running files/closing window

  1. #1
    Guest
    How would you run a file through C++ code? And after done loading a file, how do you close the window that C++ is using?

    Is this even possible?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I don't fully understand your question.What do you mean run a file.Do you mean opening a file with ShellEx API function or opening some text file or bitmap.You can close a window using the Destroy Window API.
    Code:
    DestroyWindow(hWnd)
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Guest
    Shell a program...and after, destroy the window that is being used (not the shelled program). Understand?

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Well in that case you call an app for example notepad.After this in your code put:
    Code:
    ShellExecute(NULL,"open","c:\\bootlog.txt",NULL,NULL,SW_SHOW);
    DestroyWindow(handle of your app main wnd);
    This way the shelled app will stay and your app (the app that shelled it) will close.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Guest
    Is that for C++?

    I know how to do it all in VB. But it is C++ that I am new to and want to know how.

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Yes it is for C++.You can get the HWND of your window using the FindWindow Function.
    Code:
    HWND handle = ::FindWindow(NULL,"TitleBarText");
    ShellExecute(NULL,"open","c:\\bootlog.txt",NULL,NULL,SW_SHOW);
    DestroyWindow(handle);
    This will open Notepad and Close your app.If you know VB than you know how to use the ShellExecite in some other way.

    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7
    Guest
    Hmm...don't I have to state something else? Like #include <iostream.h> (which I don't believe contains the ShellExecute and FindWindow or DestroyWindow functions.) So what would I shall I do?

  8. #8
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    No.The iostream.h is for input-output operations.The ShellExecute,FindWindow and Destroy Window are available without including header files,like almost all API functions.
    What do you mean "what would i shell i do".
    Shell the app you want to activate,or like in my example some file which will open in its default viewer.Then you destroy your window and everything is set.
    Why don't you try the code.It works.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  9. #9
    Guest
    It won't work for me though. I am using Turbo C++, not VC++.

    It keeps selecting:

    ShellExecute(NULL,"open","c:\\bootlog.txt",NULL,NULL,SW_SHOW);

    Error messge:

    • Warning NONAME00.CPP 1: Style of function definition is now obsolete
      Error NONAME00.CPP 1: ) expected

  10. #10
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Oh,why didn't you say that you use Turbo C++.In that case i can't help you.I am also a begginer in C++.This code works for me in VC++ but in Turbo C++...???
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  11. #11
    Guest
    I have Visual Studio Professional. I guess VC++ doesn't come with it. How much did you buy it for? I assume the price is high .

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    VC is definitely in VS.

    You don't need to use FindWindow to get the handle of your window - you get it when you create the window to start with:
    Code:
    HWND hWnd_Main = CreateWindowEx(...);
    // or
    HWND hWnd_Main = CreateDialog(...);
    Are you still at school, Matthew? Because you can then get it on academic pricing.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13
    Guest
    I am still in high skool parksie .
    I did buy the Visual Studio Professional Edition 6.0 from someone on the Forums.
    Doesn't seem to contain C++ though .

  14. #14
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    VC++ comes with VS.I am sure about that.When you install VS choose VC++.
    I bought the whole VS for 5$.You know , in my country prices are the same for everything.1$ for 1CD.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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