|
...to find out that it is useless (hint: OP asked for LPSTR ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
You could do this (if you're feeling adventurous):
CString sMyString("1234567890");
ThisFunctionNeedsLPSTR((LPSTR)(LPCTSTR)sMyString);
The best advise (as already stated by others) is to use GetBuffer() /ReleaseBuffer() .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That would not be a good idea.
Steve
|
|
|
|
|
It has its right E.G. in CListView or CTreeView, where structs are used for reading and writing, and hence have the strings defined as LPTSTR.
When I am writing into the control, it will not ever alter the string I gave it. So I sometimes just shut up the compiler by using the big club of a double cast.
Failure is not an option - it's built right in.
|
|
|
|
|
Personally, I always use the GetBuffer() , ReleaseBuffer() combo.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
And up to now... I will make the same :P
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi
I am trying to disable a menu item, but it is only disabling it for me and not graying it out.
For instance I have a menu as following:
File
->Open
->Save
So the "Open" and "Save" are grayed out and disabled, but "File" is not.
How can I make "File" menu item be grayed out on top of being disabled?
By the way - I am using the ON_UPDATE_COMMAND_UI_RANGE command.
Thanks
|
|
|
|
|
Currently inputting characters into a string varible in the CString class
How can i cut a set of characters from the string into another varible?
for example: - in the string is "Project"
how can i extract just the "Pro" part out of it into a varible?
Thanks for your help
|
|
|
|
|
You can use the String splitting functions of CString Left, Right, Mid. For searching after certain characters you can use the Find methods.
But you have to keep in mind that those are index based functions, so you have to either rely on fixed index positions or your string has to contain nearly the same content.
|
|
|
|
|
AlexDrummer wrote: for example: - in the string is "Project"
how can i extract just the "Pro" part out of it into a varible?
CString s = CString("Project").Left(3);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello coders,
I need an help regarding adding a button to datagridview control in my windows application.
Also i am using dataset to fill the datagridview.
Please find me the way of doing the thing.
Thanks
sulabh
|
|
|
|
|
how to get the guid of the usb flash drive inserted through mfc?
|
|
|
|
|
As far as I know there is no special MFC API for something like this.
You will probably need to call the relevant Win32API.
I have no idea which this may be, though, as I did not understand your request.
Please rephrase what you want to do.
Failure is not an option - it's built right in.
|
|
|
|
|
when we insert a usb flash drive an id (which is of 128 bit) will be generated automatically. i need an api to get this id for the inserted flash drive
|
|
|
|
|
Call ::RegisterDeviceNotification() from your application to receive WM_DEVICECHANGE messages, more info here[^].
Set it up properly so you can get a DEV_BROADCAST_DEVICEINTERFACE structure appointed by the lParam parameter in the message which contains the GUID, more info here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
This may not be too helpful but...
I had to do a similar job a couple of months ago, detect USB drive insertion accross as wide a range on Windows OS versions as possible and determine the drive letter mapping. It turned out to be a 2 week job and required downloading the Windows 2000 DDK to get the right headers to make it work. I can't send you the code as it was for my work but you might want to clear some space in your schedule for this one. You'll need the Device Notification stuff already mentioned above, that is the way to go. It probably won't work at first and the docs are bad but stick at it, It can be done
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
paras_s12 wrote: now i want that when i click on browse button c drive open
and when i choose a file for uploading
For this check the CFileDialog class.
|
|
|
|
|
Thanks sir
can i get this answer in detail please
hi
|
|
|
|
|
paras_s12 wrote: answer in detail please
You can use the CFileDialog class to show a file opendialog( Like one you see in when you click on the open menu of IE )
CFileDialog dlg( TRUE );
if( IDOK == dlg.DoModal())// shows a file open dialog
{
return false;// some error
}
// now you can get the file name
CString csFile = dlg.GetPathName();
// Set this string to the edit box
SetDlgItemText( IDC_EDIT/*spefiy the id of edit here*/, csFile );
|
|
|
|
|
|
paras_s12 wrote: can i get this answer in detail please
You were provided with a working example. What more do you want?
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi everybody.
I have created a Setup for my app. I have developed in Visual C++, MFC.
The app need some log files, config files, and some icon.
I added all of the in the correct path to the setup.
I run the app and it said that the file "ntwdblib.dll" was missing. So I added.
I run the app and it said that the file "MFC42D.dll" was missing. So I added.
I run the app and it said that the file "MSVCRTD.dll" was missing. So I added.
I run the app and it said that the file "MFCO42D.dll" was missing. So I added.
After that, my app does not make any error, does not appear, does nothing. I know the app starts but it just finishes after starting, I checked with the task administrator. What could it be?
Can someone help me?
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
garfield185 wrote: I run the app and it said that the file "MFCO42D.dll" was missing. So I added.
1. When an application is delivered for thrid party usage, it must be build in the release verion. I doubt your application is now build using the debug configuration( thats why a dependency to MFC42D.dll, MSVCRTD.dll etc came )
2. Use the Dependeny walker to find out the necessry dll need by your application and add it to your installtion setup( Ignore the dll's coming with the OS ).
|
|
|
|
|
I built as Release before getting the files to the setup, now there are some strange errors like
error LNK2001: unresolved external symbol ...
many times and about 2 different obj files.
What does it mean?
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|