Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PreTranslateMessage and covariant

Status
Not open for further replies.

minifiredragon

Programmer
Jun 29, 2003
68
US
I recently was using a Learning edition of Microsoft Visual C++ (ver 6). A few days ago I went out and bought Visual C++ .net 2003 so I can have something that removes that annoying nag screen. Now, when I compile my previously working program, I get:

Visual Studio Projects\ICServer\ICServer\ICServerView.h(66): error C2555: 'CICServerView::preTranslateMessage': overriding virtual function return type differs and is not covariant from 'CFormView::preTranslateMessage'

and I don't know why. In my .h file it is defined as such:

protected:
virtual bool PreTranslateMessage(MSG* pMsg);

and in my .cpp file as such:

bool CICServerView::preTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == 'I')
{

//Initialize InsertDlg window
CInsertDlg dlgInsertDlg;

//OPen Window
dlgInsertDlg.DoModal();
return 1;
}

//return CFormView::preTranslateMessage(pMsg) ;
}

which is almost how I had it in the one that compiled in the previous Compiler. All I did is re-add the function using virtual and protected. Before it was just private.

Any suggestions?? I know you all help me alot before. I am very new to the MFC.
 
>> return type differs

virtual bool PreTranslateMessage(MSG* pMsg);

virtual [red]BOOL[/red]PreTranslateMessage(MSG* pMsg);

-pete
 
Garr!! OMFG!!! <Kicks Microsoft> You let it put the code in itself and it puts it in wrong!!!!!

Thanks man. I never even thought it would be that simple.

<crawls off into the night grumbling>
 
>> You let it put the code in itself and it puts it in wrong!!!!!

When I use the Class Wizard to build the skeletons of PreTranslateMessage it does not put in &quot;bool&quot; it correctly puts in &quot;BOOL&quot;. I think you better stop kicking Microsoft and try to fix the loose nut between your chair and keyboard. [lol]

-pete
 
I guess you haven't used Visual C++ .net 2003.

I can't find Class Wizard!!!! It doesn't come up in help. Not on any menus. When you want to add a function you need to goto Class View, and right click on the Class you want to add a function, goto Add and it pops up the add function wizard.

After that you are left to the mercies of your knowledge (in my case very little) because there are no drop down boxes for a function that is standard (like the OnDraw or PreTranslateMessage). You select what it is from the drop down box (it is labeled bool) check a few boxes and hope you types in the variables right. That is it. Nothing like the Visual C++ 6.0.

Unless I am missing something (and I am pretty sure I am) this program is only for experts.
 
[lol] Yeah it took me a while to find it [lol] i'm still laughing about that.

So in your Class View right click the class and at the bottom of the context menu choose Properties.

Now in the Properties View directly below the combobox there is a bar of icons. Use the tool tips and click the one that says Overrides. In that list you will find PreTranslateMessage
Once you get used to it Visual Studio .NET rocks! [cheers]

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top