|
Hi
How to get a variable name?
I forgot the macro!
thanks
|
|
|
|
|
Hadi Dayvary wrote: How to get a variable name?
Closing your eyes and saying "Abracadabra" will sometimes work. Other than that, you'll need to rephrase your question.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hey what happend why you and other members on this thread got 1,maybe I can repair it with 5 vote.;)
|
|
|
|
|
It is something that happens a lot without sense, there should be some user of forum that hate some people here.
On the other hand... Thanks, but I don't care about the votes, I am far away less skilled as many other users so... If I really help someone my best reward is a simple "thanks" from asker.
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
DavidCrow wrote: Closing your eyes and saying "Abracadabra" will sometimes work. Other than that, you'll need to rephrase your question.
I found the macro :
#define NAME(VAR) ( CString(#VAR) )
and then you can use it for getting any variable name at runtime:
CString s = NAME(m_sName);
If you don't know something it does not mean that it's not exist!
|
|
|
|
|
Don't you like the double quotes " , do you?
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.
|
|
|
|
|
what the F*ck can you use that for ?!
Hadi Dayvary wrote: and then you can use it for getting any variable name at runtime
but don't you just know the name of the variable you handle when you pass it to the macro ?!
|
|
|
|
|
it could be used for some debugging tracing purpose.
|
|
|
|
|
Maximilien wrote: it could be used for some debugging tracing purpose.
The same way as surrounding double quotes can.
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.
|
|
|
|
|
Sure, but the nice thing about it is you can write a single macro that takes one argument
(a variable) and uses both its name and its value, making it easy to dump a lot of variables.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Luc Pattyn wrote: a single macro that takes one argument
(a variable) and uses both its name and its value .
Of course, the above is the trick that makes the difference.
I hope the OP will realize it.
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.
|
|
|
|
|
It seems some body didnt like your answer and you got 1 but I give you 5 because your time that you spent.;)
|
|
|
|
|
you're such a good guy hamid
keep it up
|
|
|
|
|
Hadi Dayvary wrote: How to get a variable name?
I forgot the macro!
The macro is: ABRACADABRA
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.
|
|
|
|
|
Can we use of this macro for other problems like find out exceptions on programs?;)
|
|
|
|
|
Sure!
I use it even to find a parking space for my car in the evening.
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.
|
|
|
|
|
CPallini wrote: I use it even to find a parking space for my car in the evening.
|
|
|
|
|
hi,
how to get the print preview option in a dialog?
thanks
panthal
|
|
|
|
|
Take a look in http://www.codeproject.com/printing/[^] section here and read a bit. There is a lot of things that can answer you.
Is not for a dialog but I recommend you the articles of Roger Allen and Joseph M. Newcomer their artcles helped me a lot while doing my own printing.
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
|
have used edit control in dialog box.
I can get the entered string as
CEdit *ptrEdit = (CEdit*)GetDlgItem(IDC_EDITURL);
CString urlString;
ptrEdit->GetWindowText(urlString);
bool bDestination = PCHSEManagerInternal.IsDestinationReachable(urlEdit);
//above line is in MSDN
I do not know what is "PCHSEManagerInternal".
The following errors occured
error C2065: 'PCHSEManagerInternal' : undeclared identifier
error C2228: left of '.IsDestinationReachable' must have class/struct/union type
do I need to include any header file for this
please help me for this.
|
|
|
|
|
If you are using a MSDN example without taking care about what you are copying, it is totally logical that you have errors.
That "PCHSEManagerInternal" is a class that is being used in the example and, logically, if you didn't include the header that need that class your compiler complains at it makes. It can not know what it is, is the same scenario as if you create a class "CMyClass" and the you include "CMClass" the compiler won't recoginise it.
So...
Go another time to the web where you get that line, and READ the explanations and the whole code. Take special atention to the #includes and what the article/example say about that class. You may have to search for the whole class (*.cpp and *.h) when it is not an included component in VS headers
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Did you see Requirements of IsDestinationReachable?
|
|
|
|
|
I have used edit control in dialog box.
I can get the entered string as
CEdit *ptrEdit = (CEdit*)GetDlgItem(IDC_EDITURL);
CString urlString;
ptrEdit->GetWindowText(urlString);
This 'urlString' contains web site address e.g. "http://www.google.com"
I want to validate this web site address. i.e. give me code which validates such string.
please help me for this.
Chetan
|
|
|
|