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 » Image Ctrl How To Add It??? (How to add an Image To My Project In Layer Design? Is It Possible?)
Re: Image Ctrl How To Add It??? [message #52029 is a reply to message #52026] Mon, 08 July 2019 08:58 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Hi Lestroso

Here I enclose you a folder with the "Hello World" application changed to load an user selected image. All necessary files are included. The image can be loaded from a file, or embedded inside the executable. Please tell me if you need the last case.
This is the .cpp file:
#include <CtrlLib/CtrlLib.h>
#include <Controls4U/Controls4U.h>

using namespace Upp;

#define LAYOUTFILE <HelloWorldImage/hello.lay>
#include <CtrlCore/lay.h>

class HelloWorld : public WithMainHello<TopWindow> {
	MenuBar menu;
	StatusBar status;

	void FileMenu(Bar& bar);
	void MainMenu(Bar& bar);

public:
	typedef HelloWorld CLASSNAME;

	HelloWorld();
};

void HelloWorld::FileMenu(Bar& bar) {
	bar.Add("Open image", [&] {
		FileSel fs;
		
		String file = SelectFileOpen("Image files\t*.bmp *.png *.jpg *.gif\nAll files\t*.*");
		if (!file.IsEmpty())
			image.Set(file);
	});
	bar.Add("About..", [&] {
		PromptOK("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Hello world sample}}");
	});
		
	bar.Separator();
	bar.Add("Exit", THISBACK(Close));
}

void HelloWorld::MainMenu(Bar& bar) {
	menu.Add("File", THISBACK(FileMenu));
}

HelloWorld::HelloWorld() {
	CtrlLayout(*this, "Hello World");
	Sizeable().Zoomable();
	
	AddFrame(menu);
	AddFrame(status);
	menu.Set(THISBACK(MainMenu));
	status = "Welcome to Hello World !";
}

GUI_APP_MAIN {
	SetLanguage(LNG_ENGLISH);
	HelloWorld().Run();
}


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [SOLVED] Invalid memory access on ImageDraw::Init (X11)
Next Topic: How i can play a sound?? wav,mp3,ogg,aiff????
Goto Forum:
  


Current Time: Wed Apr 24 20:20:49 CEST 2024

Total time taken to generate the page: 0.02116 seconds