c# - How to prevent user to add control on specific location? -


previously have posted question how create non-client area? , got answer. now, want prevent user add control on specific client area.so, user can add control on allocated portion of client area.

the control should looked this. enter image description here

class design & codes

xwizardcontrol: main user control placed on form.

xwizardpagewindow: container contains xwizardpages. control placed on xwizardcontrol. user add pages control collection dialog window.

xwizardpagecollection: collection of xwizardpage.

xwizardpage: user place other controls here.

xwizardpagedesigner: control designer xwizardpage control

enter image description here

you're setting nonclient rectangle incorrectly.

"on entry, structure contains proposed window rectangle window. on exit, structure should contain screen coordinates of corresponding window client area." -msdn-

also notice rect structure ltrb rectangle , not xywh rectangle.

incorrect

you shouldn't set 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 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 don't paint nonclient area correctly, , control placed @ lets location -5, -5, control may appear if it's inside nonclient area.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -