1

Previously I have posted a question about How to create non-client area? and I got my answer. Now, I want to prevent user to add control on specific client area.So, User can add control only on allocated portion of client area.

The control should be looked like this. enter image description here

CLASS DESIGN & CODES

XWizardControl: is the main user control which will be placed on form.

XWizardPageWindow: is the container which will contains all XWizardPages. This control will be placed on the XWizardControl. User will add pages from the Control Collection Dialog Window.

XWizardPageCollection: is the collection of XWizardPage.

XWizardPage: user will place other controls here.

XWizardPageDesigner: Control designer for XWizardPage control

enter image description here

Community
  • 1
  • 1

1 Answers1

0

You're setting the nonclient rectangle incorrectly.

"On entry, the structure contains the proposed window rectangle for the window. On exit, the structure should contain the screen coordinates of the corresponding window client area." -MSDN-

Also notice that the RECT structure is a ltrb rectangle and not a xywh rectangle.

Incorrect

You shouldn't set the values explicit:

ncRect.top = 68; //<----
ncRect.left = 176; //<----
ncRect.bottom -= 68;

ncParams.rectProposed.top = 68; //<----
ncParams.rectProposed.left = 176; //<----
ncParams.rectProposed.bottom -= 68;

Correct

But rather add (+=) or subtract (-=) to/from the rectangle:

ncRect.top += 30; //<---- 30px top-margin
ncRect.left += 50; //<---- 50px left-margin
ncRect.bottom -= 20; //<---- 20px bottom-margin

ncParams.rectProposed.top += 30;
ncParams.rectProposed.left += 50;
ncParams.rectProposed.bottom -= 20;

Note

If you don't paint the nonclient area correctly, and a control is placed at lets say the location -5, -5, then the control may appear as if it's inside the nonclient area.

Bjørn-Roger Kringsjå
  • 9,849
  • 6
  • 36
  • 64