Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

Mainform show and hide problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alistair George - 24 Sep 2007 07:04 GMT
Hi in Delphi its a piece of cake to show and hide a mainform eg
mainform.show mainform.hide.
However, after finding similar actions in C# seem to result in destroy
of form object, which causes errors maybe I am wrong, but here is what I
have tried with no joy:
        private void TrayFormShow_Click(object sender, EventArgs e)
        {
            frmMain.ActiveForm.ShowInTaskbar = true;
            frmMain.ActiveForm.WindowState = FormWindowState.Maximized;
// or:           frmMain.ActiveForm.Visible = true;
        }

        private void frmMain_Deactivate(object sender, EventArgs e)
        {
            frmMain.ActiveForm.ShowInTaskbar = false;
            frmMain.ActiveForm.WindowState = FormWindowState.Minimized;
            // or:           frmMain.ActiveForm.Visible = false;
        }

Once the frmMain is hidden, then it causes an error when try to show. Do
I have to create a reference object or whats the story thanks.
Al.
Som Nath Shukla - 24 Sep 2007 08:00 GMT
>          private void frmMain_Deactivate(object sender, EventArgs e)
this event is fired automatically .at that time form object has been
destroyed .so u should not use this event .beacuse u can not acceess the form
object. better to use differet event . if u are still facing prob .tell me
detail.

> Hi in Delphi its a piece of cake to show and hide a mainform eg
> mainform.show mainform.hide.
[quoted text clipped - 18 lines]
> I have to create a reference object or whats the story thanks.
> Al.
Alistair George - 24 Sep 2007 09:05 GMT
>>          private void frmMain_Deactivate(object sender, EventArgs e)
> this event is fired automatically .at that time form object has been
[quoted text clipped - 24 lines]
>> I have to create a reference object or whats the story thanks.
>> Al.

Yes, thank you that is what I suspected, but there is no information on
doing this job properly in all the threads I have looked at. For the
sake of completeness, would someone kindly put up the 'approved' method
for showing and hiding forms in the above circumstances.
Even if the resize event is used, when its time to restore there is the
form object needed.
Thank you. Alistair.
Marko Draca - 24 Sep 2007 09:50 GMT
>>>          private void frmMain_Deactivate(object sender, EventArgs e)
>> this event is fired automatically .at that time form object has been
[quoted text clipped - 32 lines]
> form object needed.
> Thank you. Alistair.
Are you looking for something like this:

private void frmMain_Resize(object sender, EventArgs e)
    {
        if (FormWindowState.Minimized == WindowState)
        {
            this.Hide();
        }
    }

private void niTray_DoubleClick(object sender, EventArgs e)
    {
        this.Show();
        WindowState = FormWindowState.Normal;
    }
Alistair George - 24 Sep 2007 19:46 GMT
> Are you looking for something like this:
>
[quoted text clipped - 11 lines]
>         WindowState = FormWindowState.Normal;
>     }
Crikey, I never used ".this" because I figured it had been lost in
windows deactivate, but it works and perfectly thank you.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.