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

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 re-painted...you hit break point again...yada...yada..)

Also I do not call invalidate on window rect of anybody...so 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 stuff..ie...
            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....                  

Who is Participating?
PAQed with points refunded (500)

Community Support Moderator
esgiAuthor Commented:
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;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.