wxScrolledWindow repainting question Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Widgets
Super wx Problem Solver
Super wx Problem Solver
Posts: 387
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

wxScrolledWindow repainting question

Post by Widgets » Thu Nov 29, 2007 1:20 am

I have been trying for quite some time to adapt the code from sample/scroll such that I can add part of the code from sample/caret.

I have cut down the scroll sample to the bare minimum - only the dumb painting window.

My problem comes about when I try to intercept the keyboard characters so that I can manipulate the caret - the current test code does not actually create and display the caret - I've cut that code to keep it as simple as possible.

My problem is that without the OnChar function in the event table, OnDraw() is called for every down-arrow press - which is all I'm working on for the present and the display updates i.e scrolls down for each time the down-arrow is pressed.

But, if I add the OnChar function to the event table, nothing happens at all to the display. The OnChar(), NextLine() and OnDraw functions are called in sequence. The loop in OnDraw is executed, but nothing changes on the display, even though I am redrawing the complete window.

Obviously I'm missing something fundamental, but I cant see what :-(

Any hints or pointers will be greatly appreciated.

TIA
Attachments
scroll.cpp
(7.59 KiB) Downloaded 33 times
Environment: Win 10 64-bit & Mint 10.2
MSVC Express 2010, 2015, 2017, 2019
wxWidgets 3.1.2
Fight SPAM - report it with wxSR

arucard
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 28, 2004 10:16 am
Location: Czech rep.

Post by arucard » Sat Dec 01, 2007 2:31 pm

In MyScrolledWindowDumb::NextLine function, you are posting paint event to redraw window. But generating paint events is an OS-specific task. If you want to redraw your window, call Refresh() instead. This will generate paint event in the right way.
wxWidgets 2.8.4, winxp, VC2003 and above

Widgets
Super wx Problem Solver
Super wx Problem Solver
Posts: 387
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Post by Widgets » Mon Dec 03, 2007 5:43 pm

Thank you very much. That does the trick very nicely.

In the original application, I'm sure I had tried variations of this, but never seemed to get the desired results.
Environment: Win 10 64-bit & Mint 10.2
MSVC Express 2010, 2015, 2017, 2019
wxWidgets 3.1.2
Fight SPAM - report it with wxSR

Post Reply