|
Try using ShellExecute() with the name of the text file as the third parameter.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The Subjets says it all
I want the same behavior as any image or word processing application actually.
For instance:
- open a image.bmp file
- launch Save as... command.
- change the type to 'Portable Network Graphics (PNG)'
I want my File dialog change the selected name to image.png.
I've scanned MSDN with the OnChangeType() stuff but when I tried to change CommDlg_OpenSave_SetControlText(hDlg, edt1/cmb13, "file.newextension");
it has no effect...
I'm a bit puzzled. Any idea?
-MyttO
|
|
|
|
|
I have created a DLL in which I'm running a query on a MySql database, then exporting it row by row into a .dbf file. Everything works except that it is very slow when it comes to a few thousand records at a time. I'm trying to speed it up in one area by changing my algorithm for output of the dates. in a particular field of the MySQL database there is a timestamp saved which returns this:
"20040325122530"
I need it to end up like this:
"2004-03-25 12:25:30"
I'm doing that now with CString Insert() function but for a 25-field query of 10000 records it's taking about 8 minutes!! Or are CStrings generally too slow anyway and would it be faster to just use char*?
bdiamond
|
|
|
|
|
CString::Insert() will probably copy/reallocate the whole string at each insertion (5 times)
Try to build it from scratch with one allocation and direct writing. You can easyly do this with CString::Format() , but it'll be pretty much the same with char * ...
But anyway 5x25x10k = 1,25M string manipulation whouldn't take that long imo.
-MyttO
|
|
|
|
|
Are you sure that it is the transformation of the date format that is taking the time?
If it is the bottleneck then to optimise it it is necessary to know more about where the data is coming from and where it is going to. At first glance a CString doesn't seem the clearest approach.
Paul
|
|
|
|
|
CString will do only one realloc, which is time consuming, and then each insert will require a memcpy for the remainder of the string, which is fairly slow.
After playing around, out of curiosity, I came up with the following, which is about 2.2 times faster than doing a series of inserts. I also observed an additional 10 fold increase by ensuring that the CString always had at least 20 bytes allocated. (Avoiding an alloc/realloc made a huge difference.)
char dstStr[20];
const char* pSrc = orgStr;
dstStr[0] = pSrc[0];
dstStr[1] = pSrc[1];
dstStr[2] = pSrc[2];
dstStr[3] = pSrc[3];
dstStr[4] = '-';
dstStr[5] = pSrc[4];
dstStr[6] = pSrc[5];
dstStr[7] = '-';
dstStr[8] = pSrc[6];
dstStr[9] = pSrc[7];
dstStr[10] = ' ';
dstStr[11] = pSrc[8];
dstStr[12] = pSrc[9];
dstStr[13] = ':';
dstStr[14] = pSrc[10];
dstStr[15] = pSrc[11];
dstStr[16] = ':';
dstStr[17] = pSrc[12];
dstStr[18] = pSrc[13];
dstStr[19] = 0;
[EDIT: Another method, though this assumed that CString will be preallocated to 20 bytes and will remain that. Otherwise its performance degrades to near that of the insert method:
char* pBuffer = orgStr.GetBuffer(20);
pBuffer[18] = pBuffer[13];
pBuffer[17] = pBuffer[12];
pBuffer[15] = pBuffer[11];
pBuffer[14] = pBuffer[10];
pBuffer[12] = pBuffer[9];
pBuffer[11] = pBuffer[8];
pBuffer[9] = pBuffer[7];
pBuffer[8] = pBuffer[6];
pBuffer[6] = pBuffer[5];
pBuffer[5] = pBuffer[4];
pBuffer[4] = '-';
pBuffer[7] = '-';
pBuffer[10] = ' ';
pBuffer[13] = ':';
pBuffer[16] = ':';
orgStr.ReleaseBuffer(19);
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Great!! I appreciate your help very much
If it's broken, I probably did it
bdiamond
|
|
|
|
|
And what about converting the timestamp value directly in MySQL query?
See DATE_FORMAT function in MySQL documentation .
Robert-Antonio
"CRAY is the only computer, which runs an endless loop in just 4 hours"
|
|
|
|
|
I thought about that, but I wanna make sure it doesn't break later on down the line if myself or someone else tries to use it without using DateFormat();
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hi, all!
How can I display all symbols of font file (ttf), like font creating tools do this?
Thank you in advance.
|
|
|
|
|
Any ideas on how to clear a radio button which you've selected??
Kind Regards
Caoimh
|
|
|
|
|
void CWnd::CheckDlgButton( int nIDButton, UINT nCheck );
or for radio buttons in a group use
void CWnd::CheckRadioButton( int nIDFirstButton, int nIDLastButton, int nIDCheckButton );
greatest thing is to do wot others think you cant suhredayan@omniquad.com
|
|
|
|
|
Use the CButton::SetCheck() method
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
You can use CButton::SetCheck()
Ant.
|
|
|
|
|
Should have refreshed before posting, seems David was a little quicker than me on this occasion
Ant.
|
|
|
|
|
I want to be able to get the line and position of an element in a xml document, so when when there is an error (not a parse error!, but e.g. attribute verification error)I can display the user the position in the document.
|
|
|
|
|
I don't use MSXML, but in XML4C you can use the Locator object (that's passed to your error handler) to find the current line and column. I suspect there's an equivalent class in MSXML.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I could not find anything similar in the MSXML dom parser.
|
|
|
|
|
Hi,
I've noticed that if I set a system environment variable, it isn't recognized by any services (even if I restart them). The only thing that seems to work is a reboot. Does anyone know how to make the services recognize the newly added variables without the need for reboot?
Note that I've tried adding the system variable in two ways:
1. manually through control panel->system
2. programatically, by putting the variable in the registry and broadcasting the WM_SETTINGCHANGE MESSAGE using the SendMessageTimeout function.
Thanks..
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
I have to convert CString to integer under unicode debugging as below...
CString str = "123";
#ifdef _UNICODE
int i = atoi(str);
#endif
throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *'
Kindly tell me how to do this?
|
|
|
|
|
Use the W2A() macro, as in:
int i = atoi(W2A(str)); Don't forget the USES_CONVERSION statement.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Or use the new vc7 conversion macros, CW2A in this case, no
need for USES_CONVERSION then.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
Assuming that VC7 is being used.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thats why i mentioned VC7 in the post.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
use
_wtoi(...)
this accepts widechar bytes.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|