|
there is an api for the same
MultiByteToWideChar()....
nave
|
|
|
|
|
Not Knuth wrote: How do I handle the ASCII end of string in TCHAR? For example, in one section I need to loop through the characters in the TCHAR string. I want to stop if I hit a new line from the char* string. That's easy in an ASCII string, but in UNICODE... well it's probably just as easy if you know what to look for! Should I be looking for TWO TCHAR characters (0xA and 0x0)? or something else?
wcstombs
"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
Support CRY- Child Relief and You
|
|
|
|
|
Place the macro USES_CONVERSION at the beginning of your function. You then have access to all of the string conversion macros. You can convert between any of ACSII (A), OLE (OLE), WIDE (W)and TCHAR (T). To convert ASCII to TCHAR do the following.
LPSTR *lpSrc;
LPTSTR *lpDest = A2T(lpSrc);
Similarly T2A, A2W, W2A, A2OLE, etc can be used. You can also put a C after the 2 to get a const string returned.
The good thing about these macros is that if you build the application with _MBCS defined, TCHAR is the same as ASCII so the A2T macros becomes nothing. If you build with _UNICODE defined then it will allocate a buffer and covert to Unicode for you. The memory is allocated on the stack with _alloca, so you can't keep the converted string after the function returns without taking a proper copy of it first. Also don't use inside a loop because it could allocate a lot of memory if the loop iteration is large.
|
|
|
|
|
John Saunders wrote: Place the macro USES_CONVERSION at the beginning of your function
John Saunders wrote: Also don't use inside a loop because it could allocate a lot of memory if the loop iteration is large.
If you use the newer ATL7 conversion macros then you do not have to use USES_CONVERSION and you can safely use the conversion macros inside a loop.
http://msdn2.microsoft.com/en-us/library/87zae4a3.aspx[^]
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Thanks, this works fine. But I am wondering how the macros work. I followed the code and see that it ultimately ends up at defs for MultiByteToWideChar and others. But of course the code is not shown. So I wonder if this is implemented as just a big lookup table or if there is some better way to approach this.
Obviously this question has become somewhat academic at this point. My initial problem is resolved. But I am just thinking about how I would have implemented this and I don't see a better way than using a big lookup. That seems too clumsy.
|
|
|
|
|
An alternative to using the ATL macros is to use the _bstr_t class. It has constructors that take both ASCII and WIDE character sets, and have overloaded operators for both char* and wchar_t* . It will end up calling the same functions in the end (the MultiByteToWide, etc.) but it easier to read and debug since it isn't a macro.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
Im writing a webserver which loads an exe file as cgi application. What im trying to do is not make the window popup each time someone visits the site.
I still need the process visible in taskmanager though...
Heres what im using at this point to load the cgi app and get the std out... which is what i need to do...
char psBuffer[1024];
FILE *pPipe;
send(AcceptSocket, header, strlen(header), 0);
pPipe = _popen("test.exe", "r");
//..other functions
_pclose( pPipe );
Any Help on this matter is appreciated.
|
|
|
|
|
I assume you've got a console window popping up. If you make the exe a normal Win32 project instead of a console one you will not get a console window popping up.
Steve
|
|
|
|
|
Thnx.. I dont think thats going to help in this situation.. because if users were to write thier own cgi.. they would have to do the same.. and such is too much to ask in my opinion... Theres got to be another way to hide the bloody window...
|
|
|
|
|
Assuming you're on XP (or better..) can't you just run your Web Server as a different user - this way the web server will have a seperate desktop, on which any cgi programs will run
|
|
|
|
|
I work with vc++ 6 (don't lough).
I have an MFC project with a resource file created by the MFC wizzard.
I can not run rc.exe on this file. It says "RC: fatal error RC1107 :
invalid usage: use rc /? for help"
I have no problems running rc.exe my own (simple) resource files.
I assume that VC runs rc.exe with some more defines/swithces.
Can anyone tell me how should I run it (and succeed) ?
Thanks
Maurice
|
|
|
|
|
hi all i want to write teh software that block certain site i.e yahoo.com how to do that any help is welcomned.Thanks
Tasleem Arif
|
|
|
|
|
Try writing BHO ( Browser Helpler Objects)
|
|
|
|
|
Hi,
I have a problem with DDK.
when I include every file of DDK (like video.h)
it gives me many errors.
Why?
please help me.
thanks.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
question now would be what are the errors you are getting?
vipin - Microsoft MVP
http://www.explorewindows.com
|
|
|
|
|
hello there,
I would like to scroll my CListBox (in other words, not a CListCtrl or CListView!) so that a certain item is the topmost visible item in the list (having it visible is not enough). Any ideas? I tried SetScrollPos, and although the range is meaningful, only the scrollbar gets "scrolled" (the bar moves), but the listbox itself doesn't move.
I'm getting quite desperate and all i can find if horizontal scrolling everywhere.
thanks
|
|
|
|
|
I think SetTopIndex or LB_SETTOPINDEX will do what you want.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
After you call SetScrollPos() to set the postion of the scroll bar you have to also send a WM_VSCROLL message to the list box to actually get the list box content to scroll.
pListBox->SetScrollPos(SB_VERT, Position);
pListBox->SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, Position), NULL);
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
wonderful, both approaches work. Thanks
|
|
|
|
|
Hello,
I have develloped a software in Visual studio 2005. It's works well but some time I get this message :
encountered a problem and needs to close. We are sorry for the inconvenience.
Error signature
App Name: spscurviewer.exe
App Ver. 1.0.0.1
Mod Name spscurviewer.exe
Mod. Vers. 1.0.0.1
Offset 0003218f
How can I check the problem !
AutreChien
|
|
|
|
|
Run it in a debugger and it should get you to the source of the problem.
Vipin - Microsoft MVP
http://www.explorewindows.com
|
|
|
|
|
|
Does anyone know where I can get the main alpha blended selection color? I know about LVS_EX_DOUBLEBUFFER for listviews, but this time I have to roll my own, and I'd rather it be consistent. I know that the border of the selection rect can be gotten from GetSysColor(COLOR_HIGHLIGHTTEXT) though. I tried using stylebuilder to see whether the color of the main selection rect came from a theme color, but couldn't find it
-- modified at 15:13 Sunday 30th July, 2006
|
|
|
|
|
Use GetSysColor(COLOR_HIGHLIGHT) to get the background color, and GetSysColor(COLOR_HIGHLIGHTTEXT) to get the foreground or text color.
Not sure what you mean by alpha blended selection color.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Ah, I was actually referring to the selection marquee when you drag select items in the listview. You can try drag selecting items in explorer in Windows XP to see what I mean. Unless you disabled it, it should draw a rather nice alpha blended selection rectangle.
Under performance options, Microsoft has it listed as "Show translucent selection rectangle".
|
|
|
|