Announcement

Collapse
No announcement yet.

InvalidateRect / UpdateWindow problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • InvalidateRect / UpdateWindow problem

    I am having trouble getting my windows updated.
    A snippet follows:

    CASE %WM_PAINT

    hDC = BeginPaint(hWnd, LpPaint)
    GetClientRect hWnd, tRect
    SetBkMode hDC, %TRANSPARENT
    SetTextColor hDC, %black
    EndPaint hWnd, LpPaint

    FUNCTION = 0
    EXIT FUNCTION

    IF NEnd>0 THEN EnableMenuItem hMenu,%IDM_NARROW,%MF_ENABLED :_
    EnableMenuItem hMenu,%IDM_REMOVE,%MF_ENABLED :_
    EnableMenuItem hMenu,%IDM_PRINT,%MF_ENABLED :_
    MENU DRAW BAR hMenu : _
    CALL invalidaterect (hWnd,BYVAL %NULL,%False) : _
    CALL updatewindow (hWnd)

    The menubar is redrawn only if I minimize the window and
    then restore it, or if I click a button in the window.


  • #2
    I qoute, from Win32.hlp: "The DrawMenuBar function redraws the menu bar of
    the specified window. If the menu bar changes after Windows has created
    the window, this function must be called to draw the changed menu bar. "

    In other words, replace InvalidateRect and UpdateWindow with:
    Code:
    CALL DrawMenuBar(hWnd)

    Comment


    • #3
      Thanks, that fixed the menu problem. Now a related problem.
      code snippet:


      CASE %WM_PAINT
      hDC = BeginPaint(hWndRect3, LpPaint)
      GetClientRect hWndRect3, tRect
      SetBkMode hDC, %TRANSPARENT
      SetTextColor hDC, %black
      DrawText hDC,BYCOPY TextW, -1, tRect, %DT_WORDBREAK OR %DT_LEFT OR %DT_vcenter
      EndPaint hWndRect3, LpPaint

      hDC = BeginPaint(hWndRect4, LpPaint)
      GetClientRect hWndRect4, tRect
      SetBkMode hDC, %TRANSPARENT
      SetTextColor hDC, %black
      DrawText hDC,BYCOPY TitleW, -1, tRect, %DT_singleline OR %DT_CENTER OR %DT_VCENTER
      EndPaint hWndRect4, LpPaint

      hDC = BeginPaint(hWnd, LpPaint)
      GetClientRect hWnd, tRect
      SetBkMode hDC, %TRANSPARENT
      SetTextColor hDC, %black
      EndPaint hWnd, LpPaint

      FUNCTION = 0
      EXIT FUNCTION

      IF NEnd=0 THEN TitleW="Noooo Records Selected" : StringZ="z" : _
      TextW=StringZ : _
      updatewindow hWndRect4


      Again, same symptoms, window not updated until minimized/
      restored, or messagebox moved over window, etc.

      the following also did not work
      CALL invalidaterect (hWnd,BYVAL %NULL,%False) : _
      CALL updatewindow (hWnd)

      Comment


      • #4
        Eureka!

        hWndRect3 & hWndRect4 are child static windows in hWnd.
        Thus, in WM_PAINT, I need to paint hWnd BEFORE hWndRect3 &
        hWndRect4. Then, I invalidate hWnd, and everything
        updates as expected.

        Comment

        Working...
        X