|
|
Hi all,
Actually i am new to VC2005. My problem is whenever i am trying to add any function say OnCtlColor to my class a message is displayed that Add/remove operation is not possible because the code element is read-only.
I am not getting how to correct it...
Can anybody help me in correcting it...
Thanks in advance
|
|
|
|
|
the header and cpp file might me readonly. Remove the read only attribute of that files.
|
|
|
|
|
And sometimes it also happens when the .ncb file gets into crazy. Close the solution and re-open it should help.
Maxwell Chen
|
|
|
|
|
Steps:
1. Switch to [Class View] tab, and highlight the class name you are going to add OnCtlColor . (It must be a CWnd based class)
2. Right-click at that name, and choose [Peoperties].
3. You are lead to [Properties] tab. You will see an icon-only button which has the name [Messages]. Click that [Messages] button.
4. The view will list all the available messages including WM_CTLCOLOR.
Then you know what to do.
Maxwell Chen
|
|
|
|
|
I have experienced this bug in Visual Studio 2005 in several of my projects. Its very annoying and I hope it was fixed in 2008.
I found a strange way to fix the bug but it works almost everytime for me.
1.) Open the header file and copy the entire contents of the header into the corresponding CPP file at the very top.
2.) Close Visual Studio 2005.
3.) Delete the Intellisense database with the extension .NCB
4.) Re-open Visual Studio 2005 and wait a few seconds for the Intellisense database to rebuild.
5.) Try to add your OnCtlColor message handler again.
6.) Copy and paste your header contents back into the .H file.
Let me know if it works for you!
-Randor (David Delaune)
|
|
|
|
|
That sequence fixes so many bugs that they should have put a big button
on the UI that does the sequence automatically LOL
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Randor wrote: I have experienced this bug in Visual Studio 2005 in several of my projects. Its very annoying and I hope it was fixed in 2008.
I fear not... just had a similar problem myself in VS 2008, and deleting the .ncb fixed the issue here too.
Cheers,
Billy.
MCPD Windows Developer
"Duct tape is like the force, it has a light side, a dark side and it holds the universe together!" - Anonymous
my holding page..more coming soon!
|
|
|
|
|
Wow, looks like I posted that back in March 2008. I am also using VS2008 now and it seems that it happens less often but the problem has not gone away. It seems that it mostly happens in my very large C++ projects. I guess we can only hope that VS2010 will have permanently squashed this little annoyance.
I am glad that the post helped you fix your issue.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi all,
Can anybody please tell me why CWinApp class have only one object?
Thanks in advance
|
|
|
|
|
Because MFC was designed that way. The one object wraps all the app instance
info that Windows apps have only one of, like the HINSTANCE, and the commandline
params passed. It also holds any other application-wide stuff of which there can only be one.
That makes it a nice place to hide app-wide variables that in the old days would be global.
Plus it makes no sense to have more than one app object in a single app.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
neha.agarwal27 wrote: Can anybody please tell me why CWinApp class have only one object?
because it the base class for the application class. It is needless to have more than one application class for one application. The implementation has dependency on the global object obtained from AfxGetApp(), which is used by the AfxWinMain from winMain. Then it is similar to ask why only one main function for an application.
"The main application class in MFC encapsulates the initialization, running, and termination of an application for the Windows operating system. An application built on the framework must have one and only one object of a class derived from CWinApp." from msdn.
|
|
|
|
|
neha.agarwal27 wrote: Can anybody please tell me why CWinApp class have only one object?
Adding to the above replies, think of it logically. You may have many dialogs, documents, menus, etc., But how many applications are you writing code for? 1? So, the one and only CWinApp derivative would represent your application and you have only one of it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
It's the unum et simplex rule.
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
|
|
|
|
|
|
Also note, C++ supports falling case (unlike C#), whereby if there is no break keyword, the next case is evaluated as well. This comes handy is some cases.
|
|
|
|
|
|
int me = 0;
switch(me)
{
case 0:
cout<<"I need a C++ book"<<endl;
break;
default:
cout<<"I still need a C++ book"<<endl;
break;
}
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: int me = 0; switch(me) { case 0: cout<<"I will read a C++ book"<<endl; break; default: cout<<"I am badly in need of a C++ book"<<endl; break; }
he he he nice one1
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
|
You should really really buy a book and learn C++ from the basics. Even if people already told you so, you don't seem to see the benefits from it. Of course, you'll spend some time doing only this (and not going any further in your project) but on the long term (and even shorter) you'll be far more efficient.
C++ is not a language where you can guess what to write and expect it to work. Even if your program compiles, you'll still have a lot of runtime problems (crashes, memory leaks, ...) and if you don't understand what you are doing, that will be a hell of a job to fix them.
And another point: people on the forum will get bored seing you posting 10 questions a day. And what will probably happen is that the quality of the answers will decrease because you don't make any effort to learn and expect us to do the job for you.
|
|
|
|
|
What's the problem with you stupid dork ?
not only you spam the forum with your minimalistic questions, but you delete it once you get an answer, so that no one here can see what was asked at first.
dude ! this is not a chat, it's a forum. if you can't wait, go somewhere else.
|
|
|
|
|
5. But I'll guess a hazard your suggestions are going into (if at all) deaf ears.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: going into deaf ears.
fell on deaf ears[^]
falls on deaf ears
falling on deaf ears
led mike
|
|
|
|
|
Didn't know that.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|