Problèmes de messages

appstmd Messages postés 27 Date d'inscription mardi 31 juillet 2001 Statut Membre Dernière intervention 17 mai 2005 - 26 déc. 2003 à 10:49
appstmd Messages postés 27 Date d'inscription mardi 31 juillet 2001 Statut Membre Dernière intervention 17 mai 2005 - 28 déc. 2003 à 22:22
Salut !

J'ai créée une application SDI avec les nouvelles classes CHtmlEditView et CHtmlEditDoc pour mon architecture document/vie (j'utilise Visual C++ .Net).

Dans ma classe View dérivée de CHtmlEditView, j'ai créé les functions OnChar et OnKillFocus pour intercepter les messages WM_CHAR et WM_KILLFOCUS.

Mais ma classe (et CMainFrame) ne reçoit pas ces messages ! (et bien d'autres encore).

Comment intercepter ces genres de messages dans un tel type de document/architecture ? Y-a-t-il quelque chose à ajout de spécial dans le contrôle HtmlEdit pour recevoir ces messages ?

Merci d'avance.
Appstmd
[htp://www.appstmd.com/programs htp://www.appstmd.com/programs]

8 réponses

vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
26 déc. 2003 à 17:22
Ces messages ne sont pas interceptées par la CMainFrame et c'est normal puisque ces messages sont envoyés à la classe View
0
appstmd Messages postés 27 Date d'inscription mardi 31 juillet 2001 Statut Membre Dernière intervention 17 mai 2005
27 déc. 2003 à 02:15
Ma classe CView ne reçoit pas non plus ces messages.....

Appstmd
[htp://www.appstmd.com/programs htp://www.appstmd.com/programs]
0
appstmd Messages postés 27 Date d'inscription mardi 31 juillet 2001 Statut Membre Dernière intervention 17 mai 2005
27 déc. 2003 à 02:31
Voici le code de ma classe CMainFrame :

code:
---------------------------------------------------------------------
// MainFrm.cpp
//

#include "stdafx.h"
#include "Focus3.h"

#include "MainFrm.h"
#include ".\mainfrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_WM_CHAR()
ON_WM_KILLFOCUS()
END_MESSAGE_MAP()

static UINT indicators[] =
{
ID_SEPARATOR,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};

.....

void CMainFrame::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
AfxMessageBox ("OnChar");

CFrameWnd::OnChar(nChar, nRepCnt, nFlags);
}

...
----------------------------------------------------------------------

et de ma classe CView :

code:
----------------------------------------------------------------------

// Focus3View.cpp
//

#include "stdafx.h"
#include "Focus3.h"

#include "Focus3Doc.h"
#include "Focus3View.h"
#include ".\focus3view.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CFocus3View

IMPLEMENT_DYNCREATE(CFocus3View, CHtmlEditView)

BEGIN_MESSAGE_MAP(CFocus3View, CHtmlEditView)
// Commandes d'impression standard
ON_COMMAND(ID_FILE_PRINT, CHtmlEditView::OnFilePrint)
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_CHAR()
END_MESSAGE_MAP()

BEGIN_DHTMLEDITING_CMDMAP(CFocus3View)
DHTMLEDITING_CMD_ENTRY(ID_EDIT_COPY, IDM_COPY)
DHTMLEDITING_CMD_ENTRY(ID_EDIT_CUT, IDM_CUT)
DHTMLEDITING_CMD_ENTRY(ID_EDIT_PASTE, IDM_PASTE)
DHTMLEDITING_CMD_ENTRY(ID_EDIT_UNDO, IDM_UNDO)
END_DHTMLEDITING_CMDMAP()

......

void CFocus3View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
AfxMessageBox ("OnChar");

CHtmlEditView::OnChar(nChar, nRepCnt, nFlags);
}

----------------------------------------------------------------------
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
27 déc. 2003 à 13:21
Pour commencer moi je travaille avec visual C++ 6 et il y a CHtmlView mais pas CHtmlEditView. En tout cas moi ca marche, ma CView dérivée de CHtmlView recoit bien le message WM_KEYDOWN

Fichier sView.cpp:
// sView.cpp : implementation of the CSView class
//

#include "stdafx.h"
#include "s.h"

#include "sDoc.h"
#include "sView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSView

IMPLEMENT_DYNCREATE(CSView, CHtmlView)

BEGIN_MESSAGE_MAP(CSView, CHtmlView)
//{{AFX_MSG_MAP(CSView)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CHtmlView::OnFilePrint)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSView construction/destruction

CSView::CSView()
{
// TODO: add construction code here

}

CSView::~CSView()
{
}

BOOL CSView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
//  the CREATESTRUCT cs

return CHtmlView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CSView drawing

void CSView::OnDraw(CDC* pDC)
{
CSDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}

void CSView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();

// TODO: This code navigates to a popular spot on the web.
//  change the code to go where you'd like.
Navigate2(_T("http://www.microsoft.com/visualc/"),NULL,NULL);
}

/////////////////////////////////////////////////////////////////////////////
// CSView printing

/////////////////////////////////////////////////////////////////////////////
// CSView diagnostics

#ifdef _DEBUG
void CSView::AssertValid() const
{
CHtmlView::AssertValid();
}

void CSView::Dump(CDumpContext& dc) const
{
CHtmlView::Dump(dc);
}

CSDoc* CSView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSDoc)));
return (CSDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSView message handlers

void CSView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
// TODO: Add your message handler code here and/or call default
MessageBox("OnKeyDown");
CHtmlView::OnKeyDown(nChar, nRepCnt, nFlags);
}
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
27 déc. 2003 à 13:25
Par contre le message WM_CHAR n'est effectivement pas recu.
0
appstmd Messages postés 27 Date d'inscription mardi 31 juillet 2001 Statut Membre Dernière intervention 17 mai 2005
28 déc. 2003 à 02:25
Merci !! Et pour les messages WM_SETFOCUS et WM_KILLFOCUS ? Je n'arrive pas à les recevoir non plus, je suis vraiment embété !!!
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
28 déc. 2003 à 18:00
c'est la mainframe qui les recoit
0
appstmd Messages postés 27 Date d'inscription mardi 31 juillet 2001 Statut Membre Dernière intervention 17 mai 2005
28 déc. 2003 à 22:22
Même la MainFrame ne reçois pas ces messages. Voici mon code :

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_CHAR)
AfxMessageBox ("Pretranslate Char");
else if (pMsg->message==WM_SETFOCUS)
AfxMessageBox ("Pretranslate Setocuzs");
else if (pMsg->message==WM_KILLFOCUS)
AfxMessageBox ("Pretranslate Killocuzs");

return CFrameWnd::PreTranslateMessage(pMsg);
}



Appstmd
[htp://www.appstmd.com/programs htp://www.appstmd.com/programs]
0
Rejoignez-nous