resize window in 10 pixel steps

  • Thread starter Thread starter Piotrekk
  • Start date Start date
P

Piotrekk

Hi

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

PK
 
Hi,

You can set windows width and height pixels so you can increment 10 px.
 
Sorry, i couldn't understand what you want to do?

Can you tell with more details?
 
Piotrekk said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top