|
-
Oct 5th, 2000, 06:57 PM
#1
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?
-
Oct 6th, 2000, 05:50 AM
#2
Frenzied Member
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)
-
Oct 6th, 2000, 06:10 AM
#3
Shell a program...and after, destroy the window that is being used (not the shelled program). Understand?
-
Oct 6th, 2000, 12:07 PM
#4
Frenzied Member
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.
-
Oct 6th, 2000, 01:58 PM
#5
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.
-
Oct 6th, 2000, 06:59 PM
#6
Frenzied Member
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.
-
Oct 6th, 2000, 08:02 PM
#7
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?
-
Oct 7th, 2000, 06:11 AM
#8
Frenzied Member
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.
-
Oct 7th, 2000, 10:12 AM
#9
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
-
Oct 7th, 2000, 10:37 AM
#10
Frenzied Member
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++...???
-
Oct 7th, 2000, 10:50 AM
#11
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 .
-
Oct 7th, 2000, 11:10 AM
#12
Monday Morning Lunatic
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
-
Oct 7th, 2000, 12:08 PM
#13
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 .
-
Oct 7th, 2000, 12:45 PM
#14
Frenzied Member
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.
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
|