onscroll event on form...

sitajony

Active Member
Licensed User
Hi, I don't find how can set an event on scrolling on a form...
Anyone can help me?
I know there's a scrollbar control who exists but I mean from the AutoScroll propriete on a form and not for the control...

Thanks for your replies...
 

sitajony

Active Member
Licensed User
And with onpaint event?
I tried this:
B4X:
        Form page;
        public event EventHandler Paint;
        private object[] eventObject;
        public EventBouge(Form page)
        {
            eventObject = new object[] { this, "Paint" };
            this.page = page;
            this.page.Paint += new PaintEventHandler(page_Paint);
            MessageBox.Show("fait");
        }

        void page_Paint(object sender, PaintEventArgs e)
        {
            MessageBox.Show("oook");
            Paint(eventObject, null);
            throw new NotImplementedException();
        }
But it doesn't work... Is there something wrong?
page_Paint is never run...
 

sitajony

Active Member
Licensed User
So there's really no one who can resolve this problem?
I neved used Paint graphics on a form so maybe there's something who is wrong in my code... It'll be really nice if someone replie...
 

berndgoedecke

Active Member
Licensed User
Longtime User
Do you want to scroll the Form with C or B4P?

Hello sitajony,
for scrolling with B4P I have extracted some subs from my actual project for Desktop. They need WindowMessage (from Andrew Graham) and Door or DoorEx (From Erel Uziel and Andrew Graham). It's not an executable program, it's only an extract. I hope it's helpful for you.

Sub Globals
WM_HSCROLL = 276
WM_VSCROLL = 277
frm3obj.New1(False)
hscrollobj.New1(False)
vscrollobj.New1(False)
End Sub

Sub FormEx3_Start
frm3obj.FromControl(FormEx3.ControlRef)
frm3obj.SetProperty("AutoScroll", True)
hscrollobj.value = frm3obj.GetProperty("HorizontalScroll") ' returns an HScrollProperties type
hscrollobj.SetProperty("LargeChange", 100)
vscrollobj.value = frm3obj.GetProperty("VerticalScroll") ' returns an VScrollProperties type
vscrollobj.SetProperty("LargeChange", 100)
WinMSg.New1(FormEx3.ControlRef)
WinMsg.Trap(WM_HSCROLL)
WinMsg.Trap(WM_VSCROLL)
WinMsg.Start
End Sub

Sub WinMsg_TrapEvent 'Gets the event
msg1 = WinMsg.wMsg
Select msg1
Case WM_HSCROLL
ScrX = hscrollobj.GetProperty("Value")
IScrolX.Text = ScrX
Case WM_VSCROLL
ScrY = vscrollobj.GetProperty("Value")
IScrolY.Text = ScrY
End Select
End Sub

Sub SetAutoscroll(VX, VY) 'Sets the Autoscrollposition Switch Autoscroll off, set the values and switch Autoscroll on to reset the window
frm3obj.SetProperty("AutoScroll", False)
hscrollobj.SetProperty("Value", VX) 'SetX(VX)
vscrollobj.SetProperty("Value", VY) 'SetY(VY)
frm3obj.SetProperty("AutoScroll", True)
ScrY = vscrollobj.GetProperty("Value")
IScrolY.Text = "y:" & ScrY
ScrX = hscrollobj.GetProperty("Value")
IScrolX.Text = "x:" & ScrX
End Sub

Sub FormEx3_Close
WinMsg.Stop
End Sub


best regards

berndgoedecke
 

sitajony

Active Member
Licensed User
Ho thanks, yes justely I wanted try this...
Thanks for your replie it's very helpful...
 

sitajony

Active Member
Licensed User
I've a problem... I need to assing the TrapEvent event to an unik sub function coz I've a lot of form in which I need to get the Window Message...

Apparently it doesn't work with AddEvent() and with the Event class from Door there's no way...

How can I do it?
Thanks for you replie...

Edit:
In fact apparently it doesn't work...
I tried for a test with a simple form and it doesn't call the sub function...
Maybe that it's not available for PPC this message code?
 
Last edited:

berndgoedecke

Active Member
Licensed User
Longtime User

sitajony

Active Member
Licensed User
Thanks for your second example, I changed some stuff and tried with AddEvent() and it works great:
B4X:
Sub Globals
    'Declare the global variables here.    
End Sub

Sub App_Start
    Form1.Show    
    Image1.Image = AppPath & "\F111.jpg"

    pnl1obj.New1(False)
    pnl1obj.FromControl("Form1")
    pnl1obj.SetProperty("AutoScroll", True)
    Pan1MSg.New1("Form1")
    Pan1Msg.Trap(276)
    Pan1Msg.Trap(277)
    Pan1Msg.Start
    AddEvent("Pan1Msg",TrapEvent,"tst")
End Sub

Sub tst
'Msgbox("trap")
msg1 = Pan1Msg.wMsg
        form1.Text = msg1
End Sub
Sub Form1_Close
    Pan1Msg.Stop
End Sub
So apparently I surely did a error in my code...
Thanks again!

Edit:
It works great it's good... Thanks!
 
Last edited:
Top