Fixing a form on the screen

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

My program produces a number of overviews, for which
I use different forms, which are displayed. These forms are
displayed at certain positions on the screen. I don't want
the user of the program to start moving them about.

Is there a way to fix displayed forms on the screen so
they cannot be moved about?

Thanks.
 
Hi,
My program produces a number of overviews, for which
I use different forms, which are displayed. These forms are
displayed at certain positions on the screen. I don't want
the user of the program to start moving them about.

Is there a way to fix displayed forms on the screen so
they cannot be moved about?

Probably you don't want to use Forms for this. Can you use a UserControl
instead? I believe it has a designer like that for forms so it shouldn't be
too different.

Pete
 
Probably you don't want to use Forms for this. Can you use a UserControl
instead? I believe it has a designer like that for forms so it shouldn't be
too different.

If I create a user control and call it like so from the main form

UserControl1 usc = new UserControl1();
usc.Show();

Nothing happens. What is it that I should do instead?
 
You have to remove all of the buttons on the title bar and then set the
Title bar text to nothing. At this point it becomes possible to anchor your
windows so users can't simply drag them around (there are still other ways
to move your window that are more complex, but I won't go in to how to fix
those here).

On your form set ControlBox, MinimizeBox, MaximizeBox all to false, then set
Text property to an empty string "" or string.Empty. If I missed a property
just do some searching for other buttons that show up in the title bar. You
should probably also set the FormBorderStyle to FixedSingle.
 
Patrick,
The easiest way is to make the form borderless, by setting the
FormBorderStyle to None. This also gets rid of the caption.

Another option is to set the ControlBox, MinimizeBox & MaximizeBox
properties to False, then set the Text property to an empty string, you will
still have a border, but no caption, so the user cannot move the form. If
you go this route consider setting the FormborderStyle to a fixed size, or
setting the MinimumSize & MaximumSize to the Size property so the form
cannot be resized.

Handling the Move event for the form and forcing the position to remain
where the form started, causes a awful screen flicker...

Not sure if overriding Control.WndProc & handling WM_MOVING,
WM_WINDOWPOSCHANGING or another Win32 message would help (I've never tried
overriding WndProc yet).

Hope this helps
Jay
 
Hi,
UserControl1 usc = new UserControl1();
usc.Show();

I don't think Show is needed.. make sure it's added to the Controls of your
form/whatever and Anchor/Dock is set properly. It should display okay after
that. I'm not too familiar with the designer in vs (i work by hand) so I
can't say much more than that.

Sorry,
Pete
 
Back
Top