Forms - Image control size with mouse

Discuss the database features

Forms - Image control size with mouse

Postby arfgh » Sat Sep 02, 2017 2:50 pm

Here there.

I want to know for the best way to make an Image control bigger when we place the mouse over it, and back to its original size and position on mouse out.

At the moment i did it using two Image controls, the big one is hidden by default. So i use two controls to do it, but i am sure that is possible to perform the same with only one. See the fact that using two controls when we move so fast the mouse, sometimes it is messed up... that's the reason i want to see other way to do it.

thx in advance
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: Forms - Image control size with mouse

Postby arfgh » Wed Sep 06, 2017 6:45 pm

somebody ?
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: Forms - Image control size with mouse

Postby UnklDonald418 » Thu Sep 07, 2017 7:42 pm

See the fact that using two controls when we move so fast the mouse, sometimes it is messed up...

I tried this with 3 small images and 3 corresponding large images using the approach you mentioned. I've not seen any problems even when quickly sweeping the mouse across the 3 small images. My images are linked to external .jpg files.
Here is the macro code I used.

Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****
Rem This is triggered by the Mouse inside event
Sub LargeImageOn(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControlMod as object

SourceName = oEv.Source.Model.Name
oForm =  oEv.Source.Model.Parent
Select Case SourceName
   Case "SmImage01"
      oImageControlMod = oForm.getByName("LgImage01")
   Case "SmImage02"
      oImageControlMod = oForm.getByName("LgImage02")
   Case "SmImage03"
      oImageControlMod = oForm.getByName("LgImage03")
End Select

oImageControlMod.setPropertyValue("EnableVisible", TRUE)
End Sub

REM ==================================================
Rem This is triggered by the Mouse outside event
Sub LargeImageOff(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControl as object

SourceName = oEv.Source.Model.Name
oForm =  oEv.Source.Model.Parent
Select Case SourceName
   Case "SmImage01"
      oImageControlMod = oForm.getByName("LgImage01")
   Case "SmImage02"
      oImageControlMod = oForm.getByName("LgImage02")
   Case "SmImage03"
      oImageControlMod = oForm.getByName("LgImage03")
End Select
oImageControlMod.setPropertyValue("EnableVisible", FALSE)
End Sub


i use two controls to do it, but i am sure that is possible to perform the same with only one.

That would likely require a listener but setting up debugging listeners can be a painful process. Use two events.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.4 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 574
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Forms - Image control size with mouse

Postby arfgh » Sat Sep 23, 2017 10:30 pm

so it is more complex, using a single image control ?
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: Forms - Image control size with mouse

Postby UnklDonald418 » Sun Sep 24, 2017 1:34 am

Sorry, I misread what you wanted.
I looked a little closer and using the MRI tool I found that each image has an ImageURL property. Using that property it is possible to use a single large image control and the macro is actually less complex (no Select Case needed).
Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****

Sub LargeImageOn(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControlMod as object

If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
      Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
End If
oMRI = CreateUnoService( "mytools.Mri" )
'oMRI.inspect oEv
SourceName = oEv.Source.Model.Name
oForm =  oEv.Source.Model.Parent
'oMRI.inspect oForm
image = oForm.getByName(SourceName).ImageUrl
oImageControlMod = oForm.getByName("LgImage01")
oImageControlMod.setPropertyValue("ImageURL", image)
'oMRI.inspect oImageControlAMod
oImageControlMod.setPropertyValue("EnableVisible", TRUE)
End Sub

REM ==================================================
Sub LargeImageOff(oEv as object)
Dim SourceName as string
Dim oForm as object, oImageControl as object

If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
      Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
End If
oMRI = CreateUnoService( "mytools.Mri" )

oForm =  oEv.Source.Model.Parent

oImageControlMod = oForm.getByName("LgImage01")
oImageControlMod.setPropertyValue("EnableVisible", FALSE)
End Sub
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.4 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 574
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Forms - Image control size with mouse

Postby RPG » Sun Sep 24, 2017 9:45 am

Maybe this helps you? I do understand the problem is to change the size of a control.
I have the idea that OOo is not the best tool to use.

When you want use OOo then it is maybe better to use something else to use instead of a image control. I do think to: insert image and use that object. I have no idea how.

Code: Select all   Expand viewCollapse view
sub resizecontrol(oEvent)
' Start with a button
' the imagecontrol and the button must in the same data-form as you see in the form-navigator
dim oButton
'dim oImage
'ImageforResize
dim oForm
dim oControlResizeModel ' This for the model of the control
dim oControlResizeView   ' This is the view of the same control
dim oControlResizeShape   ' This is the shape of the control
' This tree different thing of the same control are explained in the BASIC guide.
' You have to read chapter 12 Forms
' We have to use two strucs
dim size as new com.sun.star.awt.Size
dim point as new com.sun.star.awt.Point




' This macro must be loaded
if not globalscope.BasicLibraries.islibraryloaded("Tools") then
   ' Load now the library
   globalscope.BasicLibraries.loadlibrary("Tools")
end if


oButton=oEvent.source.model ' Now we have the button what is pressed
oButton.toggle=true ' Buttonstate must change when clicked

select case oButton.state
case 0
   ' Place the value in strucs
   size.height=2000 ' I believe 1mm = 100
   size.width=6000
   
   point.x=800
   point.y=800
   'zorder=4

case 1
   ' Place the value in strucs
   size.height=4000 ' I believe 1mm = 100
   size.width=12000
   
   point.x=200
   point.y=200
   'zorder=4

end select


oForm= oButton.parent ' We have the form as we see in the form navigator.
'mri thisComponent.getCurrentController.getformcontroller(oForm) : end
oControlResizeModel=oForm.getbyname("ImageforResize") ' We have the model of the control
oControlResizeShape = GetControlShape(thisComponent.getCurrentController.Model ,oControlResizeModel.name)
oControlResizeShape.setSize(size)
oControlResizeShape.setPosition(point)
'mri thisComponent.getCurrentController.getcontrol(oControlResizeModel)
'call makezorder
end sub
LibreOffice 5.3.6.1 on openSUSE Leap 42.3
RPG
Volunteer
 
Posts: 2102
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Forms - Image control size with mouse

Postby arfgh » Sun Oct 08, 2017 5:21 pm

i am still trying to understand how to do it and i did this, without lucky, Result of print is 0, why ?
I want to work directly with the image control, and no with buttons. So first i want to obtain its size and point. But restult is 0.

Code: Select all   Expand viewCollapse view
   oForm = oImage.parent 'We have the form as we see in the form navigator.
   oControlResizeModel = oForm.getbyname("Image") 'We have the model of the control
   oControlResizeShape = GetControlShape(thisComponent.getCurrentController.Model ,oControlResizeModel.name)
   oControlResizeShape.getSize(size)
   print size.width
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm


Return to Base

Who is online

Users browsing this forum: salrandazzo and 8 guests