|
try
LONG GetWindowLong(HWND hWnd, int nIndex);
|
|
|
|
|
What i need is little more complex.
I want not only the properties that i can get by using GetWindowLong - i want also the properties around the object.
I mean properties like - object color, text, size, class, parent of the object ( if the object is CButton that "sit" on some panel or dialog )
So... How can i get all those information ?
|
|
|
|
|
Yanshof wrote: I mean properties like - object color, text, size, class, parent of the object
go through CWnd class Members.
|
|
|
|
|
I have a function char * SetName() that I use inside a method of a different class. If I do:
char * cOpName ;
cOpName = AnotherObj.SetName() ; everything's fine. But if I try to assign the return value of SetName() to a member variable
private:
char * m_cOpName ;
m_cOpName = AnotherObj.SetName() ; I get an error, "error C2166: l-value specifies const object"
Any idea??
|
|
|
|
|
Where did you put that code ? Because looking at it it seems you put it inside the class declaration which is plainly wrong... You need to put that in a member function of the class. And the function must be non-const.
On a side note, do you know what the assignement operator is doing on char pointers ? Do you know that it only copies the pointer. It means that if inside your AnotherObj you modify the original string, the changes will also occur in m_cOpName (both pointers point at the same memory location).
|
|
|
|
|
piul wrote: m_cOpName = AnotherObj.SetName() ;
Where have you put the above line of code?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
class CAnneal
{
public:
void GenOp () ;
/...
public:
char * m_cOpName ;
};
class COperation
{
public:
char * SetName() ;
};
char * COperation::SetName()
{
return "Hello" ;
}
void CAnneal::GenOp()
{
COperation op ;
char * cOpName ;
cOpName = op.SetName() ;
m_cOpName = op.SetName() ;
}
|
|
|
|
|
Your code works fine on my system, as it should do also on your.
BTW Simulated annealing?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I hate strings...
If the "=" operator only copies the pointer, how do I do to copy the characters?? Because, the object that sets the string falls out of scope.
Oh, and it's not simulated, it's for real!
|
|
|
|
|
Use a std::string instead, it will handle all the ugly stuff for you.
|
|
|
|
|
While the best suggestion is the Cedric Moonen's one (use std::string ), you may choose the Win32 API approach (if you need to be stuck on plain C ), i.e.
void SetText(char * buf, int len);
Where buf is a buffer (of size len ) allocated by the caller.
In the function implementation, of course, you've to take care of copying characters.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
you should never use operator=() on C style strings (as you stated, it copies the pointers addresses instead of the strings contents.
if you still have to deal with char*, the use strcpy() and its variants.
but as you're coding in C++, you'd better use the std::string class which provides powerful operators to handle this...
|
|
|
|
|
piul wrote: cOpName = AnotherObj.SetName() ;
Is this SetName or GetName?
piul wrote: everything's fine. But if I try to assign the return value of SetName() to a member variable
private:
char * m_cOpName ;
m_cOpName = AnotherObj.SetName() ;
I get an error, "error C2166: l-value specifies const object"
This means "this" is constant! You are trying to assign a value to a const class' member.
For e.g.
const SomeClass sc;
sc.m_cOpName = AnotherObj.GetName(); // Error l-value specifies const object
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I'm sorry guys!!
I must be blind or something... GenOp() was in fact GenOp() const
I just didn't see it and couldn't understand...
Thanks for the help!
|
|
|
|
|
hello for all
please help me
i have
char x[50]="int w ; int s,get;";
i want to divide this string as
w
s
get
then i want to store each of them as example
string s[8];
s[1]=w
s[2]=s
s[3]=get
i can store it
i can't divide it, i have some ideas but didn't execut
please help me
|
|
|
|
|
sofia_111 wrote: i can't divide it, i have some ideas but didn't execute
What was your idea? Can you show us what you tried?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
int o=0;
for( int h=0 ;h<l ; h++)
if(str_integer[h]==' ' || str_integer[h]==',')
{
o=h+1;
if(str_integer[o] !=',' || str_integer[o] !=';')
{
cout << str_integer[o] <<'\t';
o++;
}
}
l is maximum number of str_integer
this excuted put print only the first character
i want print all character between , and ; or between space and , or between ,and,
in lgical we must use while not use if but when I use while appeare problem in excute
THANKS THIS MY IDEA
I HOPE HELP ME
modified on Tuesday, May 6, 2008 4:32 AM
|
|
|
|
|
Have a look strtok , see the sample in the related MSDN page [^].
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
is there any way without strtok ?
|
|
|
|
|
Of course it is: you may choose a lower level approach (hand crafting) or a higher level one (for instance expoiting some string class's methods or a regular expression library).
But why?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You basically need to build a (very simple) lexical analyzer [^], thought in your case it should not be such a daunting task, maybe reading some introductory material about will be helpful.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
How to create a TreeControl on a ListControl ?
|
|
|
|
|
Search Google for Tree List Control.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
have a look here[^] too, or ask codeproject search engine
|
|
|
|
|