WM_PAINT - why is it being called ad infinitum????

Posted on 2005-05-10
Last Modified: 2008-02-01
I have an ATL based toolbar...

I also have a composite control with a web browser in it...
I manual create it using the window handle of the toolbar....


OK, it shows up on toolbar fine, but the thing is, I added a OnPaint handler
(note I do not NEED the OnPaint handler, I added it because of problem)

LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
bHandled = TRUE;
return 0;

And found that it was called ad infinitum....

(The reason I added OnPaint handler was because the control with embedded webbrowser was not updating properly)

Now this continual OnPaint  call is NOT the kind you get from debugging (ie you break, the window has to be hit break point again...yada...yada..)

Also I do not call invalidate on window rect of why is the OnPaint being called repeatedly???

(related to problem...)
I also have an edit box on the toolbar (also, of course, created manually)
Basically, when I enter text in text box, the browser goes "blank" and doesn't get redrawn (the browser embedded in toolbar)

To "fix" problem with edit box not receiving back space key press messages, one has to implement some ugly
            STDMETHOD(TranslateAcceleratorIO)(LPMSG lpMsg);
            STDMETHOD(UIActivateIO)(BOOL fActivate, LPMSG lpMsg);
(this is because ie steals the key press message for special keys.....)

I found that if I commented out the TranslateAcceleratorIO code...the browser problem disappeared....but I need to capture backspace keys.....

void CEditQuery::TranslateAcceleratorIO(LPMSG lpMsg)

      int nVirtKey = (int)(lpMsg->wParam);

      if (VK_RETURN == nVirtKey)
            // remove system beep on enter key by setting key code to 0
            lpMsg->wParam = 0;
            ::PostMessage(::GetParent(GetParent()), OCM_COMMAND, MAKEWPARAM(idSearch, 0), 0L);                            }

      TranslateMessage(lpMsg);  <<-----    if I comment these two lines...browser problem disappears...   :-(
      DispatchMessage(lpMsg);   <--------   now I can' t deal with backspaces though....                  

Question by:esgi

    Author Comment

    here's answer

    LRESULT CMyToolBar::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
          CRect r;
                    {compute rect where browser is}

          DefWindowProc(uMsg, wParam, lParam);
          return 0;

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Doc'in system (example?) BA 7 63
    tenRun challenge 28 67
    scoresAverage challenge 8 58
    VBA color chart bars 12 50
    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    This is an explanation of a simple data model to help parse a JSON feed
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now