|
What you are asking is extremely low level and involved. Not the sort of thing you can expect answered in a short message board post.
Steve
|
|
|
|
|
Actually yes, but don't tell anybody!
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.
[my articles]
|
|
|
|
|
class fontdlg
{
public:
void a()
{
CFontDlg dlg;
COLORREF color=dlg.GetColor();
}
}
I want to use color is other class, so how can i use color variable in other class. For that how should i declare.
|
|
|
|
|
The quick and dirty answer is
class fontdlg
{
public:
COLORREF m_color;
void a()
{
CFontDlg dlg;
m_color=dlg.GetColor();
}
};
or
class fontdlg
{
public:
COLORREF a()
{
CFontDlg dlg;
return dlg.GetColor();
}
};
But then you should be aware that you really need some background on OOP.
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.
[my articles]
|
|
|
|
|
Does this code helpful?
CMain m*=(CMain*) GetParent();
m->yourvalues;
|
|
|
|
|
Hamid. wrote: Does this code helpful?
Sure.
But probably has little to do with OP.
Just kidding, you know, Hamid.
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.
[my articles]
|
|
|
|
|
I know him but I think no because he has some wonderful ways to solve his problems ,but I know a seceret about him,he likes merrymaking if he can to find it
|
|
|
|
|
Hi all
Could you please help me identify the Win32 API or MFC function which determines the credentials of current windows user ? ie Admin or Restriced User or Power User ?
Thanks in advance
Dharani
redindian
|
|
|
|
|
IsUserAnAdmin() can tell you if the present user is an Administrator or not.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hello All
Is there any way to know the Update in window?
In descriptive how can my programe come to when any update is done to window(Changig open window or as in codeproject the images are changing continuesly)
i can do it by making endless loop and capturing two bitmaps and comparing it, But this solution result in more CPU utilization.
So is there anybody who can solve my problem?
Thanks in advance.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Hi...
am using vc++ and sql server2005.
i am doing both server and client.
am sending a image file from server to client as a char*.
in client i need to save it into database.
then i need to retreive.
what is the procedure?
can anybody help me?
paulraj
|
|
|
|
|
hi
i have a application to convert from CSTRING to TCHAR .
with advanced thanks
francis
Franics K Antony
|
|
|
|
|
|
No !
Never use GetBuffer without knowing what it implies. Did you read the documentation of this function ?
|
|
|
|
|
Interesting. Can you please explain why would you want to use GetBuffer() here.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
LPTSTR pBuffer = szString.GetBuffer( 10 );
_tcscpy_s( pBuffer, 10, "String" );
szString.ReleaseBuffer( );
|
|
|
|
|
I'd rather liked it if he had replied to me.
I would not recommend the usage of GetBuffer() method for the sake of copying the string content to another TCHAR* . Your CString object is not integral between the GetBuffer() and ReleaseBuffer() calls. Which means two things: 1. You must never forget to call ReleaseBuffer() after you're done with it. 2. All the member functions on your CString object are *not* guarenteed to work perfectly between the GetBuffer() and ReleaseBuffer() calls.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: I would not recommend the usage of GetBuffer() method for the sake of copying the string content to another TCHAR* .
I agree.
Rajesh R Subramanian wrote: Which means two things: 1. You must never forget to call ReleaseBuffer() after you're done with it. 2. All the member functions on your CString object are *not* guarenteed to work perfectly between the GetBuffer() and ReleaseBuffer() calls.
In fact he took care about both the issues.
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.
[my articles]
|
|
|
|
|
CPallini wrote: In fact he took care about both the issues.
And the first line of my reply was "I'd rather liked it if he had replied to me." His post was something like "hey, use GetBuffer()". He wasn't bothered to explain the issues related to it, mostly because he didn't know it. And you agreed GetBuffer() isn't the best way around to do it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: And you agreed GetBuffer() isn't the best way around to do it
In fact it is the only way if you really need a pointer to the string buffer (i.e. whenever CString LPCTSTR cast operator isn't a viable option) though I agree, usually asking for a pointer to editable CString buffer is not a good idea.
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.
[my articles]
|
|
|
|
|
Rajesh R Subramanian wrote: 1. You must never forget to call ReleaseBuffer()
It is similar to new TCHAR []; and delete
Rajesh R Subramanian wrote: 2. All the member functions on your CString object are *not* guarenteed to work perfectly between the GetBuffer() and ReleaseBuffer() calls.
I expect we want to work on TCHAR rather than CString in this context
|
|
|
|
|
Rajkumar R wrote: It is similar to new TCHAR []; and delete
Thanks, but I am not in need of this information.
Rajkumar R wrote: I expect we want to work on TCHAR rather than CString in this context
We may do it, becasue we know it. You can't expect the O.P. to always know it. Also, I've stated several times this is not the best approach to extract the string from a CString object.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: but I am not in need of this information.
this is not for ur info and to mispell it, the similarity i meant here is, if the person is forgetting to write ReleaseBuffer, the same can happen in delete, and also between CreateFile-CloseHandle, GetDC-ReleaseDC, lock-unlock, ... It all upto the programmer who should be careful writting a single character of production quality code.
Rajesh R Subramanian wrote: We may do it, becasue we know it. You can't expect the O.P. to always know it.
ignorance and carelessness will always leads to bugs. I don't think this argument is supportive.
Rajesh R Subramanian wrote: Also, I've stated several times this is not the best approach
It is not supported by valid statements.
I believe this class is not designed by a team of junk fellows, they might have analysed many usecases. Direct use of CString with C-Style API, System API considering performance (while calling ReleaseBuffer CString is updated without need to assign back the editted one) and ease of use...
Rajesh R Subramanian wrote: I would not recommend the usage of GetBuffer() method for the sake of copying the string content to another TCHAR* .
make no sense, example i have given is tcscpy doesnot mean that it is for the sake of copy.
if you meant that getbuffer is making copy FYI it does return pointer without any copy unless the required buffer size is greater, the editted TCHAR data is also not copied back to CString
|
|
|
|
|
Rajkumar R wrote: this is not for ur info and to mispell it, the similarity i meant here is, if the person is forgetting to write ReleaseBuffer, the same can happen in delete, and also between CreateFile-CloseHandle, GetDC-ReleaseDC, lock-unlock, ..
But then the point here is that GetBuffer() is a member function and so people may just call it like that, while they'd generally know that new and delete, etc., go as pairs. But, they may not know it's the case with GetBuffer(). See here[^] for an example. It is up to the programmer to write good quality code, but then someone who's asking how to extract the string out of a CString will definitely need some assistance in writing good quality code. So, I'd always explain the tradeoffs while using something like GetBuffer().
Rajkumar R wrote: ignorance and carelessness will always leads to bugs. I don't think this argument is supportive.
Again, if I feel that someone may do it in an ignorant way, rather than just providing an answer which may lead him to do somethign in a wrong way, I'd try to correct him when I am answering his query.
Rajkumar R wrote: if you meant that getbuffer is making copy FYI it does return pointer without any copy unless
Do you even think that I wouldn't know this? This shows that you didn't even understand what I was talking about.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: But then the point here is that GetBuffer() is a member function and so people may just call it like that
Lock is also a member function of CMutex()
Rajesh R Subramanian wrote: Do you even think that ...
that is why i used "if", but i think i pointed what u meant just above that.
"hey, use GetBuffer()" by him, doesnot mean simply code without reading doc, he given a hint, he may not like spoon feeding and use bandwidth for explaining which is already explained in doc. however we used bandwidth enough debating.
|
|
|
|