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 » display file data and picking a line (Function opening a text file then picking and working with line data.)
Re: display file data and picking a line [message #46488 is a reply to message #46483] Sun, 15 May 2016 15:11 Go to previous messageGo to previous message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
#include <CtrlLib/CtrlLib.h>

using namespace Upp;


class test : public TopWindow {
public:
	typedef test CLASSNAME;
	test(){
		FileStream fs("Main.cpp", BlockStream::READ);
		
		Add(lbl.SetLabel("Some Text To Begin With").TopPos(2).HSizePos());
		
		edit.Load(fs);
		edit.WhenSel = THISBACK(UpdateCoords);
		Add(edit.HSizePos().VSizePos(20));
		
		curln=-1;
	}
	
	void UpdateCoords(){
		int ln=edit.GetCursorLine();
		if(ln != curln)
		{
		
			lbl.SetLabel(edit.GetEncodedLine(ln));
			curln = ln;
		}
	}
	
	Label    lbl;
	LineEdit edit;
	int curln;
};

GUI_APP_MAIN
{
	test().Run();
}


Note WhenSel is not called when the control is initially displayed. You can add a little code to cope with the situation.
 
Read Message
Read Message
Read Message
Previous Topic: Run a slow process in another thread to not block GUI
Next Topic: gui , how to switch between the visual dlg.lay to the text view
Goto Forum:
  


Current Time: Sun Jun 29 15:17:57 CEST 2025

Total time taken to generate the page: 0.03547 seconds