|
big_denny_200 wrote: anybody know how to convert const char * to LPCTSTR and vice versa
I thought LPCTSTR is for (Long Pointer To Constant String) which is same as const char *
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
i think what you wrote is LPCSTR not LPCTSTR
I have passed const char* object to a method which required LPCTSTR and got an error.
don't know exactly I am pretty new to C++
|
|
|
|
|
because you might have UNICODE set on your project. haven't you ?
|
|
|
|
|
yes, but i need to do the convertion anyway.
because i use some function that returns const char* and then need to pass it to function which requires LPCTSTR .
can you help ?
|
|
|
|
|
you didn't answer to my question.
do you have unicode enabled in your project or not ?
see W2A() and A2W() macros for such conversion anyway...
|
|
|
|
|
actually, T is for TCHAR, so it is a typedef to const TCHAR*
|
|
|
|
|
The "T" doesn't mean Unicode. A TCHAR can be either char or wchar_t depending on if your building a Unicode build or not. It depends on the UNICODE , _UNICODE and _MBCS preprocessor definitions.
Steve
|
|
|
|
|
it doesn't mean unicode,, but it's still there for it
|
|
|
|
|
|
OK, I have read just about every printing example I can find and I still cannot find a way to do this.
In my app, non-MFC, I have a listview containing quite a bit of data. I need to be able to print this data as a table. Printing lines of text and bitmaps is no problem, but when it comes to trying to structure this data it's getting a little confusing.
The table itself will never change, only the text and cell data. So It's no problem to create a template stored in the resources to which I can simply add cell values. But what sort of file should I create that can easily be populated and printed?
Please somebody kick me towards the right link.
|
|
|
|
|
Check out the Printing section on the left menu.
http://www.codeproject.com/printing/printlib.asp[^]
This article has a sample of defining printing tables.
He was a snowflake, like other "unique" snowflakes, falling down, getting stepped on, and pushed aside to disappear.
|
|
|
|
|
Hi all,
I have already a standad Visual C++ . NET, version from year 2003.
And, with this Visual C++ . NET [ version 2003], is it necessary to download VC++ Express Edition 2005?
Also, is it fully compatible with SDK plateforme + DirectX 9 installad from February 2006?
And, with this Visual C++ . NET [ version 2003], y is it necessary to download VC++ Express Edition 2005?
Thanks a lot
Regards!
|
|
|
|
|
Visual C++ .NET 2003 and Visual C++ 2005 are two (almost) completely different languages. the 2005 version cleans the syntax up A LOT and is called C++/CLI. The express edition should be compatible with any recent SDK's. I recommend downloading 2005 since it's free, and it makes it a lot easier to target the .NET platform
Thanks,
John
|
|
|
|
|
thanks a lot,
So...
I was hesitating as I earlier kept the Visual C++.Net.
In fact up to this month, Visual C++ 6.0 was offering the advantage to provide a lot of tips..etc.. as well as books, references.
Instaed than VC++.Net stayed almost without publication and not so much referenced.
So,as an expert, your advice would be to jump on Visual C++ Express Edition 2005 [ even if beta version] and programming with C++ is fine. However, programming Windows changes a lot, requires SDK and Direct X 9 are a plus .
And this is the end of VC++ 6 ( a pity honestly if we consider the difficulties to convert from VC++ 6)
thanks a lot
Regards
TPP
|
|
|
|
|
Why can I cast a pointer to a static non-class function to DWORD (for example), but not a pointer to a non-static class function? (The compiler generates an error if you try)
ie:
DWORD dw1 = (DWORD)fnStaticGlobalFunc; // OK
DWORD dw2 = (DWORD)pMyClass->fnClassLocalFunc; // Error
|
|
|
|
|
Martijn van Kleef wrote: The compiler generates an error if you try
and what does it say ?
|
|
|
|
|
Sorry, didn't include it because this:
c:\Documents and Settings\Martijnv\My Documents\Visual Studio Projects\TestWin32Console\TestWin32Console\TestWin32Console.cpp(193) : error C2440: 'type cast' : cannot convert from 'void (__thiscall X::* )(void)' to 'DWORD'
There is no context in which this conversion is possible
...still doesn't tell me why I CAN cast the static global function to DWORD but CANNOT cast the non-static class member function.
|
|
|
|
|
Notice the __thiscall X:: part of the type - that means the function is a member of class X and takes a X* parameter (which becomes this in the method). You can't cast that away.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
For non class functions, the compiler knows exactly where the function resides.
For class members it doesn't.
class base {
public: virtual void fn() {}
};
class derrived {
public: virtual void fn() {}
};
base *p = new derrived;
DWORD dw = (DWORD)p->fn; // which fn??
|
|
|
|
|
that's false. a member function is not duplicate for each instances of the class. the member functions bodies are loaded once in memory. only the implicit this parameter differs depending who call it.
|
|
|
|
|
C++ refuses to 'throw away' the class association of the non-static class method, which is what is happening in the example you give with the class method. The compiler basically says, "If I lose the class association for this method, I won't be able to tie this method back to an instance of the class."
It's not an issue with the a global (i.e. non-class ) function because there is no class association. It's also not a problem with a static class method. Static class methods aren't much more than global functions that are 'hidden' inside a class namespace. They don't have an instance of the class associated with them when they are invoked.
If you really, really, really need to get the value as a DWORD, you can use a union to get there.
<br />
class CSomeClass<br />
{<br />
public:<br />
void SomeMethod();<br />
};<br />
<br />
union<br />
{<br />
DWORD dwValue;<br />
void (CSomeClass::*pMethod)();<br />
} Address;<br />
<br />
<br />
Address.pMethod = pSomeClass->SomeMethod;<br />
<br />
<br />
Note that this technique is not implementation independent! Run on a machine that uses pointers that are not 32-bits and you have a problem.
Regards,
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
Actually that won't work..
If I use the union solution posted previously my compiler (Visual Studio .NET 2003) complains:
error C2475: 'CSomeClass::SomeMethod' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
An implementation according to the suggestion of the compiler seems to work though:
Address.pMethod = &CSomeClass::SomeMethod;
But now, where on earth did all the fuss about the this pointer go?? Did I just seem to have discarded it??
|
|
|
|
|
Well, look at that - another syntax / semantics change from VC++ 6 to 2003/2005. Grumble, grumble, grumble... But yes, I just tried the variation you describe under 2005 and it does the trick.
Anyway, it's not that you are discarding a specific 'this' pointer. The issue is that you are not discarding the class association.
If you try to cast &CSomeClass::SomeMethod to something else such as:
DWORD dw = (DWORD) &CSomeClass::SomeMethod;
the compiler will still complain because this conversion would force it to discard the class association. (Actual error message under 2005 says,"There is no context in which this conversion is possible")
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
Hello friends, has anybody knowledge about creating virtual serial ports, because I must write a program which can create virtual serial ports and be able to monitor the communication on these virtual serial ports.
Thank you for your help in advance!
szilard
-- modified at 8:40 Thursday 16th March, 2006
|
|
|
|
|