question

Wami007-9389 avatar image
0 Votes"
Wami007-9389 asked AhmedBahri-1128 commented

C++/CLI Form Resize Problem After Fill Panel

I want resize my Panel Filled Form with BOTTOMLEFT, BOTTOM in addition to BOTTOMRIGHT

My Default Resizing Code Resize only Form without Panel :

           const int cGrip = 16;
           const int cCaption = 32;
       void WndProc(Message% m) override
        {
            switch (m.Msg)
            {
            case WM_NCHITTEST:
                Point pos = Point(m.LParam.ToInt32());
                pos = PointToClient(pos);
                if (pos.Y < cCaption)
                {
                    m.Result = IntPtr(HTCAPTION);
                    return;
                }
                if (pos.X >= ClientSize.Width - cGrip && pos.Y >= ClientSize.Height - cGrip)
                {
                    m.Result = IntPtr(HTBOTTOMRIGHT);
                    return;
                }
                break;
            }
            __super::WndProc(m);
        }
dotnet-csharpc++dotnet-runtime
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Need Help ...

0 Votes 0 ·

Any Solution...

0 Votes 0 ·
ArtemiyMorozUA avatar image
0 Votes"
ArtemiyMorozUA answered Wami007-9389 commented

hi there!

I would suggest you catch WM_MOUSEMOVE messages. WM_NCHITTEST if for different purposes


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you provide me working Code :)

0 Votes 0 ·

Remaining...

0 Votes 0 ·
JeanineZhang-MSFT avatar image
0 Votes"
JeanineZhang-MSFT answered AhmedBahri-1128 commented

According to the Doc:

If the mouse is not captured, the message is sent to the window beneath the cursor. Otherwise, the message is sent to the window that has captured the mouse.

As far as I'm concerned, When the DOCK attribute of the panel is Fill, the message is sent to the panel window instead of the form window. So we couldn't resize the form after fill panel.

I suggest you could try to override OnSizeChanged of form and set the region of panel same size as form and then exclude its bottom right corner. This way, the excluded region doesn't belong to panel anymore and all messages including WM_NCHITTEST will be received by our WndProc; the panel even doesn't draw that region.

Here is my code:

 protected:
     void OnSizeChanged(EventArgs ^ e) override
     {            
         region = gcnew System::Drawing::Region(System::Drawing::RectangleF(0, 0, this->Width, this->Height));
         sizeGripRectangle = gcnew System::Drawing::RectangleF (this->Width - tolerance, this->Height - tolerance, tolerance, tolerance);
         region->Exclude(*sizeGripRectangle);
         this->panel1->Region = region;
         this->Invalidate();

     }

Best Regards,

Jeanine



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 11
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

90086-image.png



 give me undefined error
0 Votes 0 ·
image.png (137.6 KiB)

You should add the following code:

     int tolerance = 1;
     System::Drawing::RectangleF^ sizeGripRectangle;
     System::Drawing::Region^ region;
0 Votes 0 ·

Sir, I added your code without error ( with some "int to float" warnings ) but there is no any changes with any Anchor or Dock Properties , What i missing?
I fixed it with set Panel Anchor points over form, keep Form edges free and send panel to back, but in this case when menu panel opens, it cover picturebox and picture box doesn't move dynamically with MenuPanel....

0 Votes 0 ·
Show more comments

90089-ezgifcom-gif-maker.gif



Please See GIF i wanna Keep This Effect With Resize, Menu Is Left Dock and Center is Fill dock now also all added
contents move dynamically

0 Votes 0 ·

Problem Remaining...

0 Votes 0 ·

Any Solution ?

0 Votes 0 ·

Up...





0 Votes 0 ·

Send me the code github

0 Votes 0 ·

Whats your Github account?

   There nothing special code just 

` 1.Open project
2.Add Left Dock Panel
3.Add Fill Dock Panel
4.Add resize code for redraw

In this case resizeable Form doesn't resize after fill dock and When fill dock is set, all picture box move dynamically with menu panel on the fill dock



0 Votes 0 ·
Viorel-1 avatar image
0 Votes"
Viorel-1 answered Wami007-9389 commented

To resize the child control automatically after resizing the form, set its Anchor properties. This can be done in Form Designer manually, or programmatically:

 panel1->Anchor = (AnchorStyles)(AnchorStyles::Left | AnchorStyles::Top | AnchorStyles::Right | AnchorStyles::Bottom);

Show more details if you need a special behaviour.



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have Left Panel Menu With Hover Animation and when Menu open, it block ClientArea Contents.If i Fill CenterArea Panel it move with menu panel dynamically...

0 Votes 0 ·

90123-ezgifcom-gif-maker.gif



Please See GIF i wanna Keep This Effect With Resize, Menu Is Left Dock and Center is Fill dock now also all added
contents move dynamically

0 Votes 0 ·

I can keep Form Edger free and made Anchor points but in this case menu panel covers picture box and Picture box doesn't move dynamically with menu panel

0 Votes 0 ·