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 / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

Locking window size and position

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KenDev - 22 Jun 2007 23:03 GMT
Using .NET 2.0, I would like to lock my form derived window size and position
(it is not full screen and extends to the bottom) so it does not move when
the auto-hide task bar property is turned off.

Any ideas?

Thanks,
Ken
AlexS - 22 Jun 2007 23:54 GMT
You don't want user to move your form? Why?
Do you think user has no right to locate it as s/he wants?

Anyway, you can hide borders and title bar, so user won't have anything to
grab on. Then it won't move

HTH
Alex

> Using .NET 2.0, I would like to lock my form derived window size and
> position
[quoted text clipped - 5 lines]
> Thanks,
> Ken
KenDev - 25 Jun 2007 15:02 GMT
We have a touch screen application (using the whole screen) running on the XP
OS on our hardware.  It is not targeted for standard desktop configurations.

Turning the border and title bar off ( FormBorderStyle = None) does not
prevent the form from moving when it overlaps the taskbar area.

Ken
 

> You don't want user to move your form? Why?
> Do you think user has no right to locate it as s/he wants?
[quoted text clipped - 14 lines]
> > Thanks,
> > Ken
AlexS - 25 Jun 2007 15:30 GMT
Then you can handle Move event and Resize event (EndResizing) restoring
required position and size

> We have a touch screen application (using the whole screen) running on the
> XP
[quoted text clipped - 26 lines]
>> > Thanks,
>> > Ken
KenDev - 25 Jun 2007 19:55 GMT
But hasn't the form already moved and resized by the time we get those
events?  I tried changing the location in these events and it does move to
the right position, but I see it move to the other position first.

I am considering catching the WM_WINDOWPOSCHANGING message and setting the y
coordinate to my desired location before it gets processed by the base.  I am
not sure I can programmatically prevent the taskbar grab line from showing
when my window does not take the whole screen and I would prefer not to
disable it for the whole system (maintenance guys do use other apps).

> Then you can handle Move event and Resize event (EndResizing) restoring
> required position and size
[quoted text clipped - 29 lines]
> >> > Thanks,
> >> > Ken
Bob Powell [MVP] - 27 Jun 2007 20:07 GMT
You can set a form's MaximumSize and MinimumSize sizes to some value
which will lock it in place.

You can prevent the user rom grabbing the window by overriding the
WndProc and stopping WM_NCHITTEST from responding.

You may also wish to run the code in kiosk mode by not loading Explorer
at startup but running your own application. In this case the desktop
will not exist but all windows services and API's will still function.

In this case, or maybe in all cases, force the app to run maximised.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> We have a touch screen application (using the whole screen) running on the XP
> OS on our hardware.  It is not targeted for standard desktop configurations.
[quoted text clipped - 23 lines]
>>> Thanks,
>>> Ken
KenDev - 28 Jun 2007 15:40 GMT
Setting the MaximumSize and MinimumSize do not lock the window in position.  
Changing the autohide property to false and applying it still moves my
window.  

I can't prevent the user from grabbing the window by overriding the WndProc
and stopping the WM_NCHITTEST from responding because the taskbar is not my
code (am I not understanding your suggestion?).

I have been able to prevent the moving of my window by overriding the
WndProc and resetting the location to what I desire before passing it back on
along the message path.   The grab bar is still there and shows the task bar
when grabbed.

However, I think I actually want to hide the grab bar.  I can
programmatically hide it, but I think I may have some problems because we
have several apps and since we don't have a keyboard (touchscreen) it can be
difficult to get the taskbar back if the apps don't shut down properly.

The only way I have been able to hide the grab bar, is with an application
that takes up the full screen and is not resizable (which is the way our apps
used to work).  Now we have a single navigation app that takes the top of the
screen and multiple apps that sit below it.

Thanks for your help,

Ken

> You can set a form's MaximumSize and MinimumSize sizes to some value
> which will lock it in place.
[quoted text clipped - 35 lines]
> >>> Thanks,
> >>> Ken

Rate this thread:







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.