473,395 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How can I stretch picture to fit an option botton

Kabyr
29
I have a form in my application where options are displayed to the user in form of images.

I have created list of option buttons, set style to graphics and able to load pictures. My problem is that some pictures are either too big or too small to fit in the option boxes.

Can somebody help me on how to stretch the picture to fit the option box? just like in image box.

Thank you in advance.
Aug 19 '10 #1

✓ answered by Guido Geurs

can also without clipboard=

Expand|Select|Wrap|Line Numbers
  1.    With Picture1
  2.       .Width = 1200 'change the size of the image canvas => picture in the optionbutton
  3.       .Height = 1200 'change the size of the image canvas => picture in the optionbutton
  4.       .AutoRedraw = True
  5.       .PaintPicture oPic, 0, 0, 900, 900 'change the size of the image
  6.       Option1.Picture = .Image
  7.    End With

3 1636
Guido Geurs
767 Expert 512MB
the idea is to load the file in a picture var, resise it in a (invisible) picturebox, put the image in the clipboard and put the clipboard in the option button with=

You can change the size by changing paintpicture of picture1 AND the size of picture1.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim oPic As StdPicture
  3.    On Error GoTo Error_Open_File
  4.    With CommonDialog1
  5.       .CancelError = True
  6.       .Filter = "GIF (*.gif)|*.gif|JPG (*.jpg)|*.jpg|BMP (*.bmp)|*.bmp|JPEG (*.JPEG)|*.JPEG"
  7.       .InitDir = Environ$("USERPROFILE") & "\My Documents"
  8.       .DialogTitle = "Open a file..."
  9.       .ShowOpen
  10.       Set oPic = LoadPicture(.FileName)
  11.    End With
  12.    On Error GoTo Error_Open_File
  13.    With Picture1
  14.       .Width = 1200 'change the size of the image canvas => picture in the optionbutton
  15.       .Height = 1200 'change the size of the image canvas => picture in the optionbutton
  16.       .AutoRedraw = True
  17.       .PaintPicture oPic, 0, 0, 900, 900 'change the size of the image
  18.        Clipboard.Clear
  19.       Clipboard.SetData .Image, vbCFBitmap
  20.    End With
  21.    Option1.Picture = Clipboard.GetData(vbCFBitmap)
  22.    Option1.Refresh
  23. Exit Sub
  24. Error_Open_File:
  25.    MsgBox "There is an error opening the file"
  26. End Sub
  27.  
Aug 22 '10 #2
Guido Geurs
767 Expert 512MB
can also without clipboard=

Expand|Select|Wrap|Line Numbers
  1.    With Picture1
  2.       .Width = 1200 'change the size of the image canvas => picture in the optionbutton
  3.       .Height = 1200 'change the size of the image canvas => picture in the optionbutton
  4.       .AutoRedraw = True
  5.       .PaintPicture oPic, 0, 0, 900, 900 'change the size of the image
  6.       Option1.Picture = .Image
  7.    End With
Aug 22 '10 #3
Kabyr
29
Thanky ou GGEU for your brilliant idea. It was greately helpful.

I chose to apply the image directly without using the clipboard. That reduced the process time.

However, both procedures worked well.

Thank you once again and to all purus here. Happy coding.
Aug 29 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jeff | last post by:
Hiya, Im currently in the process of developing a picture browser, I want it to run off a CD, basically I have 2 questions for the group. The first is how do I get the program to only view the...
2
by: Sandra Setz | last post by:
Hi, I was wondering if someone could explain to me what the difference is between the width propery of the picture property of an image and the width property of the image itself. I would...
3
by: sangeeth | last post by:
Hi all, Is it possible to fire an event using Javascript which is equivalent to right-click --> show picture in IE. Please help me.. thanks sangeeth
0
by: Alfred | last post by:
Hi I am using following code to send email How can I use the .body or .htmlbody to insert a picture in the body of ms outlook. Outlook makes provision for sending pictures. If you are in the...
14
by: hamil | last post by:
I am trying to display an image in a picture box. The image is a group 4 fax black and white image of a piece of sheet music. The original resolution is 300 X 300 dpi. I want to have the picture...
3
by: RKalai | last post by:
Hi, I am developing an application.in which i want to put the image into a picture box.i need the picture box to be displayed with fixed size but the whole picture.ie i want to know how to set the...
1
by: rajeev deep | last post by:
Hello Everyone, When I use properties window of image then one picture call easily, even no need to write the code for calling any jpg picture or bmp picture, just double click on picture option on...
1
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I want to stretch a picture set on form background. but not want to set the picture in an image box the picture must set on the form background and i don't wanrt to use image control. i...
3
by: MarwaAlSagheer | last post by:
Hi ... I have a form with a background and a picture box that displays another image , i set Backgroundimagelayout = stretch for them both, the problem that when running the application the image...
3
vdraceil
by: vdraceil | last post by:
I'm currently working on a project in vb6. I have to display icons in the form. I use DrawIcon(picturebox1.hDC,0,0,hIcon) API to draw the icon into the picture box. As image box does'nt have hDC...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.