Click here to Skip to main content
15,921,884 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ program help counting frequency of char. entered. Pin
Mark Salsbery2-Jul-08 10:51
Mark Salsbery2-Jul-08 10:51 
AnswerRe: C++ program help counting frequency of char. entered. Pin
David Crow2-Jul-08 9:51
David Crow2-Jul-08 9:51 
AnswerRe: C++ program help counting frequency of char. entered. Pin
CPallini2-Jul-08 9:59
mveCPallini2-Jul-08 9:59 
AnswerRe: C++ program help counting frequency of char. entered. Pin
Bram van Kampen2-Jul-08 12:28
Bram van Kampen2-Jul-08 12:28 
Questionabout Win32 DLL Pin
zhoogle2-Jul-08 21:42
zhoogle2-Jul-08 21:42 
AnswerRe: about Win32 DLL Pin
Iain Clarke, Warrior Programmer2-Jul-08 23:11
Iain Clarke, Warrior Programmer2-Jul-08 23:11 
GeneralRe: about Win32 DLL Pin
Bram van Kampen3-Jul-08 0:32
Bram van Kampen3-Jul-08 0:32 
Question(MFC/SDI App) Deliver the user-defined messages from MainFrame to Document Object failed... Pin
oppstp2-Jul-08 6:25
oppstp2-Jul-08 6:25 
Hello,

I am writing a program which can get the user-defind message from the specific program.
After the program get the message, the program will do post-processing.

If I do all action in MainFrame, the program can work. (I experimented this by pop-up a message window)
But if I want the message can be delivered to the document object from MainFrame,
then do post-processing in the document object, the program would fail.

The program would hang there and no response for any action. (Ex : close the program)
And at that time, the program which send the message even doesn't launch...

I have no idea to solve this problem. Does anyone can help me ?

My environment : Vista SP1, Visual Studio 2005 SP1, Platform SDK 2003 SP1
The MFC/SDI application is created by the wizard. I don't change the default class name.

Below is my code of MainFrm.h :

#pragma once   
#include "LToolDoc.h" 
#define MYWM_NOTIFYICON     (WM_USER+2)   
  
class CMainFrame : public CFrameWnd   
{   
protected: // create from serialization only   
    CMainFrame();   
    DECLARE_DYNCREATE(CMainFrame)   
// Attributes   
public:   
  
// Operations   
public:   
  
// Overrides   
public:   
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);   
    LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);   
  
// Implementation   
public:   
    virtual ~CMainFrame();   
#ifdef _DEBUG   
    virtual void AssertValid() const;   
    virtual void Dump(CDumpContext& dc) const;   
#endif   
  
protected:  // control bar embedded members   
    CStatusBar  m_wndStatusBar;   
    CToolBar    m_wndToolBar;   
  
// Generated message map functions   
protected:   
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);   
    DECLARE_MESSAGE_MAP()   
public:    
    virtual BOOL PreTranslateMessage(MSG* pMsg);   
};  

and my part code of MainFrm.cpp is

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)   
{   
    // TODO: Add your specialized code here and/or call the base class   
//  return CFrameWnd::PreTranslateMessage(pMsg);       
           
    CWnd* pWnd = AfxGetMainWnd();   
    if(pWnd == NULL)   
        return FALSE;   
  
    ASSERT_VALID(pWnd);   
    ASSERT_KINDOF(CFrameWnd, pWnd);   
    CFrameWnd* pMainFrame = static_cast<cframewnd*>(pWnd);   
  
    CFrameWnd *pActiveFrame = pMainFrame->GetActiveFrame();   
    if(pActiveFrame == NULL)   
        return FALSE;   
       
    CLToolDoc *pDoc = (CLToolDoc *)pActiveFrame->GetActiveDocument();   
  
    pDoc->TranslateMessage(pMsg);   
       
    return TRUE;   
} 

and the TranslateMessage() in LToolDoc is

void CLToolDoc::TranslateMessage(MSG* pMsg)   
{    
  if(pMsg->message == USER_DEFINED_MESSAGE_1){   
     // Do Sometheing...}   
  else if(pMsg->message == USER_DEFINED_MESSAGE_2){   
     // Do Sometheing...)}   
  else if(pMsg->message == USER_DEFINED_MESSAGE_3){   
     // Do Sometheing...)}   
  else{}   
}  

Thanks a lot !!!
QuestionRe: (MFC/SDI App) Deliver the user-defined messages from MainFrame to Document Object failed... Pin
Mark Salsbery2-Jul-08 6:31
Mark Salsbery2-Jul-08 6:31 
AnswerRe: (MFC/SDI App) Deliver the user-defined messages from MainFrame to Document Object failed... Pin
oppstp2-Jul-08 9:27
oppstp2-Jul-08 9:27 
GeneralRe: (MFC/SDI App) Deliver the user-defined messages from MainFrame to Document Object failed... Pin
Mark Salsbery2-Jul-08 10:49
Mark Salsbery2-Jul-08 10:49 
GeneralRe: (MFC/SDI App) Deliver the user-defined messages from MainFrame to Document Object failed... Pin
oppstp2-Jul-08 15:55
oppstp2-Jul-08 15:55 
QuestionSaferGetLevelInformation Fails!!! Pin
Aabid2-Jul-08 3:21
Aabid2-Jul-08 3:21 
AnswerRe: SaferGetLevelInformation Fails!!! Pin
rp_suman2-Jul-08 5:00
rp_suman2-Jul-08 5:00 
GeneralRe: SaferGetLevelInformation Fails!!! Pin
Aabid2-Jul-08 5:13
Aabid2-Jul-08 5:13 
QuestionRe: SaferGetLevelInformation Fails!!! Pin
David Crow2-Jul-08 5:22
David Crow2-Jul-08 5:22 
AnswerRe: SaferGetLevelInformation Fails!!! Pin
krmed2-Jul-08 5:23
krmed2-Jul-08 5:23 
AnswerRe: SaferGetLevelInformation Fails!!! Pin
Aabid2-Jul-08 5:31
Aabid2-Jul-08 5:31 
QuestionRe: SaferGetLevelInformation Fails!!! Pin
David Crow2-Jul-08 5:47
David Crow2-Jul-08 5:47 
GeneralRe: SaferGetLevelInformation Fails!!! Pin
krmed2-Jul-08 6:59
krmed2-Jul-08 6:59 
AnswerRe: SaferGetLevelInformation Fails!!! Pin
krmed2-Jul-08 5:22
krmed2-Jul-08 5:22 
QuestionDrawing a grayscale Icon Pin
__DanC__2-Jul-08 3:13
__DanC__2-Jul-08 3:13 
AnswerRe: Drawing a grayscale Icon Pin
KarstenK2-Jul-08 3:39
mveKarstenK2-Jul-08 3:39 
GeneralRe: Drawing a grayscale Icon Pin
__DanC__2-Jul-08 3:44
__DanC__2-Jul-08 3:44 
AnswerRe: Drawing a grayscale Icon Pin
Mark Salsbery2-Jul-08 6:53
Mark Salsbery2-Jul-08 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.