|
-
Sep 9th, 2002, 04:09 AM
#1
Thread Starter
Junior Member
Couple of Qs
Using the shell() i call up mediaplayer and play a song given as the argument and use the notepad to read the song lyrics. But these application open up in minimized format instead of their normal/default mode
My Q1 is : How do i open an executible file in the normal mode?
I have total 3 forms and want to create a command button thru which i close all the forms and end the program. But i dont know how to do that (which command/function does that)
My Q2: How do i close up all the open forms and terminate the app?
Also could somebody tell me something about the Terminate and Unload functions.
Any help is appreaciated
PS: I'm a VB noob. Please bear with me if these are stupid and easy questions.
-
Sep 9th, 2002, 04:18 AM
#2
Frenzied Member
The Shell command has a parameter to control what the shelled app window state is;
Shell "notepad.exe",vbNormalFocus
will make notepad appear in it's default position with focus.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Sep 9th, 2002, 04:19 AM
#3
PowerPoster
Q1
VB Code:
Shell "notepad.exe", vbnormalfocus
Q2
Your app, or the app you've just opened?
Q3
Unload?? as in Unload Form1
Is so, that will close the form. You can use this in a loop to close all forms in your programs.
-
Sep 9th, 2002, 04:30 AM
#4
Q1) The shell function supports 2 parameters (bit like when you call a program from dos, sometimes you can type extra arguments after it).
VBMINIMIZEDFOCUS
VBNORMALFOCUS
VBMAXIMIZEDFOCUS
Are 3 variables you can place at the end of the shell function (see above posts for sample code), which determine how the shelled application appears on the screen.
-
Sep 9th, 2002, 04:36 AM
#5
Q2)
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next frm
When a form is loaded into the pc's memory (when the form_load event occurs before the form is shown to the user on the screen), the form object is added to a forms collection.
In basic terms, think of a collection as a table - each cell contains a loaded form. What the above code does is to go through each cell in this table & kill the form. When the above loop finishes, the main form which was shown when you first started up or ran you application was unloaded and it's used reference it was taking up in the computers memory was wiped, so the whole program finishes excecution.
Hope this makes sense!
For more reading on this one, see the MSDN library for "Objects" and why you unload and set them to nothing to clear them.
-
Sep 9th, 2002, 04:40 AM
#6
Q3) The terminate event fires when the object (form in this instance) has the space it was taking up in the pc's ram removed.
The Unload event occurrs right before the form is removed from the screen so the user can no longer see it. This event occurrs before the above terminate event when you close a form!
-
Sep 9th, 2002, 05:53 AM
#7
Thread Starter
Junior Member
Thanks everybody (esp. alex_read) just the kind of info i was looking for.
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
|