|
Thanks! That will work!
I was trying to avoid any thing that required exact knowledge of the character type. So I would not have to write multiple overloaded functions to display each piece of data. But I see now that I was off in dream land some where, because what I was conceiving is not possible (in this case).
I consider the feedback mechanism necessary for debugging and a requirement, if it is going to be used for teaching. Eventually I will create a version with out the feedback mechanism, at the moment it is only turned on by a define statement.
Thanks again, for your valuable feedback.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
#ifdef UNICODE
std::wout << L"some string";
#else
std::out << "some string";
#endif
The above looks reasonable, but it assumes the character type. Since it is a template and it can take any character type, whether UNICODE is defined or not, it well not work.
sure. did you look into the source files provided when you install Visual Studio ??
there are plenty of functions in the libraries written just this way !
if you want to know such an information at compile time, #ifdef or #if defined() remain the best way...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Plenty of MS Specific files, but not one standard file. The template is designed using standard C++, only.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
Essentialy, I am dealing with a template class that takes the character type as an argument. Therefore, I need to know character type it is.
So basically you have a class that looks like this:
template <typename CharacterType >
class Foo
{
public:
void DoFoo(CharacterType Char);
};
template <typename CharacterType>
void Foo<CharacterType>::DoFoo(CharacterType Char)
{
}
If i'm correct in my assumption, read on. If not you can ignore the rest of this post.
John R. Shaw wrote:
What I need is compiler independent text feed back from the template at runtime,
What feedback do you want? Why do you want this? More important, what is it that you don't know at compile time that you need to know at runtime? If you want to know this sort of stuff (which you really don't), look here[^].
John R. Shaw wrote:
Example:
#ifdef UNICODE
std::wout << L"some string";
#else
std::out << "some string";
#endif
The above looks reasonable, but it assumes the character type. Since it is a template and it can take any character type, whether UNICODE is defined or not, it well not work.
Templates can solve this exactly. You don't want to resolve this at runtime, but at compile time. The reason for this is that you can fix your problems faster and your compiler shouts tons of errors at you when you are about to make a big mistake in your program! You don't want to go into debugging trouble for type dependant stuff.
Consider the following:
>
template <typename CharacterType >
class CharacterDependantClass
{
public:
void DoFoo(CharacterType Char);
};
template <typename CharacterType>
void CharacterDependantClass<CharacterType>::DoFoo(CharacterType Char)
{
}
#ifdef UNICODE
typedef CharacterDependantClass<wchar_t> ClassType;
#else
typedef CharacterDependantClass<char> ClassType;
#endif
If you use an wchar_t string when UNICODE is not defined, you get compiler errors, which is exactly what you want.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Keep in mind that a requirement of this project (my own), is to use standard C++ only. That is it must be totally compiler independent, it needs to be usable in any C++ environment, be it Windows, Unix, etc... .
Bob Stanneveld wrote:
What feedback do you want?
The templates use various algorithms to process text and I want it to be able to to show the steps it takes in processing, as visual feedback to user (this feature can be turned on at compile time.
Bob Stanneveld wrote:
Why do you want this?
This feature is not just for testing, but also for teaching. It is not needed for the templates to do there job, but it is if you want to see how they do it (consider it a type of compiler feedback).
Bob Stanneveld wrote:
More important, what is it that you don't know at compile time that you need to know at runtime?
What the input is, and precisely how it processed that input.
Does a compiler know precisely what the input is going to be at runtime? If it did then it would not need to give any feedback (warning,errors,etc..).
Bob Stanneveld wrote:
You don't want to resolve this at runtime, but at compile time.
Which is what I am trying to do, in a compiler independent way. The feedback is in the form of text strings that must be formated based on the character type passed to the template.
Bob Stanneveld wrote:
If you use an wchar_t string when UNICODE is not defined, you get compiler errors, which is exactly what you want
That is only true if you're trying to pass those wchar_t strings to functions that require char strings. You can process wchar_t all you want in a non-UNICODE program, but you would need to convert them to a displayable form if you wish to display them. How they are converted for actual display is up to the user and is of no concern of the template, it assumes that the input character type is the type required for feedback. I would not (normally) mix char and wchar_t strings in this way, and do not expect users of this template to do so either, but if they did, a template does and should not care.
P.S. This reply would have been shorter, but CP went down for updating while I was writing it.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
Keep in mind that a requirement of this project (my own), is to use standard C++ only. That is it must be totally compiler independent, it needs to be usable in any C++ environment, be it Windows, Unix, etc... .
That'll be hard to accomplish since not all compilers support the standard. It will be especially hard if you compile under visual studio 6.0, since the standard support is really terrible.
John R. Shaw wrote:
The templates use various algorithms to process text and I want it to be able to to show the steps it takes in processing, as visual feedback to user (this feature can be turned on at compile time.
I don't know how you implement this, but you can implement it as a policy. Read here[^] about policy based design.
This technique is supported by the standard, but I've had some troubles with partitial template specialization on VC6.0.
If you don't want this, you can always use an observer / observable[^] pattern. I think that using this pattern is the way to go, since you completely separate display of data from the core class. This also reduces the places where you use the preprocessor to disable the view of the data. Besides that, if you need to use a different UI to display the data, you don't have to change to core class, but you just write another observer.
John R. Shaw wrote:
Which is what I am trying to do, in a compiler independent way. The feedback is in the form of text strings that must be formated based on the character type passed to the template.
Overloading here is the way to go (if you use templates), since a compiler only compiles code that you use. So the overloaded functions that are not used (the wchar_t or the char overloads for example). If you use overloading without the templates, you have to rely on the optimizer and the linker to omit the dead functions.
John R. Shaw wrote:
That is only true if you're trying to pass those wchar_t strings to functions that require char strings. You can process wchar_t all you want in a non-UNICODE program, but you would need to convert them to a displayable form if you wish to display them. How they are converted for actual display is up to the user and is of no concern of the template, it assumes that the input character type is the type required for feedback. I would not (normally) mix char and wchar_t strings in this way, and do not expect users of this template to do so either, but if they did, a template does and should not care.
Overloading should be the key here. You can use protected or private overloads for displaying the data and call thos in your template. The compiler will automatically choose the right overload. You definitly don't wan't to do some heavy compiler magic here, since this is an easy way to accomplis this.
See this code example:
template <typename CharType,
class ObserverPolicy
>
class YourAlgorithmClass
{
public:
void AddObserver( Observer* pObs );
protected:
void SendMessageToObservers(char* pszMessage);
void SendMessageToObservers(wchar_t* pszMessage);
private:
std::vector<Observer*> m_Observers;
};
template <typename CharType, class ObserverPolicy>
void YourAlgorithmClass<CharType, ObserverPolicy>::SendMessageToObservers(char* pszMessage)
{
if( !ObserverPolicy::UseObservers() )
return;
}
class UseObservers
{
public:
static bool UseObservers() { return true; }
}
class DontUseObservers
{
public:
static bool UseObservers() { return false; }
}
I hope this enlightens you and helps you with your problem.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
how to get r, g or b value from class CColorDialog, that enter that value to glColor3f( x, y, z)??? (i want to change my opengl color object from mfc)
|
|
|
|
|
msnet wrote:
how to get r, g or b value from class CColorDialog
Does this help?
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
COLORREF color = dlg.GetColor();
TRACE("RGB value of the selected color - red = %u,
green = %u, blue = %u\n",
GetRValue(color), GetGValue(color), GetBValue(color));
}
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
hi all.. I am working on a program using visual c++ that has a feature to generate reports in Excel format but I still confused how to do it. Can anybody help?
thx
|
|
|
|
|
Excel has an XML schema in which it can save/read spreadsheets. You can try saving a simple document as XML from Excel itself to see the way it looks, or you can obtain full documentation here:
Office 2003: XML Reference Schemas[^]
I suggest generating first an XML with just the needed data, and then using XSL transformations to convert it to any other format (including Excel's XML schema, but you might also convert it to an HTML page). That way you can separate the logic needed to obtain the data from the presentation format, which is better both in terms of ease of development and of maintenance. The transformation may be done in memory without actually saving an intermediate file.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
but if I'm using this method...can the xls file be opened at Ms Excel XP or lower? Because as I know, only Ms Excel 2003 that support XML. Is there any object library that I can use?(I'm using visual c++ 6.0)
thx.
|
|
|
|
|
firebolt77 wrote:
but if I'm using this method...can the xls file be opened at Ms Excel XP or lower?
I have Office XP and Excel can save to XML. I don't know about previous versions, but try it yourself. Open an excel document, select File / Save As, and look at the available formats.
firebolt77 wrote:
Is there any object library that I can use?
I don't know, there might be; I didn't search.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
thx..I've download the references schema..it very helpful. Can u give me some links that provide more examples about the references schema?
thx..
|
|
|
|
|
I've read the microsoft office schema, but it is very complex and I didn't understand. I even try to make an excel using xml by following the instruction from ms office schema, but it doesn't work. Can you give me some examples or maybe other links?
thx.
|
|
|
|
|
i too worked for same thing in ur project, what i did is create
file in write mode in with "filename.xls" by following right tabs and newlines bye..........
Satishvarma.E
|
|
|
|
|
if I use this method, will the cell be resized automatically? Can I make a table(with lines) using this method?
thx..
|
|
|
|
|
Oi, I have searched long and hard for this .lib file, but to no avail. Do any of you know where I can find this on the internet or email me a copy? My email is lanoman97@yahoo.com, thanks.
I have run searches through google and msdn and read other message board topics. I have also d/l the windows media format sdk 9, only to learn that wmstub.lib is only availble in version 7, which of course I also cannot find.
I need this file for a current project I am working on involving directshow and combining the sample DVapp and Jukebox to create a progeam that can save video off a DV camera and then play it back. Well, thats the first step at least, any pointers in that area would be great too =oP
Thank you for your help,
Lan =o)
|
|
|
|
|
The DirectShow SDK has been moved out of DX into the Platform SDK. Try updating your PSDK and see if you get it that way.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
SelectObject(hdc, font);
LPGLYPHMETRICSFLOAT pLPGLYPHMETRICSFLOAT = NULL;
ZeroMemory( &pLPGLYPHMETRICSFLOAT, sizeof(LPGLYPHMETRICSFLOAT));
DWORD hr=D3DXCreateText(m_pd3dDevice, //Device
hdc, //GDI Device Context
"Hello World", //Text
0.001f, //Maximum chordal deviation from true font outlines
0.4f, //Extrusion depth (along -Z axis)
&_pLetterMesh, //Mesh
NULL, //Adjacency information
pLPGLYPHMETRICSFLOAT); //GlyphMetrics
but I never get a valid glyph(pLPGLYPHMETRICSFLOAT) structure?
what am I doing wrong?
thanks,
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I am not a DX programmer, but I think it is because you are using a pointer to a structure instead of an actual structure.
try this (bolded text that changed):
GLYPHMETRICSFLOAT MyGLYPHMETRICSFLOAT;
ZeroMemory( &MyGLYPHMETRICSFLOAT, sizeof(GLYPHMETRICSFLOAT));
DWORD hr=D3DXCreateText(m_pd3dDevice, //Device
hdc, //GDI Device Context
"Hello World", //Text
0.001f, //Maximum chordal deviation from true font outlines
0.4f, //Extrusion depth (along -Z axis)
&_pLetterMesh, //Mesh
NULL, //Adjacency information
&MyGLYPHMETRICSFLOAT); //GlyphMetrics
|
|
|
|
|
Hi again,
How to get the allocate (or used) memory for current application ?
Thanks in advance.
Ivan Cachicatari Blog[^]
www.latindevelopers.com
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi,
How to align the first column of the CListCtrl (report mode) to right.
Thanks in advance.
Ivan Cachicatari Blog[^]
www.latindevelopers.com
|
|
|
|
|
Insert a temporary column. Insert the right-aligned column. Delete the temporary column.
I've made an article that shows how to do this in detail, but have not posted it yet.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello,
I have recently created a ticker tape which is used to display strings. It is a common single line ticker. The program currently reads in a file from which it takes in the dimensions, colors, speed, and position of the ticker as well as the string that it should display and the spacing between repetitions of the string.
I would like to write a new ticker however, which also reads the information from a file (preferably an xml file) which scrolls multiple lines at the same time, and which can also scroll images of approximate dimension: 140 X 110 pixels.
For example, it could look something like:
|----140px-------|
__ _______________________________________________________________
| | line1 line1 | |
| | line2 line2 line2 | |
110px | line3 line3 | IMAGE |
| | line4 line4 line4 | |
| | line5 line5 | |
_ |_____line6 line6 line6________________|________________|________
for a file that looked something like:
<ticker>
... <- indicates ticker properties
<item>
<text>line1 line1</text>
<text>line2 line2 line2</text>
<text>line3 line3</text>
<text>line4 line4 line4</text>
<text>line5 line5</text>
<text>line6 line6 line6</text>
</item>
<item>
<image>IMAGE</image>
</item>
</ticker>
where the number of 'text' tags nested in an 'item' tag is fixed (to some number, not necessarily 6) and there is only one 'image' tag per 'item' tag.
Also, another tag which specifies the spacing (pixels or time) between items should be specified in the ticker properties.
The problem is that since I am relatively new to the VS C++ (using .NET 2003), I don't really know how I would go about doing this.
If anyone has done a similar project, or could possibly guide me or help me with the code, it would be greatly appreciated.
Thanks in advance,
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|