Print Page | Close Window

[SOLVED]Snap layout for Win11

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=24452
Printed Date: 15 May 2024 at 1:36am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED]Snap layout for Win11
Posted By: PST
Subject: [SOLVED]Snap layout for Win11
Date Posted: 26 January 2024 at 7:59am
Hi, I'm missing Snap layout support for Win11 when using Ribbon control. I can see there is support done for CommandBar (already in 20.3 according to release notes) but there was nothing done for Ribbon control - this was already mentioned in one post quite a while ago.

Or did I overlook something?



Replies:
Posted By: agontarenko
Date Posted: 31 January 2024 at 1:57am


Hello,

As for snap layouts with MDI child - this problem already fixed.
As for snap layouts with Main form which contains ribbon - Codejock hide original caption and draw custom caption with custom buttons thus in this case snap layouts will not shown.
You can see attached screenshot which demonstrate it is.

Regards,
Artem Gontarenko  


Posted By: PST
Date Posted: 22 February 2024 at 4:50am
Hi Artem, does that mean there is no plan to fix this issue in one of your next releases?


Posted By: rdhd
Date Posted: 29 February 2024 at 12:14pm
I'm not quite understanding this reply. Am I supposed to modify IsCaptionVisible and just return TRUE? I tried that and immediately got an assert in CJ's CXTPModernUIFrameCaptionButton::SetBackgroundColor followed by a crash in CXTPMarkupObject::GetValue(CXTPMarkupDependencyProperty* pProperty).

This happens when I am starting up the app. The m_pMarkupUIElement is nullptr.


Posted By: rdhd
Date Posted: 29 February 2024 at 1:18pm
By the way, you can use Windows+z key in to get the snap menu. That's as close as I got with CJ as we use the ribbon UI.

I do create my own floating frames for our documents and I don't use a ribbon. Snap, rounded corners and the OS provided shadow in Win11 all work just fine.


Posted By: rdhd
Date Posted: 29 February 2024 at 1:57pm
I can avoid the CJ crash if I return TRUE from IsCaptionvisible AND I don't call CXTPRibbonBar::EnableFrameTheme(TRUE).

I can also avoid calling DwmSetWindowAttribute to turn on rounded corners in Win11. I also did not turn on CJ shadows. The result is below. Rounded corners, OS provided shadows and (not shown) I get the Snap menu when over the maximize or restor icon. But, I lost the custom caption, of course, and the Quick Access Bar is no longer in the caption area when I show the ribbon.


Posted By: rdhd
Date Posted: 29 February 2024 at 2:00pm
Trying to insert an image since they didn't show up. This time I ran insert image in the edit toolbar and got another error. Try and try again.


Posted By: rdhd
Date Posted: 29 February 2024 at 3:09pm
Well this is promising. I made only one change. I implemented OnNcHitTest. I got the XTPXControl from the ribbon bar for the maximize button and after calling ScreenToClient on the input point, I called GetRect() on the control and then if PtInRect returns true, I return HTMAXBUTTON.

Now I get the snap menu whether I have a document open or not. I don't have to turn off the frame theme nor return TRUE from IsCaptionVisible.

Now I have to implement the NC button down since clicking on the caption button doesn't result in maximizing the window (which I expected would happen).


Posted By: rdhd
Date Posted: 01 March 2024 at 2:06pm
Seems to be working just fine. I didn't really need OnLcLButtonUp but I keep it for completeness. I needed the button down to make sure the control executes and tracking is correct while the mouse is down. I needed mouse move to ensure selecting and highlighting worked as it should. Now I have SNAP in all cases I know to try.

LRESULT JCXTPRibbonBar::OnNcHitTest(CPoint point)
{
CXTPControl* pButton = m_pControls->FindControl(SC_MAXIMIZE);
if( nullptr == pButton )
{
pButton = m_pControls->FindControl(SC_RESTORE);
}

if( pButton )
{
CPoint ptClient = point;
ScreenToClient(&ptClient);

CRect rcControl = pButton->GetRect();
if( rcControl.PtInRect(ptClient) )
{
return HTMAXBUTTON;
}
}

LRESULT lr = CXTPRibbonBar::OnNcHitTest(point);

return lr;
}

void JCXTPRibbonBar::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
if( HTMAXBUTTON == nHitTest )// HTMAXBUTTON is 9
{
CPoint ptClient = point;
ScreenToClient(&ptClient);
return OnLButtonDown(1,ptClient);
}
CXTPCommandBar::OnNcLButtonDown( nHitTest, point);
}

void JCXTPRibbonBar::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
if( HTMAXBUTTON == nHitTest )// HTMAXBUTTON is 9
{
CPoint ptClient = point;
ScreenToClient(&ptClient);
return OnLButtonUp(1,ptClient);
}
CXTPCommandBar::OnNcLButtonUp( nHitTest, point);

}

void JCXTPRibbonBar::OnNcMouseMove(UINT nHitTest, CPoint point)
{
if( HTMAXBUTTON == nHitTest )// HTMAXBUTTON is 9
{
CPoint ptClient = point;
ScreenToClient(&ptClient);
return OnMouseMove(0,ptClient);
}

OnMouseLeave();
CWnd::OnNcMouseMove(nHitTest, point);
}



Posted By: Pesci7
Date Posted: 04 March 2024 at 9:15am
Tested on my side and snap works fine. I hope it will be fixed also in the next release.
Speaking of the next release, it's been 11 months without any release...


-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 11 (x64)
Language: Visual Studio 2022 (C++)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net