Scrolled Window doing crazy things [MSW] Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
Knows some wx things
Knows some wx things
Posts: 44
Joined: Fri Aug 03, 2007 8:07 pm

Scrolled Window doing crazy things [MSW]

Post by nroberts » Wed Feb 18, 2009 7:06 pm

The following is my paint function. The tracker pays attention to where scrollbars are and such and creates the transforms (used by my custom dc wrapper) needed to draw in the correct places. It works great in all cases except for one. When I use the scrollbar menu to do a "Scroll here" I get some very strange behavior.

First, my paint function is called by the scroll event processing function and draws the window correctly. Then the image drawn is shifted some X number of pixels in the direction of scroll and my paint function is called again. This time though the dc will only draw in the area that is blank after the draw shift. This causes the window to look like a cut running in the middle that copies a section and pastes it on the other side.

I have tried to set the clipping region on the dc by:


500x500 happens to be the size of the window as I test this. Had it worked I would have set to the actual client size, but it didn't do a damn thing.

I've followed the code through the wx event handling procedures until it enters windows land. Then put a breakpoint in wxWndProc at the start. The movement of the window image happens in windows land and then wx gets a refresh event (apparently clipped to the offending area).

Is there anything I can do to override the dc's unwillingness to draw on the entire window? My drawing algorithm is correct and would fix the problem if I could just draw the entire window.

Thanks for any help. Paint function follows:

Code: Select all

      void paint(wxPaintEvent &)
        wxPaintDC dc(window);

        wxPen tpen = dc.GetPen();
        wxPen pen = tpen;

        wx_drawing_context ctx(dc, tracker.transform());
        doc->get_grid()->draw_region(tracker.viewed_area(), ctx);


Knows some wx things
Knows some wx things
Posts: 44
Joined: Fri Aug 03, 2007 8:07 pm

Post by nroberts » Wed Feb 18, 2009 8:15 pm

It appears that the wxScrolledWindow does something weird when you release the thumb. This was causing the problem and others I later realized where occurring. I fixed the issue by providing a blank handler for that event.

Post Reply