| 
 | 
 | 
 
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » multiple classes include-problem 
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	
		
		
			| Re: multiple classes include-problem [message #14428 is a reply to message #14427] | 
			Tue, 26 February 2008 14:03    | 
		 
		
			
				
				
				
					
						  
						bytefield
						 Messages: 210 Registered: December 2007 
						
					 | 
					Experienced Member  | 
					 | 
		 
		 
	 | 
 
	
		I don't know if i do good but I was having problems with Images, so i simply use different classes for the same *.iml file(maybe it duplicate the images stored in executable, don't know). Here is an example (maybe bad one    ) 
 
#ifndef _ImageEx_ImageEx_h
#define _ImageEx_ImageEx_h
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <ImageEx/ImageEx.lay>
#include <CtrlCore/lay.h>
class ImageEx : public WithImageExLayout<TopWindow> {
public:
	ImageEx();
};
class Second: public TopWindow
{
public:
	Second();	
};
#endif
 
 
#include "ImageEx.h"
#define IMAGECLASS FirstImg
#define IMAGEFILE <ImageEx/ImageEx.iml>
#include <Draw/iml.h>
ImageEx::ImageEx()
{
	CtrlLayout(*this, "Window title");
	Icon(FirstImg::MyImage());
}
GUI_APP_MAIN
{
	ImageEx().Run();
}
 
 
#include "ImageEx.h"
#define IMAGECLASS SecondImg
#define IMAGEFILE <ImageEx/ImageEx.iml>
#include <Draw/iml.h>
Second::Second()
{
	Icon(SecondImg::MyImage());
}
 
		
		
  cdabbd745f1234c2751ee1f932d1dd75
		[Updated on: Tue, 26 February 2008 14:04] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |  
	
		
		
			| Re: multiple classes include-problem [message #14436 is a reply to message #14435] | 
			Tue, 26 February 2008 16:54    | 
		 
		
			
				
				
				
					
						  
						bytefield
						 Messages: 210 Registered: December 2007 
						
					 | 
					Experienced Member  | 
					 | 
		 
		 
	 | 
 
	
		| mrjt wrote on Tue, 26 February 2008 17:39 |   Maybe I wasn't clear enough, I believe the correct solution is: 
 
In .h file: 
#define IMAGECLASS SomeImg
#define IMAGEFILE <SomeImg/SomeImg.iml>
#include <Draw/iml_header.h>  
 
In ONE .cpp file: 
#define IMAGECLASS SomeImg
#define IMAGEFILE <SomeImg/SomeImg.iml>
#include <Draw/iml_source.h>  
 
The way the image stuff works is that the macros create a class with functions taht return the image, so naturally it is best to have the header and source for this class in .h/.cpp files.
  |  
  
 
Yeah, know that but if we have more sources and still want to use same *.iml file, what we do? I cannot put all my code in 2 files (header and source). 
 
An example: 
main.h - contain the generally includes, some global functions declarations, etc. 
MyApp.h - MyApp class which implement main windows (it use some images from *.iml file) 
MyApp.cpp - MyApp implementation and GUI_APP_MAIN 
 
MyDialog.h - a dialog (complex) or something 
MyDialog.cpp - dialog implementation 
 
ConfigDlg.h - ... 
ConfigDlg.cpp - ... 
 
So i need images in every class (in every source). Is there another solution or mine is not so dirty? Or perhaps others use just 2 files (*.h/*.cpp) to write an application? 
I don't want 10000 lines of code or more to share the same file. Should i implement the code which use images in a single source then, and other keep separated?  
		
		
  cdabbd745f1234c2751ee1f932d1dd75
		
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	
		
		
			| Re: multiple classes include-problem [message #14438 is a reply to message #14437] | 
			Tue, 26 February 2008 17:25   | 
		 
		
			
				
				
				
					
						  
						bytefield
						 Messages: 210 Registered: December 2007 
						
					 | 
					Experienced Member  | 
					 | 
		 
		 
	 | 
 
	
		Well, thanks. It solve the problem. I was trying the same thing with header and source, but because in source I wasn't define IMAGECLASS (guessing it is defined once in header) I've got errors. 
Now, looking on iml_header.h i understand why it wasn't work, IMAGECLASS get undefined at the end of file.
		
		
  cdabbd745f1234c2751ee1f932d1dd75
		
 |  
	| 
		
	 | 
 
 
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 17:04:27 CET 2025 
 Total time taken to generate the page: 0.05550 seconds 
 |   
 |  
  |