Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » always on top SOLVED (GUI)
Re: always on top [message #46244 is a reply to message #46241] Fri, 01 April 2016 21:02 Go to previous messageGo to previous message
Lance is currently offline  Lance
Messages: 527
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();
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: upp-mingw-9671 with win\upp9628 SOLVED
Next Topic: link error with MINGW - - SOLVED
Goto Forum:
  


Current Time: Wed May 08 22:44:48 CEST 2024

Total time taken to generate the page: 0.03094 seconds