Problem in message handling
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Problem in message handling

  1. #1
    Join Date
    Mar 2005
    Posts
    3

    Arrow Problem in message handling

    Hello friends,
    First off, please check below code. Well, I am developing printing functionality from the windows mobile device using vc++. (I am novice to the vc++ ). For printing, we are using third party DLLs. Below are important snippet required to explain the complete picture. Currently, the problem I am more concerning is printing multiple pages. For this, we have API and everything. While printing using “mpPreviewDialog” API (provided by third party in form of DLL) and when it recognize more than one pages required, it raises/passes “MP_EVENT_REQ_NEW_PAGE” message from printing library, ie mpPreviewDialog itself, to the handle hWnd of “mpPreviewDialog(hWnd,__)”. Now, to handle this message, we have put all logic portion in one class which is inherited from CWnd so that we can override “DefWindowProc” function to achieve our goal. But while I run the application and command print for multiple page, it only prints the first page perfectly and then just get hanged. Thus, it fails to handle the “MP_EVENT_REQ_NEW_PAGE” message of “DefWindowProc” function. What all I need is to handle this message and execute the case MP_EVENT_REQ_NEW_PAGE: while printing and multiple page required. Because in this case it issues the message but appropriate case never get executed. I hope you got my point. Please let me know how to solve this. Am I missing something? Thank you very much for your time in advance.
    Code:
    class CFxPrinterWnd : public CWnd
    {
    	DECLARE_DYNCREATE(CFxPrinterWnd)
    
    public:
    	CFxPrinterWnd();           // protected constructor used by dynamic creation
    	virtual ~CFxPrinterWnd();
    
    public:
    #ifdef _DEBUG
    	virtual void AssertValid() const;
    #ifndef _WIN32_WCE
    	virtual void Dump(CDumpContext& dc) const;
    #endif
    #endif
    
    protected:
    	DECLARE_MESSAGE_MAP()
    public:
    	int PrintReport(HWND hwnd, int flg);
    protected:
    	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
    };
    
    Int CFxPrinterWnd::PrintReport (HWND hWnd, int flg)
    {
                    _______
    
    	This contains “mpPreviewDialog” API call which starts printing and issue “MP_EVENT_REQ_NEW_PAGE” message if more than one page required.
    }
    
    LRESULT CFxPrinterWnd::DefWindowProc(___,___,___)
    {
                    Switch (message)
                    {
                                    ___
    
                                    Case MP_EVENT_REQ_NEW_PAGE:       //This debug point never get focused while printing and new page required.
                                                    ___This point is never get executed
                                                    ___
                    }
    }
    
    Button1 Click Event
    {
                    hWnd = ::FindWindow(NULL, _T(“del”));
                    CFxPrinterWnd wnd;
                    Wnd.Create(_______________________);
                    Ret = wnd.PrintReport(hWnd, 0);
                    ___
                    ___
                    mpPreviewDialog (hWnd____);                //This is the printing API where MP_EVENT_REQ_NEW_PAGE message get raised while printing if new page            
                                                                                                    //required.
                    wnd.DestroyWindow();
    }
    ---
    Kind Regards,
    Sachin Patel
    Last edited by Andreas Masur; January 10th, 2009 at 09:07 AM. Reason: Added code tags...

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,274

    Re: Problem in message handling

    Quote Originally Posted by 02mca31 View Post
    Hello friends,
    First off, please check below code. ...
    You should edit your post adding Code tags around your code snippet. Otherwise the code is unreadable.
    Check out the Announcement: Before you post....
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center