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 » Static Ctrl Picture and .iml
Static Ctrl Picture and .iml [message #29739] Thu, 11 November 2010 12:41 Go to next message
Daniel_Sun is currently offline  Daniel_Sun
Messages: 5
Registered: November 2010
Location: Hamburg, GER
Promising Member
Hey,

I'm back with another request.

My aim is to have some kind of pictures or drawings to indicate the status of different bits in a PLC, like LED's. Now the problem is to get those into my TopWindow and change them during runtime (e.g. Bit is 1 -> LED becomes green, Bit is 0 -> LED becomes gray).

If someone could just help me with how to put a selfmade picture or drwaing into my Layout.

Right now I'm at the point where I created an .iml File and added two images. Then I've put a User Class of type "Picture" (labeled picLED1) into my Layout. Now I'd like to assign one of the Images to the "Picture".
Trying something like:
picLED1 = MyImages::grayLED();

would'nt work.

What do I miss?
Re: Static Ctrl Picture and .iml [message #29740 is a reply to message #29739] Thu, 11 November 2010 12:48 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
You want ImageCtrl in the .iml, then use SetImage in your code.
Re: Static Ctrl Picture and .iml [message #29741 is a reply to message #29739] Thu, 11 November 2010 13:03 Go to previous messageGo to next message
Daniel_Sun is currently offline  Daniel_Sun
Messages: 5
Registered: November 2010
Location: Hamburg, GER
Promising Member
Ahh nice, this works for me.

Thanks alot.
Smile
Re: Static Ctrl Picture and .iml [message #29742 is a reply to message #29739] Thu, 11 November 2010 13:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Hello Daniel

I think it should work. I enclose you a sample package.

And this is the .cpp file:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define  IMAGEFILE  <iml/image.iml>
#define  IMAGECLASS MyImg
#include <Draw/iml.h>

#define LAYOUTFILE <iml/img.lay>
#include <CtrlCore/lay.h>

struct App : WithMyLayout <TopWindow> {
	typedef App CLASSNAME;
	void OnLed() {
		static bool on;
		if (on) {
			on = false;
			led.SetImage(MyImg::Grey());
		} else {
			on = true;
			led.SetImage(MyImg::Red());
		}
	}
	App() {
		CtrlLayout(*this);
		but.WhenAction = THISBACK(OnLed);
		led.SetImage(MyImg::Red());
	}
};

GUI_APP_MAIN
{
	App().Run();
}

  • Attachment: iml.7z
    (Size: 1.03KB, Downloaded 201 times)


Best regards
Iñaki
Re: Static Ctrl Picture and .iml [message #29743 is a reply to message #29742] Thu, 11 November 2010 13:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
This is the screenshot:

index.php?t=getfile&id=2930&private=0
  • Attachment: demo.PNG
    (Size: 4.03KB, Downloaded 613 times)


Best regards
Iñaki
Re: Static Ctrl Picture and .iml [message #29744 is a reply to message #29739] Thu, 11 November 2010 13:35 Go to previous messageGo to next message
Daniel_Sun is currently offline  Daniel_Sun
Messages: 5
Registered: November 2010
Location: Hamburg, GER
Promising Member
This is exactly what i was looking for.

Thanks.

The key is to use the ImageCtrl class which i have'nt heard about before.

Slowly I'm being convinced that U++ is a very mighty "Tool".
Wink

[Updated on: Thu, 11 November 2010 13:37]

Report message to a moderator

Re: Static Ctrl Picture and .iml [message #29746 is a reply to message #29744] Thu, 11 November 2010 15:57 Go to previous message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
You can see another image control in Controls4U bazaar package exactly here Smile.

Best regards
Iñaki
Previous Topic: Changing compiler "on the fly"
Next Topic: Using U++ without UppIDE
Goto Forum:
  


Current Time: Fri Apr 26 02:34:11 CEST 2024

Total time taken to generate the page: 0.12954 seconds