cdoverlaw Posted October 27, 2003 Posted October 27, 2003 (edited) This is a subroutine which i thought would show another form, (but keep the current form open) but this dosent work, what is wrong with this sub routine Private Sub cmdMP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMP.Click frmMediaPlayer.Visible = True End Sub Edited October 27, 2003 by cdoverlaw Quote
aewarnick Posted October 27, 2003 Posted October 27, 2003 First you have to create an instance of frmMediaPlayer and then call Show() not Visible. Quote C#
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 ok, so how do i do that, what code creates an instance of the form Quote
aewarnick Posted October 27, 2003 Posted October 27, 2003 Form frmMediaPlayer=new frmMediaPlayer(); frmMediaPlayer.Show();I don't know what VB would be but there is how I would do it in C#. It is very similar in VB. If you just look around the code you will see examples. Quote C#
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 Ok, can someone with experience with visual basic point me in the right direction because i am thick, lol, nah its coz i cant seem to work it out, Thanks for trying to help aewarnick, what is c# like, is it better than vb.net and is it easy to learn, i still need help with this vb.net problem though as it would take to long to convert my windows sidebar to c# Jonathan Quote
compturon Posted October 27, 2003 Posted October 27, 2003 ok dim frmname as new objform objform.visible = true Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 Ok, problem fixed, all i need now is to know how to make the file the form has open to close when the form is closed Incase you want to know i used this code Dim frmMP As New frmMediaPlayer frmMP.Show() Quote
*Experts* mutant Posted October 27, 2003 *Experts* Posted October 27, 2003 You can use the Closing event or Closed event to execute code you want to execute before or after the form is closed. Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 And what is the closing event code? Quote
*Experts* mutant Posted October 27, 2003 *Experts* Posted October 27, 2003 Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing End Sub You can get the code for the event in VS.NET by going to the code view, from the object dropdown on the top left of the code editor select FormName Events and then from the combo to the right select the event, it will automatically add the code for you. Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 (edited) How do i get it to close the file though i have this code so far Private Sub frmMediaPlayer_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing End Sub Edited October 27, 2003 by cdoverlaw Quote
aewarnick Posted October 27, 2003 Posted October 27, 2003 "then call Show() not Visible" Sorry, forgot that Show makes Visible true. It is just easier. Thanks for reminding me compturon. Look into the Process class. Lot's of posts here about it. Do a search. Quote C#
compturon Posted October 27, 2003 Posted October 27, 2003 ok so you show a window and you hide the window you launch the new form and when you close new form do you have to close the old Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 my program keeps the original form open while opening a second form which then needs to close leaving only the original form, the problem is that the form that needs to close continues to play the file that was opened in the form, so i need to make it close the file and then close the form (i have got the closing of the form to work, just not the closing of the file) I tried this code FileClose() [code] but this dosent work Quote
compturon Posted October 27, 2003 Posted October 27, 2003 how are you opening the file and what kind of file is it? (post what you use to open it) Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click OpenFileDialog1.ShowDialog() 'display Open dialog box If OpenFileDialog1.FileName <> "" Then Try AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName Catch MsgBox("Error opening media file.") Finally FileClose(1) 'close file End Try End If End Sub This is my opening code The files are media files, .mp3, .mpeg etc Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 Also how do i make the windows media center control resize as the app is resized Quote
compturon Posted October 27, 2003 Posted October 27, 2003 ok in private sub form1_closing(byval.....) AxWindowsMediaPlayer1.URL = "" end sub That should Do it for you Quote
cdoverlaw Posted October 27, 2003 Author Posted October 27, 2003 Thanks, lol why didnt i think of that, i must be getting thicker in my old age (and i am only 16 lol). I had to put it in the form exit sub routine, it wouldnt work on the form closing sub routine Anyway can you please tell me where i can fine out how to control every aspect of the media center control (like make it go full screen, set the media file to repeat etc) Quote
cdoverlaw Posted October 28, 2003 Author Posted October 28, 2003 I cant install it because my hard drive is to small, so is there anywhere on the net i can see the info i require Quote
cdoverlaw Posted October 28, 2003 Author Posted October 28, 2003 hmm, i cant get the stuff i found on there to work properly, i want to make the player to go to fullscreen zoom, what code does this require Quote
samsmithnz Posted October 28, 2003 Posted October 28, 2003 This is a VERY painful thread to work through. To open a new form (lets say its called frmMain): dim frmMainInstance as frmMain frmMainInstance = new frmMain frmMainInstance.show To close it, maybe you have a button or something, use: me.close or frmMainInstance.Close() That closing function is an event and you can put code in their when your form starts to close. Quote Thanks Sam http://www.samsmith.co.nz
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.