.NET

Reply
Contributor
gepetto143
Posts: 14
Registered: ‎05-14-2010
Message 1 of 8 (714 Views)
Accepted Solution

Main form does not show up

714 Views, 7 Replies
10-20-2010 07:52 AM

I have an application I developed using vb.net.

Up until yesterday afternoon, my application was loading and showing correctly. 

I don't know if I changed a setting in AutoCAD but my application's main form doesn't show anymore (it was working fine and it just suddenly stopped showing).  I can see it in the task bar but it cannot get focus anymore (I get Me.CanFocus = False when the form loads).

This happend in the same work session.  I did not close AutoCAD, that is why I think I changed an AutoCAD parameter without noticing.

Any idea?

Thanks

Louis

Contributor
gepetto143
Posts: 14
Registered: ‎05-14-2010
Message 2 of 8 (710 Views)

Re: Main form does not show up

10-20-2010 07:58 AM in reply to: gepetto143

I forgot to mention that if I maximise the form I can see it.

I did a few more tests.

- I loaded an other application I wrote and it worked fine

- I loaded an old version (compiled a few months ago) of the application that is not working and it did not work.  The main form of both version of the program have the same name.

Contributor
gepetto143
Posts: 14
Registered: ‎05-14-2010
Message 3 of 8 (702 Views)

Re: Main form does not show up

10-20-2010 08:29 AM in reply to: gepetto143

That's weird...

I changed the name of the form and now, it shows correctly.

If I rename it back to it's original name, it doesn't show.

Any idea?

*Expert Elite*
norman.yuan
Posts: 984
Registered: ‎04-27-2009
Message 4 of 8 (682 Views)

Re: Main form does not show up

10-20-2010 12:03 PM in reply to: gepetto143

What kind of form is it? Modal? Modeless? Or PaletteSet? Do you use

 

Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog()/ShowModelessDialog() to show the form? If yes, it may be that the form's location remebered by AutoCAD was off screen when it was closed last time. This kind of thing happens often when one use a laptop, move around and connect to different Monitor(s).

 

AutoCAD thinks it does a good job to remeber form/dialog box's location when ShowModelessDialog()/ShowModalDialog() method is used, but when AutoCAD tries to place a form back to remebered location, it should have checked whether the rememberd location is off screen or not. How difficult could that be?

 

Contributor
gepetto143
Posts: 14
Registered: ‎05-14-2010
Message 5 of 8 (681 Views)

Re: Main form does not show up

10-20-2010 12:07 PM in reply to: norman.yuan

Modal

 

It's possibly what is happening but I have only 1 monitor and I'm not using a laptop.

Is there a way to make AutoCAD forget the form location?

I tried to fix the location (10,10) of the form when it loads but it doesn't work.

*Expert Elite*
norman.yuan
Posts: 984
Registered: ‎04-27-2009
Message 6 of 8 (676 Views)

Re: Main form does not show up

10-20-2010 12:20 PM in reply to: gepetto143

Modal form? lucky you that you did not set the form's "ShowOnTaskBar" to False, so that you can tell that the form is actually shown, but simply not seeable due to its off-screen position.

 

By Windows tridition, Modal dialog box should not ne shown in task bar. In this case, once the the form is shown (off sceen), AutoCAD looks like frozen to unsuspected user. The first time I ran into this was in one of my office demo of one of my first .NET App for Acad2006: I tested my demo with at my desk with 2 screens and I show the form on the other screen and closed it there. Then when my computer connected to a projector (one screen, of course). Once I run my command, AutoCAD mystically frozen. How embarrassed was I then one can imagine.

 

Now yo can easily move the form back to your main screen with this steps (right after your form shows; Do not use mouse click anywhere):

 

1. Hold down Alt + Spacebar
2. Press the M key
3. Use the arrow keys to relocate the window
4. Press the Enter key when you have the Window in the desired location.

 

 

Contributor
gepetto143
Posts: 14
Registered: ‎05-14-2010
Message 7 of 8 (673 Views)

Re: Main form does not show up

10-20-2010 12:38 PM in reply to: norman.yuan

Thank you very much.

I was able to move my form back in the screen :smileyhappy:

Active Contributor
CADbloke
Posts: 38
Registered: ‎08-12-2008
Message 8 of 8 (393 Views)

How to make sure modal dialogues are on the screen

03-27-2011 08:38 PM in reply to: gepetto143

I got sick of AutoCAD managing window positions regardless of whether there is a screen for the window to display on or not. AutoCAD doesn't check for that - like it doesn't check for Nulls on method inputs but don't get me started on that.

 

ShowModalDialogue can have a property for AutoCAD to persist the postion. It sucks. Don't use it. Set it to false. You can't overwrite the window position once AutoCAD has control over it, so you can't move the window back onto the visisble screen after you undock your laptop or whatever it is you did to make some screen real estate go away.

 

Here's how I got around it ...

 

I added 2 integers to the settings file, WindowLocationX & WindowLocationY and set them to a nominal 100 each so the first run doesn't blow up.

 

I added this to the Window_Shown event to recall the saved location ...

			int x = Settings.Default.WindowLocationX;
			int y = Settings.Default.WindowLocationY;
			Point loc = new Point(x,y);
			this.Location = loc;
						if (!Screen.FromControl(this).Bounds.Contains(this.Location))
			{
				this.DesktopLocation = new Point(100,100);
			}

... the last bit there will move it top top-left-ish if it opens out of bounds.

 

I added this to the window closing event to save the location

		private void UpdateLocationInSettings(object senderFormClosingEventArgs e)
		{
			Settings.Default.WindowLocationX = Location.X;
			Settings.Default.WindowLocationY = Location.Y;
		}
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.