Print Page | Close Window

[solved] v18.4 - cannot set WS_EX_TOPMOST any more

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=23639
Printed Date: 22 October 2018 at 6:59am


Topic: [solved] v18.4 - cannot set WS_EX_TOPMOST any more
Posted By: SvenC
Subject: [solved] v18.4 - cannot set WS_EX_TOPMOST any more
Date Posted: 22 May 2018 at 10:55am
I have one dialog window which can be set to be top most to make it an easy drop target window which always stays on top of other windows.

Like documented I call SetWindowPos(myHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);

When I build with 18.2 this works well and sets the window ex style WS_EX_TOPMOST.

But with 18.4 this shows no effect on the top level window myHwnd.

I verified the hwnd in the debugger and with Spy++ - all correct. Putting 18.2 back into play, everything works.

Can you repro that?

And even better, how can it be fixed?


-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017



Replies:
Posted By: rdhd
Date Posted: 24 May 2018 at 4:02pm
SetWindowPos is a complicated API. I have spent lots of time hacking on the parameters as there are so many options. So what's the actual issue? I assume another window is also a top most window and that is causing some issue. Perhaps the new MFC is now making a window top most that either wasn't there before, or wasn't top most. Or, even if it was topmost, the order of the calls to SetWindowPos has changed.

At this point I would probably search MFC for WS_EX_TOPMOST and see if any calls with it have changed from 18.2 and check to see if the order between yours and one of the MFC ones has changed. Might not be as hard as it sounds. When you get to your code, set/activate a breakpoint in CWnd::SetWindowPos just to see if it is called after you make the call.


Posted By: SvenC
Date Posted: 25 May 2018 at 4:17am
CWnd::SetWindowPos is not called. I use ::SetWindowPos(myHwnd) as well, so I do not call it either

While debugging I can see that I add 0x8 (WM_EX_TOPMOST) to the correct HWND, but using Spy++ I can see that the ex style is not set.

So it is not another window having the topmost flag as well, but mine not getting it (or not holding on to it).

I added a call to GetStyleEx directly after my ::SetWindowPos call and that does not return the topmost style.

Running the same code against 18.2 the GetStyleEx does return my just added topmost flag.

Any other ideas?

A code diff from 18.2 and 18.4 did not show anything obvious in regards to HWNDTOPMOST.
There is some code in a hook section dealing with a shadow window but that is identical in 18.2 and 18.4


-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017


Posted By: olebed
Date Posted: 27 May 2018 at 2:04pm
Hello SvenC,

Try to revert changes in Source/Common/XTPDLLExports.h like in http://forum.codejock.com/forum_posts.asp?TID=23563&KW=sdkddkver.h&PID=76760&title=cxtptaskdialog-windows-xp-issues#76760" rel="nofollow - this post .
And rebuild library.

Regards,
 Oleksandr Lebed


Posted By: SvenC
Date Posted: 28 May 2018 at 2:58am
Tried that. No change in behaviour.

I made this change (replaced > 1600 with > 160000) in the code.
A bit different to yours because of the new #else part in there:

#if _MSC_VER > 1200

// #if _MSC_VER > 1600
#if _MSC_VER > 160000
#include <sdkddkver.h>
#else

So sdkddkver will not be included.


-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017


Posted By: astoyan
Date Posted: 29 May 2018 at 10:10am
Does you dialog have FrameShadow enabled by any chance? If not, how does it use ToolkitPro so it causes that side-effect (e.i. SkinFramework, CommandBars frame theme, any specific controls on it, etc.)?

Regards,
   Alexander


Posted By: SvenC
Date Posted: 29 May 2018 at 10:51am
I use an CXTPFrameWnd with a ribbon and a CFormView. No skinning

I did nothing explicitly to enable a FrameShadow, but see an additional window in Spy++.

I use the Office 2013 and 2016 themes, depending on the installed Office version. Maybe that introduces that shadow thing?

This is the window hierarchy in Spy++. I set (or try to set) the ex style on the main windows "dg mail Suche".




-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017


Posted By: SvenC
Date Posted: 01 June 2018 at 10:58am
Any other idea?

Can you repro this?

I took the RibbonSample and added TOPMOST flag toggling in the OnCharBold handler of the Bold command in the Ribbon.

With 18.2 the topmost flag is toggled, with 18.4 not.

In mainfrm.cpp add the top most style in precreate to make sure that initially the window has the top most ex style. When you click the Bold button twice the flag should get removed and set again. But with 18.4 the top most flag cannot be set back again, while 18.2 works as expected.

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CXTPFrameWnd::PreCreateWindow(cs) )
return FALSE;

cs.lpszClass = _T("XTPMainFrame");
CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));

cs.dwExStyle &= ~WS_EX_CLIENTEDGE;

  cs.dwExStyle |= WS_EX_TOPMOST;

return TRUE;
}

in RibbonSampleView.h add the OnCharBold override:

  void OnCharBold();

in RibbonSampleView.cpp add the implementation:

void CRibbonSampleView::OnCharBold()
{
  CWnd* pWnd = AfxGetMainWnd();
  if(pWnd != nullptr)
  {
    DWORD exStyle = pWnd->GetExStyle();

    if((exStyle & WS_EX_TOPMOST) != 0)
      pWnd->SetWindowPos(&CWnd::wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    else
      pWnd->SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  }
}



-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017


Posted By: SvenC
Date Posted: 11 June 2018 at 1:52am
Please, any ideas?

This bug prevents me to go from 18.2 to 18.4.

That window in our case is a drop target and it is much harder to use if it falls behind the window from which something should be dragged on our window.


-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017


Posted By: olebed
Date Posted: 23 June 2018 at 10:57am
Hello,

I found that bug depends on changes in CXTPFrameShadow part.

As fast workaround you can change m_hOwner to NULL in method CXTPFrameShadow::Create
in part

BOOL CXTPFrameShadow::Create(
.....
    bSuccess = CWnd::CreateEx(exStyle, AfxRegisterWndClass(0),
      _T("XTPFrameShadow"), WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT,
      CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL);
.....

Also this changing fixes other bug 
Quote I found that an application which uses xtreme toolkit version 18.4.0 flickers very much.

The problem can be reproduced by the GUI_VisualStudio example.
We use VS2017 15.7.3 but I think the version is not important.

ToDo:
1. Open GUI_VisualStudio example by Visual Studio
2. Change the function CMainFrame::OnWindowMore() as following
void CMainFrame::OnWindowMore()
{
    CXTPTaskDialog dialogMessageBox(this);
    dialogMessageBox.SetWindowTitle(_T("Test"));
    dialogMessageBox.SetMainInstruction(_T("Test"));
    dialogMessageBox.SetMainIcon(TD_QUESTION_ICON);
    dialogMessageBox.SetCommonButtons(TDCBF_CANCEL_BUTTON);
    dialogMessageBox.DoModal();
}
3. Compile and execute GUI_VisualStudio example
4. Select menu Window->More Windows
==> application flickers

I can reproduce the problem also in our application when calling the CXTPTaskDialog. The mainframe flicker also occurs when updating a custom made tooltip window. The problem is that the tooltip window shows monitoring data and is therefore updated very often which means that our application flickers very much.

Regards,
 Oleksandr Lebed



Posted By: SvenC
Date Posted: 24 June 2018 at 4:40am
That fixed it. Thank you very much!

-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017


Posted By: SvenC
Date Posted: 09 August 2018 at 9:33am
Fixed in 18.5.0 - Thank youThumbs Up

-------------
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017



Print Page | Close Window