CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2007
    Posts
    5

    Window repaint error?

    i have a frame inside a static window inside a static window and a scrollbar.
    im usin this to make a scrolling panel, it works but...
    when i scroll it up then back down, if the frame goes above the top of the main container 'StaticLeftContainerhWnd' i get streaks of the frame.

    heres some code
    inside the main window proc in the WM_CREATE msg i have
    Code:
          ScrollbarhWnd = CreateWindowEx(0, "SCROLLBAR", NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SBS_VERT, 154, 0, 16, 240, hwnd, (HMENU)IDC_SCROLLBAR, GetModuleHandle(NULL), NULL);
          StaticLeftContainerhWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "STATIC", NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 174, 240, hwnd, (HMENU)IDC_STATICLEFTCONTAINER, GetModuleHandle(NULL), NULL);
          StaticLeftScrollhWnd = CreateWindowEx(0, "STATIC", NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SS_BLACKFRAME, 0, 0, 154, 240, StaticLeftContainerhWnd, (HMENU)IDC_STATICLEFTSCROLL, GetModuleHandle(NULL), NULL);
          FramehWnd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, "BUTTON", "Caption", WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_GROUPBOX, 2, 3, 150, 40, StaticLeftScrollhWnd, (HMENU)IDC_FRAMENAME, GetModuleHandle(NULL), NULL);
    and in the WM_SCROLL msg
    Code:
        case WM_VSCROLL:
        {
          siScrollInfo.nPos = GetScrollPos(ScrollbarhWnd, SB_CTL);
          switch (LOWORD(wParam))
          {
            case SB_LINEUP:
            {
              if (siScrollInfo.nPos > 0) {
                siScrollInfo.nPos--;
              }
              break;
            }
            case SB_LINEDOWN:
            {
              if (siScrollInfo.nPos < siScrollInfo.nMax) {
                siScrollInfo.nPos++;
              }
              break;
            }
          }
          SetWindowPos(StaticLeftScrollhWnd, 0, 0, -siScrollInfo.nPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
          SetScrollPos(ScrollbarhWnd, SB_CTL, siScrollInfo.nPos, true);
          break;
        }

    heres a screenshot to see whats actually goin on


    ive tride updatewindow() on all the hwnds including the main window
    ive tried invalidaterect() on all the hwnds including the main window

    in different orders and tryin different 1s one at a time
    i dont know whats going on, any help would be awesome

    thank you,
    chrunchy

  2. #2
    Join Date
    Oct 2007
    Posts
    178

    Re: Window repaint error?

    are you handling WM_PAINT yourself for any of the windows?

    does the same thing happen if you drag the whole window partly off of the screen?

  3. #3
    Join Date
    Nov 2007
    Posts
    5

    Re: Window repaint error?

    no im not handling wm_paint

    it only does that when i use the scrollbar to move it
    if i minimize and restore the main window the streaks are gone..until i use the scrollbar

  4. #4
    Join Date
    Nov 2007
    Posts
    5

    Re: Window repaint error?

    strange...i removed the
    WS_CLIPCHILDREN
    flag from the StaticLeftContainerhWnd createwindowex funtion and it doesnt do this anymore...
    ill have to figure out WHY cause its going to drive me crazy until i do :P
    thank you for tryin loki

  5. #5
    Join Date
    Aug 2008
    Posts
    8

    Re: Window repaint error?

    Did you ever fix this? I'm trying to draw rectangles that seem to "streak" upon scrolling in either direction. Also, the rectangles are completely redrawn when I minimize then restore the window but apparently the origin moves.

    My code to draw the rectangles is

    CRect TempRect = pDoc->GetNode(i); // The points for the rectangle
    OnPrepareDC(pDC);
    pDC->DPtoLP(&TempRect);
    pDC->Rectangle(TempRect);

    and I set the scroll bars sizes in OnInitialUpdate with

    CSize Workspace(1000, 1000);
    SetScrollSizes(MM_LOENGLISH, Workspace);

    I have tried a variety of fixes in OnPrepareDC included setting the mapping mode to MM_LOENGLISH and setting the origin at 0, 0 but nothing works.

    I'm new to visual applications and I think there must be a simple like I've seen in some "sketch" or "scribble" examples. Any help?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured