|
I don't think you use MFC,but if the answer is yes you can check for CString class.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Yes I am using MFC.As I have written before I am now to programming and I now very few things.For this reason I wrote this message.Can you help me?I now that I must search CString.
Thank You ,Nektarios
The truth is out there.
|
|
|
|
|
The thing I can guess now is:
Use FindOneOf() to find spaces,then use Left() to extract those number.
Have you got it or you need more?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
You can also use Find() instead of FindOneOf()
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
There are a lof of types called "strings". Mazdak anwered as for MFC CString s.
Most probably, you're using char * s. In this case, the usual (though not especially good) way to go is using function strtok .
If you're using std::string s, use a tokenizer like Boost tokenizer. Having into account you're new to programming, you might need some help from someone with more experience to install and begin to use this library.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If you are using a standard char array, you can use a function called strtok . This function will allow you to step through a string and find all of the tokens, or substrings. Here is a short example:
#include "stdafx.h"
#include "stdlib.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
char str[] = "Let us get out of here, NOW!";
char *vars[10];
int index = 0;
vars[index] = strtok(str, " ,");
while (vars[index] &&
index < 10 )
{
index++;
vars[index] = strtok(NULL, " ,");
}
int token;
for (token = 0; token < index; token++)
{
cout << vars[token] << endl;
}
return 0;
}
|
|
|
|
|
As it seems your code is good but I don't understand the meaning of some commnds
What this command do?
vars[index] = strtok(str, " ,");
What this examine?
while (vars[index] && index < 10 /*There is only space for ten strings.*/)
Please explain.
|
|
|
|
|
Nektarios Sourligas wrote:
vars[index] = strtok(str, " ,");
Earlier I created an array of 10, char* pointers. This is the pragmatic way to hold the variables that you originally mentione din your first question,
var1, var2, var3 ...
Except for in this case, you access the variables like this, using a zero indexed array:
vars[0], vars[1], vars[2] ...
strtok returns the pointer to the next token in your string. Therefore I assign the result of strtok to the current variable. I keep track of the current variable with the index value. index starts at 0. If you wanted to write it out with the 6 or 7 variables that you had it would look like this:
var1 = strtok(str, " ,");
var2 = strtok(NULL, " ,");
var3 = strtok(NULL, " ,");
... and so on.
Nektarios Sourligas wrote:
while (vars[index] && index < 10 /*There is only space for ten strings.*/)
1) vars[index]:
I should have been more explicit with this, another way to write this is (NULL != vars[index] . Basically I am testing the variable for NULL. If strtok reaches the end of the string, and there are no more tokens, then it will return NULL, and we know that we are done parsing the string.
2) index < 10
This is just to be safe, in case you wanted to change the string that I provided. The string that I provided had 7 tokens in it. If you changed the string to something with more than 10 tokens in it, and that test was not there, then most likely an error would occur. I am simply making sure that no more than 10 tokens are assigned from strtok
One more thing that I forgot to mention about strtok, is that it modifies the string that you are parsing, so if you want to keep the original string intact, you will want to make a copy of that string, and use the temporary version of it, like so:
char originalStr = "This is the original string.";
char *tempStr;
int iLen = strlen(originalStr);
tempStr = new char[iLen+1];
if (NULL == tempStr)
{
}
char* var1 = strtok(tempStr, " ");
...
delete[] tempStr;
Good Luck
|
|
|
|
|
You said you're using MFC, so use AfxExtractSubString() to split the full string on spaces.
--Mike--
"Jobs that don't allow you to visit the Lounge 25 times a day at the minimum are not worth having anyway."
-- Nish, 3/28/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
How do I list the classes / methods / properties defined in a com component programatically?
(something similar to object browser / intellisense feature found in VB)
regards and thanks
M$
|
|
|
|
|
VB does it by reading the type library (typelib) that is included in the DLL with the COM object that you have. I have never really messed with the typelib directly, but maybe that will get you started on your search.
|
|
|
|
|
Look into the ITypeLib, ITypeLib2 and ITypeInfo.
Using these interafaces you can enumerate the
contents of a typelibrary.
|
|
|
|
|
I am working on some ATL objects that are called from an ASP page. Is there anyway to redefine ATLASSERT to do something else or nothing so it doesn't hang the server when it throws the dialog box?
TIA!
|
|
|
|
|
If it's just a macro, then just #define it to do nothing, after including the header that defines it to start with.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
It compiles to nothing when you compile in release mode.
|
|
|
|
|
Thanks! However, I have been using debug builds and switching between a GUI app so I can step through code and the ASP pages. I missed redefining if after the header, I was trying to do it before the include. That redifined the macro however I am still getting assertion dialogs somewhere. Do you guys know off the top of you head any other assert macros that would get called from the ATL internals?
Thanks again!
|
|
|
|
|
ATL makes heavy use of ATLASSERT internally.
|
|
|
|
|
#ifdef ATLASSERT
#undef ATLASSERT
#endif
#define ATLASSERT ....
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Hi, I am a beginner and I need to know how do I go about printing a dialog box.
Please answer my question asap
thank you!
|
|
|
|
|
atomicluis wrote:
Please answer my question asap
But of course, we live to serve.
Saying things like 'please answer quick' and 'urgent' is just plain annoying. You can say that when you're paying for the service.
You need to get a device context for a printer, which the print dialog will help you do ( you don't need to display it for this ), then you can do a bitblt right across. If you want to print the entire dialog ( caption bar, etc. ) you'll need to use GetWindowRect, then you can draw the entire dialog after doing a screen capture ( which is just creating a HDC with "DISPLAY" as the first paramenter, or MFC has a class for it which escapes me ).
Be warned, unless you do a stretchblt, it will be VERY, VERY small.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
The chances of your answer making sense to the requester are slim, i think.
Therefore, you must write a lengthy tutorial on Device Contexts, MFC, Printers, The DDK, um... .NET, er.... pointers as well.
Please do this ASAP it's incredibly urgent.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
ROTFL !!!
Actually, I fully expected to have to expand on my reply, but I wanted first to know if he wants to print a dialog box, or just the client area.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Check this.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
hi,
i have just a couple of questions.
1. Does anybody know how to read pdf files or a class that exists to download?
2. Does anybody know how to control Word and / or explorer from within a program
Cheers
Dor
|
|
|
|
|
I don't know about your first question but for your second take a look at this article in MSDN:
Interacting with Microsoft Excel: A Case Study in Automation
Yeah, its about Excel but I belive that the same ideas can be applied to Word.
Hope it helps.
|
|
|
|
|