Help! Newbie to MS Visual C++.NET has Class Wizard problem

R

raylopez99

Hi all,

I'm just a hobbiest but I have a question on Microsoft Visual Studio
C++.NET 2002 version 1.0; I think there's a bug in 'manually' entering
a member function.

First of all, unlike the previous verison of Visual Studio C++ 6 from a
few years ago, I cannot find (or don't have) the button to use the
"Class Wizard" to add a member function from the MFC. (Instead, I get a
Wizard for Generic C++ class, for ATL, and for a MFC class in four
flavors: Class, ActiveX, TypeLib and ODBC Consumer))

Therefore I must add a MFC class (from the library, such as
"OnRButtonDown"), "manually", by adding a definition/declaration in the
header and source files.

This is a problem because now, though the program compiles, it seems
like the 'manually added' function is not recognized. But from the
"Properties" window it appears that it is recognized as a MFC
CMainFrame VCCodeClass function (in the example below,
"CMainFrame::OnRButtonDown" was added 'manually' but not (seemingly)
recognized.

Anybody else have this problem?

Might be specific to 2002 Visual Studio, not 2003.

RL


PS--in the below code snippet, I can get a MessageBox to pop up by left
clicking the mouse but never by right clicking the mouse. Since the
program does not appear to have any bugs, and is otherwise symmetrical,
I assume it's a problem with MFC "recognizing" that what I call
"OnRButtonDown" is from the library <afxwin.h> and not my own version.




////////////////////////

// MainFrame.h
#include <afxwin.h>

class CMainFrame : public CFrameWnd
{
private:
CString mStr;
CPoint mPt;


public:
CMainFrame(); // Constructor

// window msg handling function
afx_msg void OnPaint();
afx_msg void OnChar (UINT nChar, UINT nRep, UINT nFlags);
afx_msg void OnLButtonDown (UINT nFlags, CPoint pt); // THIS WORKS
(runtime)
afx_msg void OnRButtonDown(UINT nFlags, CPoint pt); // THIS DOES NOT
EVER GET CALLED (runtime)
DECLARE_MESSAGE_MAP();
};



///////////////////////////////////////////////////////////////////////
// MainFrame.cpp
#include "MainFrame.h"

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
// message calls this function
ON_WM_PAINT() // void OnPaint()
ON_WM_CHAR() // void OnChar (UINT nChar, UINT nRep, UINT
nFlags)
ON_WM_LBUTTONDOWN() // void OnLButtonDown (UINT nFlags, CPoint pt)
END_MESSAGE_MAP()

CMainFrame::CMainFrame() // Constructor
{
Create(NULL,"Ex04b Left Click then Type Characters",
WS_OVERLAPPEDWINDOW, CRect(20,30,350,140));

mStr = "Hi!";
mPt = CPoint(5, 10);

};

void CMainFrame::OnPaint()
{
CPaintDC dc(this);
dc.TextOut (mPt.x, mPt.y, mStr);
}

void CMainFrame::OnChar (UINT nChar, UINT nRep, UINT nFlags)
{
CString str;
str.Format(" %c Ascii code: %d ", nChar, nChar);
SetWindowText(str);

mStr = mStr + (char)nChar; // append char to mStr

Invalidate (TRUE); // Display method 2
}

////////// THIS WORKS - OnLButtonDown //////////

void CMainFrame::OnLButtonDown (UINT nFlags, CPoint pt)
{
mStr = ""; // Begin with new string
mPt = pt; // at this new coordinate position
MessageBox("Hows it going LEFT BUTTON", "AGreeting", MB_ICONQUESTION);
}

////////// THIS DOES NOT WORK (compiled but never gets called despite
clicking on right mouse button) - OnRButtonDown //////////

void CMainFrame::OnRButtonDown(UINT nChar, CPoint pt)
{
mStr = ""; // Begin with new string
mPt = pt; // at this new coordinate position

MessageBox("Hows it going Right button click??!!!", "AGreeting",
MB_ICONQUESTION);

}
/////////////////////////
 
S

Stephen Howe

I'm just a hobbiest but I have a question on Microsoft Visual Studio
C++.NET 2002 version 1.0; I think there's a bug in 'manually' entering
a member function.

I will stop you here.
You want to configure your newsreader so that it knows of the Microsoft news
server:
msnews.microsoft.com
and subscribe to newsgroups

You will find 6 newsgroups devoted to Visual Studio, 22 newsgroups devoted
to Visual C/C++ etc. They all begin
microsoft.public.*

Post to comp.lang.c++ when you want help with standard C++ language or
library (or you suspect that your compiler is deficient and want to check if
your code is standard C++). comp.lang.c++ does not care about _particular_
compilers etc.

DONT post here if it is compiler-specific problem, compiler switches, linker
switches, Windows problem, hardware problem, device problem (like keyboard,
mouse, USB, screen, sockets).

Stephen Howe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top