2

I have to define the size and position of the form's client area.

I have viewed this link and used the below code for defining the client area of the form.

 private void On_Wm_NcCalcSize(ref Message m)
    {
        NativePaint.RECT rect = new NativePaint.RECT();
        NativePaint.GetWindowRect((int)this.Handle, ref rect);

        rect.top += CaptionHeight;
        rect.left += borderWidth;
        rect.right -= borderWidth;
        rect.bottom -= borderWidth;

        Marshal.StructureToPtr(rect, m.LParam, true);
    }

It works perfectly. But I can't able to understand the purpose of the method call Marshal.StructureToPtr(rect, m.Lparam, true).

I have analyzed about this here. But I can't understand the reason for using the method in this scenario.

Is this the only way to customize the client area?

Can anyone please share your knowledge.

Community
  • 1
  • 1
  • Sounds like an x-y problem. Why do you think you want to do this? – TaW Mar 27 '17 at 07:17
  • that's what I don't know. Is there any possibilities to define the client area without using this.? – Mohanram Anbukkarasu Mar 27 '17 at 08:32
  • I meant: Why do you want to 'change the clientarea?'. - Also: Does that mean you want it to be different from just the full window area minus borders and minus title?? – TaW Mar 27 '17 at 10:22
  • I have to increase the size of the title bar. For that I am need of this. – Mohanram Anbukkarasu Mar 28 '17 at 04:29
  • This is very hard! Instead I suggest to remove the titltebar altogether and simulate one of you own. - See [here](http://stackoverflow.com/questions/42751715/adding-buttons-to-side-of-window-on-windows-form/42812851#42812851) for an example to workaround the issue! (It seems to be about transparency, but the top label acts as a title bar!!) – TaW Mar 28 '17 at 07:09

0 Answers0