|
|
Thank you. This solve my problem
|
|
|
|
|
I've already written my code in C# and it works. But to integrate it into our product, I have to re-write it C++ 6.0. I'm very weak here and am lost. My problem is this: I start with a line extracted from a file. The string contains a variable number of individual commands consisting of one letter followed by a number. In C# my code is built like this:
private string[] LineSplitter(string LineIn){
if (LineIn == "")
return null;
string[] strOut = new string[0];
int i = 0;
string strChar;
do
{
...code to locate length of number following letter
} while ((isNumeric(strChar)) && (i + 1 < LineIn.Length));
strOut = (string[])ResizeArray(strOut, strOut.Length + 1);
strOut[strOut.Length - 1] = LineIn.Substring(0, i);
LineIn = LineIn.Substring(i);
} while (LineIn.Length > 0);
return strOut;
}
(And I'm sorry for putting C# in a C++ group, but I'm looking for the C++ equivalent)
Here are my questions...
1. How do I declare the function as string array?
2. How do I increment array elements until I'm done? Each line can have a variable number of elements.
3. How do I return the result.
Please be gentle. I'm struggling with C++ and this is my first post. I'm wrestling through the majority of everything else in this process, but this has my brain in a pickle.
|
|
|
|
|
Mark Randel wrote: 1. How do I declare the function as string array?
Not exactly an array but this is the C++ way -
std::vector<std::string>
Mark Randel wrote: How do I increment array elements until I'm done? Each line can have a variable number of elements.
while (LineIn.size() > 0)
Mark Randel wrote: How do I return the result.
std::vector<std::string> strOut;
.
.
.
return strOut;
modified on Wednesday, November 18, 2009 5:53 PM
|
|
|
|
|
Thanks a lot. The vector was the key to what I was looking for. I'm using CString , though. But it all works fine.
My question about adding to the array was concerning changing the size of the array. The vector makes that easy with the push_back command.
Also, returning the value from the function required that I make the type of the return as a vector:
std::vector<CString> CNCLine::LineSplitter(CString LineIn)
{
std::vector<CString> strOut;
... code
return strOut;
}
Works like clockwork. Thanks for the direction.
____________________________________________________
I'd rather have a frontal lobotomy than a bottle in front of me... Bill W
|
|
|
|
|
Interesting... the post erased the "<cstring>" command after the vector designation. Hope it doesn't with this text. Otherwise, I'm going to end up looking quite foolish.
____________________________________________________
I'd rather have a frontal lobotomy than a bottle in front of me... Bill W
|
|
|
|
|
That is because < and > are using by HTML for the tags.
Replace < with < and > with >
In fact you can simply click on the signs at the top of the editor to insert them.
|
|
|
|
|
Hi,
I have a simple application in MFC that creates files of (Name.ext) type. How can I make it launch the application by double clicking the file? Note, I can open the file from within the application?
|
|
|
|
|
If the file is an executable (like .EXE) you can use CreateProcess .
If the file is a document file (like .DOC) use ShellExecute with the "open" operation.
|
|
|
|
|
|
Thanks for the suggestion. I know how to open the app by double clicking, but what I am not sure how to do is how to handle double clicking a file created by the app. example:
my executable is "MyApp.exe", I use this to create files like "MyApp.dat". Where do I implement ShellExecute in the program to make "MyApp.dat" open up when double clicked?
Thanks
|
|
|
|
|
What is the format of your .dat file?
In which application do you intend to open it?
|
|
|
|
|
The App is a simple Dialog Application with an Edit Field that contains Text about the customer information. So, the data is simple CString Text. I would just like to have the file open when double clicking showing the customer Text as opposed to open the app and then point to the file.
Thanks
|
|
|
|
|
Maximilien has already answered that.
You have to associate .dat with your application.
|
|
|
|
|
I must be missing something, because I thought I had the association done. When I double click I get the App without the file info populated. But, I can look at my association code a bit more.
Thanks
|
|
|
|
|
Take a look at the documentation for CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes(BOOL bCompat) .
|
|
|
|
|
Did you use AppWizard to create the application? If so, it should have created a .reg file, and added a few lines (EnableShellOpen() and RegisterShellFileTypes() ) to the app's OnInitInstance() method to update the registry.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi All,
I am using CAcroAXDocShim classes for AcroPDF.dll in my project.
My projects main dialog uses this control to display the PDF's.
From my Main dailog, if i use the scrollbar, the PDF control dosent refresh properly.
i.e brown stripes gets in middle all over the PDF.
I taught of posting a refresh message to the PDF Control, but CAcroAXDocShim class dosent have a refresh method.
Can any one give me some suggestions on how i can get out from this refresh issue.
Thanks,
Kasi
|
|
|
|
|
kasi14 wrote: From my Main dailog, if i use the scrollbar,
Is it the ActiveXControl's scroll bar? or the DialogBox has its own scroll bar?
-Suhredayan
|
|
|
|
|
Is there any way to determine plunging or removing of a removable storage like flash memories to the system in MFC?
Of course not by setting timer?
|
|
|
|
|
Windows will broadcast a message, see DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE,
so all it takes is catching these.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Thanks
DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE Messages work perfect.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Can you respond to the WM_DEVICECHANGE message?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks
I have tested DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE Messages and they work fine
modified on Wednesday, November 18, 2009 2:28 PM
|
|
|
|