.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Main form does not show up

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
lpleducgroupetanguay
1141 Views, 7 Replies

Main form does not show up

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

7 REPLIES 7
Message 2 of 8

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.

Message 3 of 8

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?

Message 4 of 8

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?

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 8

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.

Message 6 of 8

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.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 7 of 8

Thank you very much.

I was able to move my form back in the screen 🙂

Message 8 of 8

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;
		}
- - - - - - -
working on all sorts of things including www.tvCAD.tv & www.CADreplace.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost