control resizing when monitor resolution change

  • Thread starter Thread starter farukh
  • Start date Start date
F

farukh

dear sir
i want to resize my controls when the user changes the
monitor resolution. so my problem is i am not know the
event which should be fire when the resolution changed i
try form_Resize but it does not work well.
and tell me the short way for tackling this problem.

thnx alot.
 
Hi farukh,

AFAIK there is no such an event. Waht you might wanna do is to override
WndProc and handle WM_DISPLAYCHANGE (0x7e) message. This message is send to
windows when resolution changes.
 
dear sir,
thnx for ur kind help.
can u tell me any short way to tackle this problem? or i hve to pick one
by one all conrol and resize it.

Regards,
Farukh.
 
Hi farukh,

I don't know what you want ot achieve, but I believe it is enough to catch
that message in the level of the form and in responce to change form's Size
and maybe Location. With proper control docking and anchoring the form
should take care of layouting its children.

The code may look something like this
--- In form class ---
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if(m.Msg == 0x7e)
{
Point newSize = new Point(m.LParam.ToInt32());
newSize.X /= 2;
newSize.Y /= 2;
this.Size = (Size)newSize;
}
}

this keeps the form always to be half of the screen size
 
Have a look at this :

http://www.kliksoft.com/?S=2&SS=11

Regards,

Özden

Stoitcho Goutsev (100) said:
Hi farukh,

I don't know what you want ot achieve, but I believe it is enough to catch
that message in the level of the form and in responce to change form's
Size
and maybe Location. With proper control docking and anchoring the form
should take care of layouting its children.

The code may look something like this
--- In form class ---
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if(m.Msg == 0x7e)
{
Point newSize = new Point(m.LParam.ToInt32());
newSize.X /= 2;
newSize.Y /= 2;
this.Size = (Size)newSize;
}
}

this keeps the form always to be half of the screen size

--
HTH
Stoitcho Goutsev (100) [C# MVP]


farukh farooq said:
dear sir,
thnx for ur kind help.
can u tell me any short way to tackle this problem? or i hve to pick one
by one all conrol and resize it.

Regards,
Farukh.
 
Dear sir,
thnx alot. i hope now i can easily tacle this problem.

Regards,
Farukh Ali Farooq.
 
Back
Top