|
Hi All
Which would be the best way to pass a CString to a TCHAR myVar[]
for example
what i want to do is something like
CString myStr = "hello";
TCHAR myVar[] = myStr;
thanks
si
|
|
|
|
|
si_69 wrote: Which would be the best way to pass a CString to a TCHAR myVar[]
Variables do not get passed to each other.
You can, in some cases, convert from one type to another.
CString myStr = _T("hello");
TCHAR *myVar = (LPTSTR) (LPCTSTR) myStr;
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
you meant using _tcscpy() , strcpy() or strncpy() , not using operator=() , didn't you ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
non, the original poster just wanted to cast a CString to something alse, not make a copy ...
or at least that's what it looked to me.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
toxcct wrote: you meant using _tcscpy(), strcpy() or strncpy(), not using operator=(), didn't you ?
No, not at all.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
|
si_69 wrote: Which would be the best way to pass a CString to a TCHAR myVar[]
try lstrcpy function
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm trying to read a Dump file from a client, and I'm not sure how to do this with WinDbg.
1. If I'm not certain about the client's OS, can I download multiple Windows OS symbols to the same path, or do I need to download the symbols to seperate path for each OS version?
2. If I have the symbols for an OS with service packs installed, can I still use these symbols with a dump file from an OS that doesn't have any service packs installed?
3. Is there any clean way to examine the dump file to determine which OS it's for, and what version or service pack it has with it?
4. If I wanted to use VC++ 7.1 to examine the dump file, exactly how would I do that?
I'm currently waiting for the client to send some msinfo32 output that I believe will tell me about the OS and service pack, but I was wondering if there are other options for getting this information via the dump file.
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
How do I change the color of the edit portion of a CDateTimeCtrl
|
|
|
|
|
Have you looked into the WM_CTLCOLOR message, or the OnCtlColor() handler?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Yes I have tried both, but they dont appear to work with CDateTimeCtrl's
Thank You
|
|
|
|
|
What about overriding PreSubclassWindow() in your derived class and changing the color there?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
hi,
I have created a dialog using Cproperty sheet but facing difficulty while setting the focus on Help button from Cancel button and vise-versa using arrow keys, though using tab it works properly. Also, its not using Active Control X.
|
|
|
|
|
You need to look into the WS_GROUP style.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi there!
I'm quite new with C++, using other languages but now i needed to write an Printer USB routine in C++, and i need some help!
It's like this
BytesToWrite = sprintf( (char *) szBuffer, "\033F\r\033B 512 600 4 1 2 3 150 1 999999999\r\033I\r");
WriteFile( hDevice, szBuffer, BytesToWrite, &cbWritten, Null);
etc, etc, etc
I need to replace the 999999999 with the first command line argument (paramstr(1) Can someone help me with this!?
What this function does, is to send ESC commando codes to an Zebra Eltron printer.. Print barcode.. 999999999 is the barcode, but i need be able to call this little application from another application then with the barcode as command line argument.!
Best regards
Andreas
|
|
|
|
|
andreas_sweden wrote: I need to replace the 999999999 with the first command line argument (paramstr(1) Can someone help me with this!?
Does your program have a main() function?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi, yes!
Srry, didn't mention.. but here it comes!
int main(int argc, char* argv[])
{
TCHAR DeviceName[1024];
HANDLE hDevice = NULL;
DWORD cbWritten;
DWORD cbRead;
BYTE szBuffer[1024];
DWORD BytesToWrite;
StringType SlumpNum;
// This function enumerates the printer class devices and detects the appropriate
// device
CCmdLine cmdLine;
EnumeratePrinter(( LPGUID) &GUID_CLASS_ZEBRA_USB,
DeviceName,
PRINTERNAME);
hDevice = CreateFile(DeviceName,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
// Read Ribbon
BytesToWrite = sprintf( (char *)szBuffer,
"\033!RIBBON\r");
WriteFile( hDevice,
szBuffer,
BytesToWrite,
&cbWritten,
NULL);
// To read you need to send "\033E 2\r"
BytesToWrite = sprintf( (char *)szBuffer,
"\033E 2\r");
WriteFile( hDevice,
szBuffer,
BytesToWrite,
&cbWritten,
NULL);
ReadFile( hDevice,
szBuffer,
1024,
&cbRead,
NULL );
// End of ribbon read
// Start Encode Data
// Fill in the data in firmware buffer
// First track ZEBRA1 command: \033&B 1 ZEBRA1\r
// Second track Age command: \033&B 2 28\r
// Third track YOB command: \033&B 3 1975\r
// Encode all three track
// command: \033E*\r
BytesToWrite = sprintf( (char *)szBuffer,
"\033F\r\033B 512 600 4 1 2 3 150 1 999999999999\r\033I\r");
WriteFile( hDevice,
szBuffer,
BytesToWrite,
&cbWritten,
NULL);
And you can see the 999999999999 that i would like to insert the first command line parameter instead...
Regards
Andreas
|
|
|
|
|
andreas_sweden wrote: int main(int argc, char* argv[])
Command-line arguments are supplied in the argv (argument vector) variable.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi again, thankyour for answering so quickly.
May i ask you to be a little more specefic.. since i no 1% of c++ . well, not really but almost..
I havn't the got the clue how i must do to get that inserted at that position where i needed it..
If you had time to help my it would be very kind!
Thnakyou !
/Andreas
|
|
|
|
|
andreas_sweden wrote: since i no 1% of c++
Actually it has nothing to do with C++. See here and here for more.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Okey, so one step further .. guess i used the argv correct
same as ParamStr in Delphi and so on.
Ok, now i'm having trouble to inserting that string into the function.
Like this, wich doesn't work:
Argument = argv[1];
BytesToWrite = sprintf( (char *)szBuffer,
"\033F\r\033B 512 600 4 1 2 3 150 1 "&Argument&"\r\033I\r");
Thankyou!
/Andreas
|
|
|
|
|
andreas_sweden wrote: BytesToWrite = sprintf( (char *)szBuffer,
"\033F\r\033B 512 600 4 1 2 3 150 1 "&Argument&"\r\033I\r");
Try:
sprintf(szBuffer, "\033F\r\033B 512 600 4 1 2 3 150 1 %s\r\033I\r", argv[1]);
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thankyou thankyou * 10000
Very much!
Everything works just fine!!!
Mucho Gracias!
/Andreas
|
|
|
|
|
I've tried to overload the << oprator, so that I can output to a file and to a console at the same time but I have no success. I cannot find a solution in Internet and I get the error message: ambigous overload of operator <<...
Any ideas what to do?
I want to be able to use this operator to output something like:
logfile << "data";
but still to be able to do this:
cout << "out";
Thank you!
|
|
|
|