|
LPTSTR can be either Unicode or not depending on whether UNICODE is defined. Using std::wstring is ok if you are sure LPTSTR is always unicode. But in this case it would be more correct to have LPWSTR. What to do in current case, is to use std::basic_string<TCHAR>:
typedef std::basic_string<TCHAR> tstring;
Now, conversions between LPTSTR and tstring will work regardless of being unicode or not.
--
=====
Arman
|
|
|
|
|
Thanks for the info
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi Arman and Mark,
Thanks a lot. Its working fine with wstring for me.There are no compilation errors now.
But I am having one more problem.
I am using text resource file in my VC++ workspace.
I have included *.rc and *.h file. but I am not able to get the handle to resource file. Following is the sample code.
TCHAR sResName[5] = _T("#103");
TCHAR sRestype[12] = _T("MY_RESOURCE");
HRSRC hres = FindResource(NULL, sResName, sRestype);
HGLOBAL hbytes = LoadResource(NULL, hres);
LPVOID pdata = LockResource(hbytes);
LPBYTE sData = (LPBYTE)pdata;
LPTSTR sXml = (LPTSTR)sData;
wstring strXml(sXml);
In the above code i am not getting hres pointer.
The address of hres is null. Do u have any idea why I am not getting the pointer to resource file using FindResource(). I have included the resource file in the header files folder.
Is there any better way of doing the same?
Thanks in advance
JK
|
|
|
|
|
2 reasons I see for FindResource to fail -
1) A resource of type "MY_RESOURCE" with an integer ID of 103 isn't in the exe's resources.
2) The resource isn't compiled/linked into the exe file (since you've used NULL for hModule param)
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi Mark,
Thanks for the reply.
I have checked the ID number its correct.
And I have included resource file in the workspace and I have included resource header in my *.cpp.
I could complie successfully. When I debug and see the return type of findresource() it is NULL.
Do u any idea how to fix this.
Thanks in advance.
JK
|
|
|
|
|
It looks like it should work.
Without seeing the resource script I can't imagine.
You could try AfxGetInstanceHandle() instead of NULL for the module handle.
Also make sure the type is a string and not a macro for an integer.
That's all I can think of off hand...
Mark
This episode brought to you by the number 5
|
|
|
|
|
i am very bad in strings and LPTSTR all that crap
so i switched to using the class CString
simply type
CString MyString;
if you want to put something into your Cstring, type
MyString = "this is my string"<br />
if you want to pass your CString into a LPTSTR field, use MyString.GetBuffer()
switch to CString today!
|
|
|
|
|
I want to develop a program with features below :
1. The usb mass storage device should not be recognised by the windows operating system as a removable storage device at all. i.e. in the standard windows explorer the new removable drive should not be visible
2. But my program must recognise it , and must do all user applications like file operations on it
How can this be done , must i write a strong USB Bus filter driver ?
Thank you very much...
|
|
|
|
|
You're describing features of the hardware, it needs somehow to show a non standard interface to Windows, so Windows cannot tell what it is, but your software will know how to interact with it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I need help encrypting a string with Crypto++, RSA encryption. I downloaded it and integrated in my solution.
I have the keys in hex strings. All the samples I found read the keys from files or sign messages (I want to encrypt the string, not sign it).
Thanks
|
|
|
|
|
ErnestoNet wrote: All the samples I found read the keys from files or sign messages (I want to encrypt the string, not sign it).
They hide that information in the documentation[^]
|
|
|
|
|
|
Hi
In which scenarios would COM connection points be preferred to Windows Messaging (like regsisterwindowsmessage,postmessage) ?
Thanks
Rose81
|
|
|
|
|
Rose81 wrote: In which scenarios
Perhaps if you provide the list of "scenarios" we can filter it for you.
|
|
|
|
|
Rose81 wrote: In which scenarios would COM connection points be preferred to Windows Messaging (like regsisterwindowsmessage,postmessage) ?
In general:
Whenever you want a COM server to notify its client you should use connection points or preferably your own source interface.
More detailed explanation:
When you design COM servers you should always design with distribution in mind, i.e. your server may be used remotely from a different machine using DCOM. In this case you cannot send/post windows messages to the client.
Furthermore your server may be created in a UI-thread that may not necessarily have a window.
Tip of the day:
Regarding the concept of connection points even the COM authority Don Box recommends not to use connection points in his book "Effective COM"[^], but rather your own source interface.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I'm having the problem in an application I made in VC6 and Windows2003.
In Windows2003 works fine, but when I put the app in the WindowsXP where it has to be, it doesn't work.
I installed all the VStudio6 with the SP6 as I have it in Window2003, and still not working.
Something I noticed in the XP machine;
When I make a new project in VC6 and select a Windows Application -> Hello World Example, works ok.
BUT, I open the Example About Dialog it generates, and add a ProgressBar or a ListControl; when I run it, it runs, but the About Dialog si not load.
In my original App, I'm using a ListControl and a ProgressBar, so thats the problem......
Is there anybody that can help me ?
Guillermo.
-- modified at 14:47 Tuesday 26th June, 2007
I just tried in another XP and another Windows2003
and the same.
In XP doesn't work and in W2003 yes. :'( ¡Strange!
|
|
|
|
|
Are you calling InitCommonControls() (or InitCommonControlsEx()) somewhere BEFORE using any
controls?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I didn't explicitly add the InitCommonControls, it's necesary? cause in W2003 works. shouldn't be needed in W2003 also??
Where should I add it in the code ?
I read in MSDN something about it; it said the that problem with initcommoncontrols was in VC5 and that in VC6 was solved, so, if I need to add it; where should I put it?
in WinMain? or just before the DialogBox Call ?
Thnx!
|
|
|
|
|
2003 may have a DLL that pulls in the common control DLL automatically.
It doesn't hurt to call InitCommonControls() though
WinMain is fine. Give it a try!
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Great!!!
The InitCommonControls() did the job!!!
Another thing that makes me think is why in w2003 works, if the
#include "commctrl.h" nor the link to comctl32.lib where added previously.
But well...
Adding the link to comctl32.lib and the include commctrl.h and the InitCommonControls Call, works!!!!
Thanx a lot.
Guillermo.
|
|
|
|
|
anselmo wrote: Another thing that makes me think is why in w2003 works, if the
#include "commctrl.h" nor the link to comctl32.lib where added previously.
Those need to be there for your project to compile and link.
At runtime, however, ComCtl32.dll needs to be loaded. That's all InitCommonControls does - makes
a call into the DLL which forces it to be loaded if it isn't already. That's why I think if
it worked on 2003, that a system DLL causes the ComCtl32.dll to be loaded so it's already there
when you create your controls.
Glad it worked!
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi,
I have placed a static Text Common control, can i set the alignment of text present in that text box, I have found right align text option but couldn't find center alignment option, does any one know about it.
Warm Regards,
Mushq
|
|
|
|
|
If you placed it on a dialog in the resource editor, then select the control, press F4 to get the
properties window for the control. Find the Align Text property - you should be able to set it
to left, center, or right.
For a programmatically-placed control, add the SS_LEFT, SS_CENTER, or SS_RIGHT style when creating
the control.
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Mark Thanx a lot
|
|
|
|
|
Dude you broke the forum again
|
|
|
|