|
|
Home » Community » Newbie corner » always on top SOLVED (GUI)
always on top SOLVED [message #46241] |
Fri, 01 April 2016 07:19 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
I have an app compiled may 2014 that is always on top.
I just updated M$VS to 2015 for the compiler and upp #9628
The code has this line:
TopMost(true, true).MinimizeBox();
When compiled and run now it is not always on top.
Has the upp code for always on top changed? If so what is used now?
Neil
[Updated on: Fri, 08 April 2016 20:56] Report message to a moderator
|
|
|
Re: always on top [message #46244 is a reply to message #46241] |
Fri, 01 April 2016 21:02 |
Lance
Messages: 633 Registered: March 2007
|
Contributor |
|
|
Hi nlneilson:
After some digging into the code, I find that the failure is because this line doesn't behave as it's expected or it used to behave:
in Win32Ctrl.h
HWND GetHWND() const {
return parent ? NULL : top ? top->hwnd : NULL;
}
The reason of the failure is because when this function is called before you call Run() on the TopWindow derivative, parent is NULL, which is expected, and top is NULL too (this might have been changed either by UPP developers or is due to changes in Windows SDK). the top will only get a meanful value after Run() is called.
See the following code for an effect:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp: public TopWindow
{
MyApp()
{
Add(b.SetLabel("Set TopMost").SizePos());
b<<=THISBACK(Clicked);
}
Button b;
void Clicked()
{
this->TopMost();
}
typedef MyApp CLASSNAME;
};
GUI_APP_MAIN
{
MyApp().TopMost().Run();
}
Notice the MyApp mainwindow is a normal window contrast to our will, but after click on the button, it becomes TopMost as requested. The only thing changed would be [b]top[/top]'s proper assignment after show.
I don't know how to fix the library code, but he's a quick workaround.
In you top window's construct, add one line:
this->SetTimeCallback(0,THISBACK(SetTopMost));
And add a member function to your MyApp equivalent:
void SetTopMost(){ TopMost(); }
for a reference:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp: public TopWindow
{
MyApp()
{
SetTimeCallback(0,THISBACK(SetTopMost));
}
void SetTopMost(){ this->TopMost(); }
typedef MyApp CLASSNAME;
};
GUI_APP_MAIN
{
MyApp().Run();
}
|
|
|
|
Re: always on top [message #46253 is a reply to message #46252] |
Sat, 02 April 2016 23:43 |
Lance
Messages: 633 Registered: March 2007
|
Contributor |
|
|
It surprised me that it didn't work for you. The linked post is actually irrelevant to our situation.
If you can create a minimized sample, I can try and determine what goes wrong.
Before that, try the following
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
TopWindow a;
a.Open();
a.TopMost().Run();
}
Replace TopWindow with your TopWindow direvative. This is neater way to guarantee the TopWinow(derivative)'s top->hwnd is initiallized, ie, call Open() before call TopMost().
If above won't work, then your problem is a little different, e.g., your ctrl might have a parent (which will result in GetHWND() returning NULL).
[Updated on: Sat, 02 April 2016 23:59] Report message to a moderator
|
|
|
Re: always on top [message #46258 is a reply to message #46241] |
Sun, 03 April 2016 03:53 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
attached is test 2 which was a very early example I tinkered with.
I am not used to how the FUDforum is setup, it makes my head hurt until I get used to it.
-
Attachment: Test2.zip
(Size: 1.44KB, Downloaded 230 times)
[Updated on: Sun, 03 April 2016 04:16] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Dec 06 15:45:57 CET 2024
Total time taken to generate the page: 0.01514 seconds
|
|
|