Minimizing then showing a Modal Dialog;

M

Matt Budd

Hello all..

I am writing a fairly simply C# app that consists of a main form and then a
modal dialog. The glitch is that when I click my button on the main form, I
want to minimize the main form before I show the modal dialog. I've tried
the following code:

//-----------------------------------------
FormWindowState leOriginalWindowState = this.WindowState;
frmPreview loPreviewForm = new frmPreview();

this.WindowState = FormWindowState.Minimized;
loPreviewForm.ShowDialog();
this.WindowState = leOriginalWindowState;
//-----------------------------------------

This does launch the dialog, but because I minimized the main form, the
application loses focus in the taskbar. Even though the dialog itself isn't
minimized, the OS focus changes to the next open application (like if I
would've done an Alt+Tab), and the dialog then appears behind the other
application window.

I can get it to sort of work if I do a this.Hide() and this.Show() instead
of the minimize and restore, but I don't really want to comprimise that
functionality...any ideas?

Thanks for any info,
Matt
 
M

Matt Budd

If we can minimize it then it remains in the taskbar and goes through the
minimize animation. Hiding it just makes it disappear and it no longer shows
up in the taskbar. Our users might not understand where it has gone or why
it seemed to transform.

Yes, this comprimise is feasable, but most of our user base is not
computer-savvy, and we would like to make it as least confusing as possible
(i.e. sticking with something they know from other apps in minimization).

Bottom line...the functionality we want is to minimize the main form before
showing the modal dialog. The hide/show is working right now, but it is not
what we want. Does anyone know a way that we can achieve what we want to do?

- Matt
 
J

Jonathan Miller

I agree the tag is where I would like to store my primary key. However, it appears that a menuitem does not have tab property.

nntp://news.microsoft.com/microsoft.public.dotnet.framework.windowsforms/<[email protected]>

Jonathan Miller said:
I am dynamically generating some of the menuitems in a context menu. So
far everything has worked well. I can add the menu items, I can even add a
click event handler. However, this presents a new problem. Since all of
the items are generated on the fly, they all point to the same handler code.
How do I tell what menuitem was clicked on? I understand I can use the
sender object to read the name, but I really need a way to associate a
database primary key with each menu item. Any ideas on this?
I'd use the 'tag' property... it's an 'object' so you can associate anything
to it... like

MenuItem myItem = new MenuItem();
myItem.Text = "Blablabla";
myItem.Tag = "MyKey";

---

protected void onMenuItemClick(object sender, EventArgs e) {
string mySQL = "SELECT " + (string)((MenuItem)sender).Tag) + " FROM
myTable";
}

Hope this helps

Javier Campos



[microsoft.public.dotnet.framework.windowsforms]
 

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