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# / August 2007

Tip: Looking for answers? Try searching our database.

resize window in 10 pixel steps

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Piotrekk - 22 Aug 2007 09:33 GMT
Hi

I was wandering if is this possible to resize window in steps
different than 1 px.
Thanks

PK
Bahadır ARSLAN - 22 Aug 2007 10:10 GMT
Hi,

You can set windows width and height pixels so you can increment 10 px.

> Hi
>
[quoted text clipped - 3 lines]
>
> PK
Piotrekk - 22 Aug 2007 10:18 GMT
On 22 Sie, 11:10, Bahad r ARSLAN <bahadir.ars...@netron.com.tr> wrote:
> Hi,
>
[quoted text clipped - 7 lines]
>
> > PK

Yeah but how to get new size in Resize Begin or Resize event?
Piotrekk - 22 Aug 2007 10:18 GMT
On 22 Sie, 11:10, Bahad r ARSLAN <bahadir.ars...@netron.com.tr> wrote:
> Hi,
>
[quoted text clipped - 7 lines]
>
> > PK

Yeah but how to get new size in Resize Begin or Resize event?
Bahadır ARSLAN - 22 Aug 2007 10:21 GMT
Sorry, i couldn't understand what you want to do?

Can you tell with more details?

> On 22 Sie, 11:10, Bahad r ARSLAN <bahadir.ars...@netron.com.tr> wrote:
>> Hi,
[quoted text clipped - 10 lines]
>
> Yeah but how to get new size in Resize Begin or Resize event?
Peter Duniho - 22 Aug 2007 18:14 GMT
> Hi
>
> I was wandering if is this possible to resize window in steps
> different than 1 px.
> Thanks

If you want to limit the user to only being able to size the window in
10 pixel increments, I believe you need to implement this yourself.  You
would handle the Resize event, and in there, look at the current Size of
the control that is the sender of the event, then calculate a new Size
as desired, and finally reassign that new Size to the sender.

You'll have to cast the sender to a Control type, of course, so that you
can access the Control class members of the Form.

Something like this might work for you:

    private void Form1_Resize(object sender, EventArgs e)
    {
        Control ctl = (Control)sender;

        ctl.Size = new Size(((ctl.Width + 5) / 10) * 10,
            ((ctl.Height + 5) / 10) * 10);
    }

This makes the form restricted to the nearest 10-pixel increment of size
based on the dragging.  The "+ 5" before doing the division handles the
rounding; if you just want to truncate to the 10-pixel increment less
than or equal to the dragged size, don't include that part.

Pete
Ben Voigt [C++ MVP] - 23 Aug 2007 05:43 GMT
> Hi
>
> I was wandering if is this possible to resize window in steps
> different than 1 px.
> Thanks

Handle WM_SIZING:

http://msdn2.microsoft.com/en-us/library/ms632647.aspx

> PK

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.