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 » Using a label as a link to a folder
Using a label as a link to a folder [message #46918] Wed, 14 September 2016 15:28 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I developed an application that shows some information (taken from a DB) related to purchase orders. Information is contained in a form. The form contains also a path/link (shown as a label) to a shared directory containing relevant documentation (pdf files, excel files, emails etc.) related to the order. I have been asked to make the path "clickable" i.e. the user should click on it and the folder should be opened in Windows Explorer. If that is not feasible, I can even use a button to show the path instead of a label: the important thing to me is to understand how to launch Windows explorer. Thanks in advance for any suggestion.
Regards,
Gio
Re: Using a label as a link to a folder [message #46919 is a reply to message #46918] Wed, 14 September 2016 19:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hi,

to open path as directory, I am using this snippet:

void ShellOpenFolder(const String& dir)
{
	#if defined(PLATFORM_WIN32)
		LaunchWebBrowser(dir);
	#elif __APPLE__
		String tempDir = dir;
		tempDir.Replace(" ", "\\ ");

		IGNORE_RESULT(
			system("open " + tempDir + " &")
		);
	#else
		String tempDir = dir;
		tempDir.Replace(" ", "\\ ");
		
		IGNORE_RESULT(
			system("xdg-open " + tempDir + " &")
		);
	#endif
}


To have clickable label, use RichText instead of Label and QTF.

Mirek
Re: Using a label as a link to a folder [message #46923 is a reply to message #46918] Fri, 16 September 2016 08:26 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Giorgio

In Bazaar/Controls4U there is HyperlinkLabel that does the job.

It is so simple that you can even copy it.

class HyperlinkLabel : public Label {
public:
	HyperlinkLabel() {
		NoIgnoreMouse();
		SetInk(LtBlue());
	}
	HyperlinkLabel& SetHyperlink(const char* str) 		{hyperlink = str; return *this;}

private:
	String hyperlink;
	virtual Image CursorImage(Point p, dword keyflags) 	{return Image::Hand();}
	virtual void LeftDown(Point p, dword keyflags) 		{LaunchWebBrowser(hyperlink);}
};


Best regards
IƱaki
Re: Using a label as a link to a folder [message #46990 is a reply to message #46923] Wed, 12 October 2016 11:17 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Many thanks to both of you.
Previous Topic: Truncation
Next Topic: System Requirements, target platforms
Goto Forum:
  


Current Time: Sat Apr 20 04:55:39 CEST 2024

Total time taken to generate the page: 0.05487 seconds