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 » U++ Library support » TabCtrl » Background color of layout (How to change the background color of a layout )
Background color of layout [message #48206] Mon, 05 June 2017 11:07 Go to next message
Upp_User is currently offline  Upp_User
Messages: 8
Registered: May 2017
Location: India
Promising Member
Hi,
I have been using U++ (thanks for this great tool!!) some time back and resumed its usage after a break.
I am trying to use Tab control and wanted to change the background color of the layouts. I went through the forum and understood there is no direct way to do it, but, can be done through Frames.

I tried to implement the task (attached the case) but it is not working, neither giving any error message.

Can someone please look into it and suggest the fix?

Thanks a Lot for your help in advance.



  • Attachment: layouts.zip
    (Size: 1.21KB, Downloaded 70 times)


UPP User
Re: Background color of layout [message #48207 is a reply to message #48206] Mon, 05 June 2017 16:49 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 526
Registered: August 2007
Location: Turkey
Contributor
Hello,

You can override the Paint() function.

Layout.h:

class layouts : public WithlayoutsLayout<TopWindow> {
public:
	typedef layouts CLASSNAME;

	struct Tab1 : WithinputTab<ParentCtrl> {
		Color cc;
		virtual void Paint(Draw& w) override
		{
                        auto r = GetRect();
			w.DrawRect(r, cc);
                }
		void ChangeColor(Color c) { cc = c; Refresh(); }
		
	};
	Tab1 tab1;
	WithoutputTab<ParentCtrl> tab2;
	layouts();
	
	void setTitle();
	void setFrame();
};


Layout.cpp:

void layouts::setTitle()
{
	tab1.but1.SetLabel("Pushed me");
	tab1.ChangeColor(SMagenta());

}


Hope this helps.
Note that you can also add a background image this way (by painting it to the background). It's up to you. Smile

Regards,

Oblivion.

[Updated on: Mon, 05 June 2017 16:53]

Report message to a moderator

Re: Background color of layout [message #48212 is a reply to message #48207] Tue, 06 June 2017 06:47 Go to previous messageGo to next message
Upp_User is currently offline  Upp_User
Messages: 8
Registered: May 2017
Location: India
Promising Member
Thanks a lot Oblivion, for your Quick reply.

I tried your code and i still don't see the color of the layout is changing. Attached the snapshot of the output.

I am running it in Windows 10, and using "MINGWx64 Debug" for compilation and i am using,

U++ version 10804 (64 Bit Gcc C++11) {details collected from the "about" option)

Should you need more details for the fix, Please let me know.

Thanks Again
Surendran.


UPP User
Re: Background color of layout [message #48213 is a reply to message #48212] Tue, 06 June 2017 08:17 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 526
Registered: August 2007
Location: Turkey
Contributor
Hello Upp_user,

Hmm, it should "just work."
I've tested it on Win7-10 (MinGWx64) and Arch Linux (GCC) with latest upp nightly build.

Yet, given the screenshot you provided, you didn't seem to click the button yet (its label is still "push me" where it should read "pushed me").

So, I know it's a silly question, but to be sure, did you click the button?
Color should change when you click the button.

Of course, you don't have to call Tab1.ChangeColor() in that callback. You can call it from wherever you want.
I put it there for demonstration purpose.



Regards,

Oblivion

[Updated on: Tue, 06 June 2017 08:18]

Report message to a moderator

Re: Background color of layout [message #48218 is a reply to message #48213] Tue, 06 June 2017 10:35 Go to previous message
Upp_User is currently offline  Upp_User
Messages: 8
Registered: May 2017
Location: India
Promising Member
Hello Oblivion,
It is my bad, yes after pushing the button it worked (your question was not silly but really an important one).

i actually wanted to add the function tab1.ChangeColor(SMagenta()) in SetFrame which will be automatically invoked upon execution, but i realized it was added in SetTitle which obviously needs a button push.

Apologies for inconvenience and try to avoid these silly questions.


Thanks a lot once again
Surendran



UPP User
Previous Topic: How to plot image in one tab based on TabCtrl
Goto Forum:
  


Current Time: Wed Dec 19 16:47:11 CET 2018

Total time taken to generate the page: 0.00821 seconds