Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Graphics question on Excel VBA UserForm

Hello newsgroup,

I got to this group from the public German Excel group, where my
question could not be answered. I hope this is the correct place. :-)

This is my situation:
I have an Excel UserForm where I display a low-resolution image. After a
user click on the image, I want the picture to "zoom in", i.e. I want to
replace the low-resolution image with a small portion of a
high-resolution image showing more details.

Any hints on how this can be achieved with some API function?

Thank you very much!
Jens
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Graphics question on Excel VBA UserForm


Hi Jens

One way is to use a control that has a Zoom property AND acepts images
eg a Frame. Just load in your high def image and use the Frames Zoom
property.
If you have a number of pictures, then I would use an Image control to
store these.


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...fo&userid=1954
View this thread: http://www.excelforum.com/showthread...hreadid=387744

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Graphics question on Excel VBA UserForm


.... api's not needed

but you'll need to put the image in a frame to get the "panning"
mechanism that forms.imagecontrol doesnt have.

you'll only load the large hires picture but control the size of the
imagecontrol. (sizemode must be set to zoom)


Could keep the scrollbars hidden and manipulate the scrolltop.left/ etc
with a few buttons.

Private Sub UserForm_Initialize()
With Me.Frame1
.ScrollBars = fmScrollBarsNone
.KeepScrollBarsVisible = fmScrollBarsNone
End With
With Me.Image1
.Top = 0
.Left = 0
.Height = Me.Frame1.InsideHeight
.Width = Me.Frame1.InsideWidth
.PictureSizeMode = fmPictureSizeModeZoom
End With
End Sub

Private Sub Image1_Click()
With Me.Frame1
If .ScrollBars = fmScrollBarsNone Then
.ScrollBars = fmScrollBarsBoth

Me.Image1.AutoSize = True
.ScrollHeight = Image1.Height
.ScrollWidth = Image1.Width
Else
.ScrollTop = 0
.ScrollLeft = 0
.ScrollWidth = .Width
.ScrollHeight = .Height
.ScrollBars = fmScrollBarsNone

Me.Image1.AutoSize = False
Me.Image1.Height = .InsideHeight
Me.Image1.Width = .InsideWidth
End If
End With
End Sub







--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jens Meier wrote :

Hello newsgroup,

I got to this group from the public German Excel group, where my
question could not be answered. I hope this is the correct place. :-)

This is my situation:
I have an Excel UserForm where I display a low-resolution image.
After a user click on the image, I want the picture to "zoom in",
i.e. I want to replace the low-resolution image with a small portion
of a high-resolution image showing more details.

Any hints on how this can be achieved with some API function?

Thank you very much!
Jens

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Graphics question on Excel VBA UserForm

keepITcool schrieb:
... api's not needed

but you'll need to put the image in a frame to get the "panning"
mechanism that forms.imagecontrol doesnt have.

you'll only load the large hires picture but control the size of the
imagecontrol. (sizemode must be set to zoom)

Could keep the scrollbars hidden and manipulate the scrolltop.left/ etc
with a few buttons.


Hi keepITcool,

thanks a lot for your reply. I guess this is a really helpful approach.
But unfortunately I was unable to fully understand what your code does.

Here is what I did: I created a UserForm with a Form and an Image object
inside the Form. Then I loaded a picture (the supposed low-resolution
image) into the Image. After showing the userform, the image filled the
whole frame, and on clicking the image, it resized to its original size
(no stretch).

At this point I got stuck. How can I reach that on clicking the image
the high-res image is loaded and zoomed/panned to the right spot?
Actually, only panning the high-res image would be enough.
I tried to play with the ScrollWidth/Height/Top/Left properties, but
could not see any effect on the behaviour of the userform.

As I think we got quite close to the thing (I've been searching for
quite a while now...), I would really appreciate further help!
Thank you,
Jens
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Graphics question on Excel VBA UserForm

as I said..

you load the hires picture (which initially is shown as a thumbnail.)

IF you want to actually swap hires and lores pictures
(reread from disk) you must include some code to do that.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jens Meier wrote :

keepITcool schrieb:
... api's not needed

but you'll need to put the image in a frame to get the "panning"
mechanism that forms.imagecontrol doesnt have.

you'll only load the large hires picture but control the size of the
imagecontrol. (sizemode must be set to zoom)
Could keep the scrollbars hidden and manipulate the scrolltop.left/
etc with a few buttons.


Hi keepITcool,

thanks a lot for your reply. I guess this is a really helpful
approach. But unfortunately I was unable to fully understand what
your code does.

Here is what I did: I created a UserForm with a Form and an Image
object inside the Form. Then I loaded a picture (the supposed
low-resolution image) into the Image. After showing the userform, the
image filled the whole frame, and on clicking the image, it resized
to its original size (no stretch).

At this point I got stuck. How can I reach that on clicking the image
the high-res image is loaded and zoomed/panned to the right spot?
Actually, only panning the high-res image would be enough. I tried
to play with the ScrollWidth/Height/Top/Left properties, but could
not see any effect on the behaviour of the userform.

As I think we got quite close to the thing (I've been searching for
quite a while now...), I would really appreciate further help! Thank
you, Jens



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Graphics question on Excel VBA UserForm

keepITcool schrieb:
as I said..

you load the hires picture (which initially is shown as a thumbnail.)

IF you want to actually swap hires and lores pictures
(reread from disk) you must include some code to do that.


OK,

that's clear to me - the high-res picture is shown as a thumbnail.

But on the event of clicking the image, how can I possibly pan it to be
centered on the mouseclick position?? And zoomed in?
I played around with ScrollWidth/Height/..., but got no results...

Thanks again,
Jens
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Graphics question on Excel VBA UserForm


remove the image_click replace with

Private Sub Image1_MouseUp(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Dim f#
With Me.Frame1
If .ScrollBars = fmScrollBarsNone Then
.ScrollBars = fmScrollBarsBoth
Me.Image1.AutoSize = True
.ScrollHeight = Image1.Height
.ScrollWidth = Image1.Width

f = (Image1.Height / .Height)
.ScrollTop = (y - .Top) * f
.ScrollLeft = (x - .Left) * f

Else
.ScrollTop = 0
.ScrollLeft = 0
.ScrollWidth = .Width
.ScrollHeight = .Height
.ScrollBars = fmScrollBarsNone

Me.Image1.AutoSize = False
Me.Image1.Height = .InsideHeight
Me.Image1.Width = .InsideWidth
End If
End With
End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jens Meier wrote :

keepITcool schrieb:
as I said..

you load the hires picture (which initially is shown as a
thumbnail.)

IF you want to actually swap hires and lores pictures
(reread from disk) you must include some code to do that.


OK,

that's clear to me - the high-res picture is shown as a thumbnail.

But on the event of clicking the image, how can I possibly pan it to
be centered on the mouseclick position?? And zoomed in?
I played around with ScrollWidth/Height/..., but got no results...

Thanks again,
Jens

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Graphics question on Excel VBA UserForm

keepITcool,

thanks a lot for your help.

I still have to do some testing, I am currently inserting your code into
my (far more complex) program.
But this seems to do what I was looking for!

Thank you again!
Jens
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Graphics question on Excel VBA UserForm

Jens Meier schrieb:
thanks a lot for your help.

I still have to do some testing, I am currently inserting your code into
my (far more complex) program.
But this seems to do what I was looking for!


I've fully integrated the code into the existing program now, I've added
some additional features (such as panning the image, switching between
different resolution because Excel doesn't render large images well,
etc.) and it works perfectly!

So thank you again!
Jens
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Graphics question on Excel VBA UserForm

glad to have helped :)

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jens Meier wrote :

Jens Meier schrieb:
thanks a lot for your help.

I still have to do some testing, I am currently inserting your code
into my (far more complex) program. But this seems to do what I
was looking for!


I've fully integrated the code into the existing program now, I've
added some additional features (such as panning the image, switching
between different resolution because Excel doesn't render large
images well, etc.) and it works perfectly!

So thank you again!
Jens

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel graphics Berrybrook New Users to Excel 4 October 14th 09 04:39 PM
API graphics question Mike510 Excel Programming 2 January 3rd 05 12:37 PM
Excel VBA question - showing userform when opening workbook ajliaks Excel Programming 2 April 12th 04 06:24 PM
Excel VBA - Graphics Bourbon[_3_] Excel Programming 0 January 8th 04 08:40 PM
An Interesting Excel UserForm Question DennisE Excel Programming 1 December 25th 03 07:22 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"