Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 10th, 2005, 12:20 PM   #1
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Using Multiple Windows...

Alright well what im trying to achieve is to open a window onto of the main window.

I am createing a notepad/ richtext editor, and when the user clicks file new on the menu a window should prompt with the FileNew Form I created. I know in VB6 all I had to do is say TheFormName.Visible = True but its not this way in .NET, anyone know how?

Also to clear up any confusion, the form I want to show has already been created and is in the project explorer, the forms name is frmFileNew

Thanks.
brokenhope is offline   Reply With Quote
Old Sep 10th, 2005, 12:29 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You need to load a new instance of the form:
Dim MyForm As TheFormName

MyForm = New TheFormName
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 10th, 2005, 12:40 PM   #3
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Alright thanks, that worked. The reason I messed up on the article I read was it said Dim oForm As FormName, and I was thinking it was like a variable Integer, and thats what FormName represented, but really it actually meant the forms name 0_o.

Anyways is there any way to make the Parent window inactive (without disabling it) while the new form is open. Like most applications when you go file new, and the new dialog comes up, you cant play around with the main program until you close the new dialog...
brokenhope is offline   Reply With Quote
Old Sep 10th, 2005, 1:16 PM   #4
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
After you create the form, use the ShowDialog method.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Sep 10th, 2005, 1:20 PM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Set the Enabled process to False, I guess.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 10th, 2005, 1:28 PM   #6
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
ShowDialog, instead of Show worked. Thanks. I have one last question about trying to communicate to the main form from the new form....

I have two forms

formMain
formFileNew

When you click the new button on formMain the formFileNew form comes up, when you click OK on formFileNew it needs to close itself (which works) and enable rtbTextBox on formMain, which doesnt work.

I cant figure out how to naviagate the code to the main form. Heres the code I tried in formFileNew to do this, which doesnt work:

    Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click
        Dim formMain As formMain
        formMain.rtbTextBox.Enabled = True
        Me.Close()
    End Sub

formMain.rtbTextBox.Enabled = True Fails and I get an error. Everything is spelled correct as well. Anyone know how to do this?
brokenhope is offline   Reply With Quote
Old Sep 10th, 2005, 1:32 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
First of all, you can't declare a variable with the same name as a variable type:
Dim frmMain As formMain
Next, you need to create it first:
frmMain = New formMain
frmMain.rtbTextBox.Enabled = True

Out of interest, what does formFileNew actually do?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 10th, 2005, 2:13 PM   #8
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Ooble's advice would create another form resulting in 3. I suppose you want to communicate back to the *original* form. This is not VB6, you need a reference to "communicate" with a form. In your setup, A method in the formMain class creates and gets a reference to an instance of formFileNew. formFileNew has no way to access the formMain instance that created it. I would suggest adding a property on the formFileNew class specifying what the user has selected. When the form closes, access the property. ShowDialog returns when the form is closed, so the property should have the data you want.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Sep 10th, 2005, 2:51 PM   #9
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
You could declare your main form's instance as a public shared variable: if your project runs the main form, you'll need to create global a main() routine for startup, i.e.

Public Shared ifrmSomeForm As frmSomeForm

Public Sub Main()
        ifrmSomeForm = New frmSomeForm ' We create the instance here as opposed to in the variable declaration as that could lead to multithreading problems
        ifrmSomeForm.Show()
        ' Insert application shutdown code here
End Sub

Then wherever you are, the main instance of the form frmSomeForm can be accessed via ifrmSomeForm without worrying about race conditions etc.
Rory is offline   Reply With Quote
Old Sep 10th, 2005, 4:55 PM   #10
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Alright, Thanks you guys.

Ooble: Yea I need to refrence the original not create another, but formFileNew is the dialog / form that comes up asking for what kind of New file you want to create, Text File, which will have no highlighting, PHP which will have php highlighting, html which will have html highlighting, rich text, which will have a whole bunch of rich text options, or specify your own type, also asks where you want to save it, and which abbreviations, headers, footers you want to use if any... so yea...

Daemeon: I didnt quite understand what you meant. Im really new to VB .NET so I dont know much about it, or how to do things. The only thing I understood is it couldnt be done, if that is what you were saying 0_o... I got confused about here "I would suggest adding a property on the formFileNew class specifying what the user has selected. When the form closes, access the property. ShowDialog returns when the form is closed, so the property should have the data you want." I dont know what you meant by add a property to the class, specifying what the user has selected...

Rory: I didnt quite understand that code, as I am new to VB .NET X_X. But reading that code I am guessing it globalizes the 2nd form... atleast thats what I got out of it... Sorry im really new to this, and cant understand any of this very well. This seems kind of object oriented, which ive never worked with before.

Sorry for my noobishity -_-.


EDIT

After reading over the posts a couple of times were you saying like:

On the formMain's code make an event for when OK or close is clicked on formFileNew and get its data and enable the richtext box from there? would that work? or were you saying something else?

Last edited by brokenhope; Sep 10th, 2005 at 5:07 PM.
brokenhope is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:36 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC