Non-full screen and fullscreen dialogs

  • Thread starter Juan Pedro Gonzalez
  • Start date
J

Juan Pedro Gonzalez

Hi,

I've been trying to do a walk around for dialogs.

I'm using VB .NET 2003. I found out that the ShowDialog wasn't working when
I called it. It seems the dialog would stay on the background. My small
workarround for full screen dialogs is as follows:

*FULLSCREEN DIALOGS*

I decleare a Private variable for the form class:

Private mvar_ParentForm as Form

Then I create a new function that overrides the ShowDialog in the form I
wish to visualize as a dialog as follows:

Public Shadows Function ShowDialog(ByRef ParentForm as Form) As
Windows.Forms.DialogResult
Me.mvar_ParentForm = ParentForm
Me.BringToFront()
Return MyBase.ShowDialog()
End Function

The last step is another walkarround so the main application form gets shown
if I close the dialog (The dialog form is called FrmDialog):

Private Sub FrmDialog_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Me.SendToBack()
Me.mvar_ParentForm.BringToFront()
End Sub

This works right for Full screen dialogs, although I don't really like what
I see on the "Running Aplications" window... It shows two applications: One
of them is my real aplication an the other is the dialog form. If I activate
the real aplication I get a blocked form. The last work arround was done due
to this effect: when I activated the Dialog form and I pressed OK the
application form wouldn't show up. Is there a way to get rid of this effect?
I mean merging both "applications" into one application?

Note: asigning the parent form won't work as I get a blocked dialog window
with an innactive bar.


*NON-FULL SCREEN DIALOGS*

It seems this is a really common question... Here's my work around for this
kinds of dialogs...

The work arround I did here is as follows (Again everything is done in the
form that will act as a dialog):

I changed the Form's New (Comments are in spanish as it's my natural
language):

Public Sub New(Optional ByVal ParentForm As Form = Nothing)
MyBase.New()

Me.Parent = ParentForm

'El Diseñador de Windows Forms requiere esta llamada.
InitializeComponent()

'Agregar cualquier inicialización después de la llamada a
InitializeComponent()
End Sub

It seems important to asign the parent before initializing the components.
The next step would be overriding the ShowDialog:

Next step: Override the de ShowDialog as follows:

Public Shadows Function ShowDialog() As Windows.Forms.DialogResult
Me.Parent = Nothing
Me.BringToFront()
Return MyBase.ShowDialog()
End Function

You'll notice I assigned a parent for this form and now I'm setting it to
nothing... Well, there's an explanation to it: If I dont set the parent form
on New then I don't get a Non-full screen dialog, but if I don't reset this
value to nothing the I'll get a blocked form wich I won't be able to move or
click on any item of it. By setting it to nothing this problem dissapears
and I'll be able to use the form.

This walkarround will give a working non-full screen dialog but there's
still some points wich I'd like to get fixed and maybe someone can help with
it.

The first problem is that the title bar will be shown in a grey color
(inactive) although you can move it and interact with the controls on it.
Any ideas on how to get this fixed?

The second problem, wich is giving me a headache is the ok button. If the
form has the MinimizeButton set to true the "OK" button shows up correctly
but it won't interact with the user... if the minimizebutton is set to false
the ok button will appear displaced and won't let you interact, although
it's displaced because a hiden minimize button is there (and it will let you
minimize the dialog although it won't return a value)... If the controlbox
is set to false the ok button won't appear, but the "hidden" minimize button
will still be there.

If there's a way to get the "Ok" button image intro the "hidden minimize"
button, this walkarround could be tweaked to get a fully working non-full
screen dialog. Any one has any idea on how to do this? Another good way to
get it working would be trying to do some subclassing or something to get
the ok button to work with the minimizebox to true. Again asking for help
with this issue.

Greetings,

Juan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top