Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

Have a windows form that i can minimise but have set the maximies propertie to false. Am using a Context menu to reshow the window but keep crashing the programme when I select that option. Can anyone tell me what is the command to show up the window?

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted (edited)
Could you post the code you are using?

You should be able to redisplay the form either by doing .Show or by setting .WindowState= FormWindowState.Normal

 

Ok have tried a number of different thinks but they all give the same result, the following error:

An unhandled exception of type 'System.NullReferenceException' occurred in FileWatch.exe

 

Additional information: Object reference not set to an instance of an object.

 

Here is the code i have tried

frmWatch.ActiveForm.visible = true

 

frmWatch.ActiveForm.Show()

 

frmWatch.ActiveForm.WindowState= FormWindowState.Normal

 

Here is the method that is doing the calling:

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctxShowWindow.Click

       MessageBox.Show("Not Operational yet!")
       frmWatch.ActiveForm.WindowState = FormWindowState.Normal

   End Sub

 

Mike55

Edited by mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

  • Administrators
Posted

It looks as though when you are minimizing the form it is no longer the active form - hence the Nullreference exception.

 

Rather than rely on the active form could you not create a variable to store a reference to the form and use that to redisplay the form?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

What, do the following

dim x as new myWinform

 

and the go

 

x.show()

of whatever function cause the form the appear.

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

x.showdialog

 

will make the new form the focused form and will block any others being used.

 

x.show on its own would allow the user to swap to another form and this might mess up your control.

Hamlet
Posted

Here is how I finally did it...

If Me.WindowState = FormWindowState.Minimized Then
           Me.WindowState() = FormWindowState.Normal
           Me.Activate()
       End If

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
Are you keeping all you forms alive for the duration of the application and Minimizing/Mazimizing as needed. Have you considered what might happen if the user does an Alt-Tab and switches to a different one of your forms. It will totally mess up the control flow of your app.
Hamlet
Posted
Are you keeping all you forms alive for the duration of the application and Minimizing/Mazimizing as needed. Have you considered what might happen if the user does an Alt-Tab and switches to a different one of your forms. It will totally mess up the control flow of your app.

 

I see where you are comming from, however its ok for this applications as it only has one form.

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...