Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Window not scrolling
Window not scrolling [message #43028] |
Thu, 24 April 2014 13:34  |
SkuldOMG
Messages: 2 Registered: April 2014
|
Junior Member |
|
|
I'm currently writing a windows application using the U++ IDE. One window that is used for data entry contains more fields to be displayed than can be fit into a single screen, so I wanted to add a scrollbar to my window. So far, so good, I looked up the ScrollBar example on the U++ page and tried to implement it in my application. My problem is - it just doesn't scroll. I suspect that it has to do with my application having multiple windows, but I'm not sure. Here's how my application is structured:
GUI_APP_MAIN {
MainWindow app;
...
app.Run();
}
struct MainWindow : TopWindow {
PatientFrame dlg;
...
// Opens window that displays a patient overview
void new_patient() {
...
dlg.Execute();
}
...
struct PatientFrame : TopWindow {
ProcessFrame proc;
...
// Opens the window that should have a scrollbar
void new_process() {
...
proc.Execute();
}
}
struct ProcessFrame : TopWindow {
...
// Nearly 1:1 from the example
ScrollBar sb;
virtual void Layout() {
sb.SetPage(GetSize().cy);
}
virtual void MouseWheel(Point, int zdelta, dword) {
sb.Wheel(zdelta);
}
bool Key(dword key, int) {
return sb.VertKey(key);
}
// n is the number of entryfields I have, each entryfield is 21 pixels high
void SetCount(int n) {
sb.SetTotal(n * 21);
}
void Scroll() {
Refresh();
}
void buildList() {
// Constructs the contents of the window
...
// Sets the size for the scrollbar
SetCount(count);
}
...
typedef ProcessFrame CLASSNAME;
ProcessFrame() {
SetRect(0, 0, 720, 435);
Title("Process Frame").Sizeable().Zoomable();
...
AddFrame(sb);
sb.WhenScroll = THISBACK(Scroll);
sb.SetLine(21);
}
}
Now the scrollbar itself displays just fine. Also its size seems to be set correctly, since when I resize the window to be smaller, the scrollbar adjusts itself, same thing when I resize it bigger. I also tried playing around with the size of one line, again, the scrollbar adjusts just fine. The only problem is, it does not actually scroll the view area.
Any help would be appreciated.
|
|
|
Re: Window not scrolling [message #43035 is a reply to message #43028] |
Fri, 25 April 2014 00:59   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi SkuldOMG,
there is a package in bazaar called AutoScroller that do automatic scrolling of a panel inside another Ctrl. give it a try, usage example is in AutoScrollerTest.
regards
omari.
regards
omari.
|
|
|
Re: Window not scrolling [message #43135 is a reply to message #43028] |
Thu, 15 May 2014 13:35   |
SkuldOMG
Messages: 2 Registered: April 2014
|
Junior Member |
|
|
Thanks for your answer!
I've got it nearly working, only I can't seem to find the proper way to add the current view to the scroller. In my process frame constructor I call at the very end:
Size sz = GetSize();
sc.EnableScroll();
Add(sc.SizePos());
sc.AddPane(this);
However this gives me the error error C2664: 'AutoScroller<C>::AddPane' : cannot convert parameter 1 from 'ProcessFrame *const ' to 'Upp::Ctrl &'.
EDIT:
When I try to call it via a function that returns a Ctrl & (such as sc.AddPane(Title("Progress Form"))), I end up getting a stack overflow in Ctrl::CancelModeDeep() when starting the program.
I also tried sc.AddPane(*GetParent()), which will lead to an "Assertion failed" error in CtrlChild.cpp.
[Updated on: Thu, 15 May 2014 13:49] Report message to a moderator
|
|
|
Re: Window not scrolling [message #43136 is a reply to message #43135] |
Thu, 15 May 2014 17:35  |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi,
probably you try to add a Ctrl to his child.
this is another example that use AutoScroller, without .lay file
hope it help:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#include <AutoScroller/AutoScroller.hpp>
class AView : public ParentCtrl
{
DocEdit doc0, doc1, doc3, doc2;
public:
AView()
{
SetRect(0, 0, 500, 600);
Add(doc0.LeftPosZ(12, 68).TopPosZ(12, 44));
Add(doc1.LeftPosZ(12, 164).BottomPosZ(12, 176));
Add(doc2.RightPosZ(16, 176).TopPosZ(16, 92));
Add(doc3.RightPosZ(12, 176).BottomPosZ(12, 92));
}
};
class AScroller : public TopWindow
{
AView v;
AutoScroller<ParentCtrl> sc;
public:
AScroller()
{
Sizeable().Zoomable();
SetRect(0, 0, 200, 300);
sc.EnableScroll();
sc.AddPane(v);
Add(sc.SizePos());
}
};
GUI_APP_MAIN
{
AScroller().Run();
}
regards
omari.
[Updated on: Thu, 15 May 2014 19:15] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Apr 26 22:13:29 CEST 2025
Total time taken to generate the page: 0.00768 seconds
|