|
Well, I have a couple of solutions:
1) You could replace the spaces as you read the strings from the file
2) You could use CQStringParser, and let it parse each string as it's read into space-delimited fields, and the read the fields one at a time out of the object. Of course, you'd probably want to create an array of CQStringParser objects too.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What do I use to replace the spaces as I read the strings from the file? I am trying to use strtok at present with limited success. Thanks for your help by the way,
-Regards
Steve
|
|
|
|
|
I wouldn't use strtok (mostly because I wrote the CQStringParser class).
If you're using CStdio, you're using MFC. If you're using MFC, CQStringParser would be abetter choice because it parses the strings for you without you having to do anything but instantiate an object with a string and a delimiter character.
Check out that class and see if it doesn't work better than strtok.
Besides all that, CString has a Replace() function that can replace all instances of one character with another.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Do you just need to make a one-time change to the file? (That's what it sounds like to me.) Install Perl from ActiveState and run this from the command line:
perl -pi.bak -e 's/\s+/\n/g' yourfile.txt
That replaces any group of 1+ spaces with a newline (and saves a backup in yourfile.txt.bak just in case).
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hi,
Can anyone reccomend a good replace for the MFC CDatabase and CRecordset classes? I am trying to port an MFC based database app to plain Win32 and I haven't been able to find anything powerful enough.
Cheers
James Spibey
I love the word naked, it's brilliant isn't it, 'naked'. When I was a kid I used to write the word naked on a bit of paper hundreds of times and rub my face in it - Jeff, Coupling, BBC2
|
|
|
|
|
Have you searched this site's Database section?
I can't recommend one specifically because I've never used anything except MFC's and my own portable class library. However, I must ask: why? Why go to plain Win32?
You may consider copying MFC's classes and "adapting" them as your own, since they wrap around the Win32 API.
Regards,
Alvaro
|
|
|
|
|
You can use ADO. It is a COM object. Just create an instance and go to it.
Long ago (1995), I used a thing called DBLib. It was pretty primative. I don't know if its still avaialble.
Hope this helps,
Bill
|
|
|
|
|
I have added speech to one of my applications using the Microsoft SDK 5.0. It works on my development machine, but not on machines that do not have the SDK loaded. Are there files from the SDK that need to be added to the target machine?
|
|
|
|
|
Yes. They are described in the documentation for the SDK. If you are really documenation adverse, try running the DEPENDS utility that ships with VC. It will tell you all the things your program needs to run. Go to a standard configuration system and see which ones are missing. If this is for wide distribution, better go with the documentation.
P.S. Remember, when redistributing other peoples software, check the licensing agreements. This is especially true if you are developing commercial software and distributing Microsoft stuff.
Hope this helps,
Bill
|
|
|
|
|
Hi, All.
How can I change the Z location of a control?
* Using MFC
* Dialog Based App.
Thanks
BTW: I want to thank you guys 4 helping me. Thanks.
|
|
|
|
|
Use CWnd::SetWindowPos().
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I use a CHtmlView to display a web page,and i can use this code to get the IHTMLDocument2 interface pointer:
CDhtmlView * pView = (CDhtmlView *)GetActiveView();
LPDISPATCH pDispatch;
pDispatch = pView->GetHtmlDocument();
IHTMLDocument2 * pHTML;
pDispatch->QueryInterface(IID_IHTMLDocument2,(void **)&pHTML);
then i can use this pointer to do something.
but when a homepage use the to split into same frame. how i get the IHTMLDocument2 pointer of a homepage in a frame??
|
|
|
|
|
Call IHTMLDocument2::get_frames() to get a IHTMLFramesCollection2 interface. For each frame in the collection, query it for IHTMLWindow2, then call get_document(). (There's sample code in MSDN on the IHTMLFramesCollection2::item page.)
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I want to read/write a unicode file. Is there a API through which I know whether the file is unicode or not, is there a file header for a unicode file. If this is not there, what is the function (string related) i need to use.
thanks
Kannan
|
|
|
|
|
Here's some code I use to avoid using a UNICODE file in a non-unicode build (gpfs the kernel):
#if !defined(_UNICODE)
DWORD dwBytesRead;
ReadFile(hFile, szBuf, 4096*sizeof(TCHAR), &dwBytesRead, NULL);
if(dwBytesRead > 7) {
DWORD dwUnicode = IsTextUnicode(szBuf, dwBytesRead, NULL);
if(dwUnicode) {
m_bStringsLoaded = FALSE;
retval = MD_UNICODE_ERROR;
}
}
#endif
Not guaranteed to work for small strings - hence the '> 7' check (as if thats gonna help me!). Check the docs for IsTextUnicode - interesting stuff.
|
|
|
|
|
Thanks. It works For me.
Cheers
Kannan
|
|
|
|
|
I'm trying to use the windows media player active-x control in my app but i can't seem to load a file. This is what i have:
CString Movie = "C:\mymovie.avi";
m_cPlayer.SetFileName(Movie);
m_cPlayer.Play();
i tried to put "file:///" before the path because some web related stuff needs it, but that didn't work either.
How do i load the file?
Thanks
Kuniva
|
|
|
|
|
The backslash should be typed twice:
CString Movie="C:\\mymovie.avi";
...
|
|
|
|
|
In msdn ,in "Recordset: Locking Records (ODBC)",It
said "Relatively few ODBC drivers currently support pessimistic locking."
How can I know my ODBC driver support pessimistic locking?
|
|
|
|
|
SQLGetInfo should do it.
Regards,
Alvaro
|
|
|
|
|
- How to change the size of a toolbar?
- How to add/remove a image of a toolbar?
- Can you help?
- Regards,
BigMouth
|
|
|
|
|
Use SetSizes() to change the size of toolbar buttons.
The height of a toolbar will be the height of the buttons.
And the width will be the width of the containing window
For images use an image list and send a TB_SETIMAGELIST message. If you want to change the images, change the image list and send the TB_SETIMAGELIST message again
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
- Thanks pal!
- I still have a question. Can you show me an example about the usage of TB_SETIMAGELIST message?
- Have a nice day,
BigMouth
|
|
|
|
|
You can actually modify the imagelist directly - m_wndToolbar.GetToolbarCtrl().GetImageList() returns a pointer to the image list, and you can then use ExtractIcon to pull an image out, or Add or Replace to add an image or replace one respectively.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
- Thanks pal!
- I use the following codes, but it seems that it does not work.
void CMainFrame::OnEditCopy()
{
// TODO: Add your command handler code here
CImageList* list1=this->m_wndToolBar.GetToolBarCtrl().GetImageList();
list1->Add(AfxGetApp()->LoadIcon(IDR_MAINFRAME));
}
- Can you help me out?
- Regards,
Maer
|
|
|
|