vb6: place image control on frame dynamically - image

I'm working on a new UI-element in an vb6 programm. I need to place pictures dynamically on 2 diffenent colored background lines:
I tried out two different ideas but none of them is working:
Idea 1
I used image control and assigned an image to the control. Then I set left, top, with and hight properties to values where I want to place the image. Image was places at correct position but not in foregound on a frame but in background (behind coloured frame).
Can anyone tell me how I can place an image control in foreground (on green coloured frame)? I need to place these image controlls dynamically from code in running program.
Idea 2
In second sulution I tried to use picturebox instead of image control. Picturebox can be placed on colored background (frame) without any problems.
Here the problem is that loaded picture has to be scaled to size of picturebox picture property. Picture is loaded to picturebox by following code: Picture.Picture = LoadPicture("F:\img.JPG")
Does anyone know how I can scale this img to size of picturebox?
Can anyone help me to follow up one of the solutions. In principle I would prefere to use Image controls if it is polible to place them in foreground on frame.

I'm going to guess that after creating the image control, you are moving it onto the Frame. If so, this is why the control is behind the Frame. You really want the image to be inside the frame. The key to do this is to set the Container property.
Dim img As Image
Set img = Me.Controls.Add("VB.Image", "Image1")
If Not img Is Nothing Then
img.Move 200, 200, 400, 400
img.Stretch = True
img.Picture = LoadPicture("your image.jpg")
Set img.Container = Frame1
img.Visible = True
End If

Related

How to resize image if the image is bigger than Textbox.But it not increase scale if smaller

I created RDLC report layouts by using Visual Studio Report Designer.
I need to display image on textbox.
The image was set center align by Chris Hays 's method.
But This method must set sizing to be "Clip"
So It has a problem because when Image which it was getting from database is bigger than textbox. It would clipped like below.
I tried to use sizing with "Fit Proportional" Mode. It can't set centered image by Chris Hays 's method.
But if I use sizing with "Fit to size". I can ignore centered image. But if some image is very small. It will lose quality.
What should I do if I need to
1.Centered image
2.Fit to textbox if image is bigger than textbox.
3.Original size if image is smaller that textbox.
I can resolved this problem by created two image control.
First image control -It was set sizing "Fit"
Second image control- It was set sizing "Clip" and used Chris Hays 's method for centered image.
Both two image controls was set Visibility property by expression
if a width of image is bigger than textbox , First image control will show and second will hide.
if a width of image is smaller than textbox , First image control will hide and second will show.
I can get a width of image by this code
=(System.Drawing.Image.FromStream(new System.IO.MemoryStream(CType(First(Fields!FILE_BINARY_DATA.Value, "My Table"),Byte()))).Width /96)
96 is dpi
After I known a width of image from above expression.
I will use it for set Visibility Property of First Image like these
=iif((imgWidthInch.Value > 2.6 ),false,true)
2.6 is widht of my textbox.
And Set Visibility of Second Image by the other hand.
If you're using the same sizes of the tutorial you could try and set the Sizing property by using the following expression:
=IIF(Round((3.5-System.Drawing.Image.FromStream(new System.IO.MemoryStream(CType(Fields!LargePhoto.Value,Byte()))).Width
/96)/2,2)>0, "Clip", "Fit")

Make Picturebox Transparent in Visual Basics 2010

I am a beginners so please answer me in detail so that i will be able to do it.
I am making a simple application in visual basics 2010.
I have two picture boxes in my form one is for background and another one is the object which will move... i have to make the second picture box transparent.
I have a png image to insert on that box which is of transparent background.
Please help me ..
Here, the important thing is the parent. You can load a transparent picture to the PictureBox (Note: You can load a BMP file, as well). You can define any color as transparent. See the picture.
In this project:
The parent of Panel1 is Form1.
The parent of PictureBox1 is Panel1.
The parent of PictureBox2 is PictureBox1.
The parent of PictureBox3 is Form1.
If you make PictureBox1 transparent, then you will see it is only transparent for Panel1 (which is PictureBox1's parent). In other words, you can see the Panel1's Background under the transparent color.
If you make PictureBox3 transparent, then you will see it is only transparent for Form1 (which is PictureBox3's parent). In other words, you can see the Form1's Background under the transparent color.
That's why, as much as I understand, in your project the parent of PictureBox2 should be PictureBox1. You can load (or draw) a picture for PictureBox1. Then you can load your animation picture to PictureBox2 which has a transparent color.
Please see the code below:
...
PictureBox2.BackColor = Color.Transparent
PictureBox2.Size = New Size(1042, 1474)
PictureBox2.Location = New Point(55, 0)
Dim bmp As Bitmap
bmp = (System.Drawing.Image.FromFile("empty.bmp"))
bmp.MakeTransparent(Color.FromArgb(255, 255, 255))
PictureBox2.Image = bmp
...
Hope, it helps.

Large Image Centering

I get from the server image 800X800 in jpg format and i need to display it in center of the WP7 screen. I need to display like example in this url
http://imageshack.us/photo/my-images/152/examplea.jpg/
I prefer to do this without cropping of image if it possible, because i get new image always in start of application. I tried with stretch, rectangle geometry.
I write this without code example, because this is only insert a image.
Sorry for my bad English.
Try like this in Xaml
Image name="Image" width = 800 height = 1000 stretch = fill Margin="-215,-120,-255,-184"
Then set the source

Zooming an image inside a picture box

I'm have a picture box control and 2 Command Buttons. I have an image displayed inside the picture box.
Is it possible to zoom the image when the Zoom-in and Zoom out buttons are clicked?
Or I can even put a scroll bar. Is it possible to zoom the image according to the scroll bar movements?
I'm using VB 6.
I assume here that you are using BMP or JPG files here.
The simple scratch method is to place an Image control in the PictureBox, initially with the property Stretch = False. Initially, it would be in the top left hand corner. After setting the Picture property to your picture object, the Image control will be resized to fit the image. Save the original width and height of the control in variables. Now set Stretch = True. You can zoom in by resizing the image using
img.Move 0, 0, sngWidth * sngMagFactor, sngHeight * sngMagFactor
Where sngMaxFactor = 4! or however much you want to zoom by.
Restore back to original size by:
img.Move 0, 0, sngWidth, sngHeight
You can also pan the zoomed image by altering the Left and Top arguments in the Move() method.
It might be easiest to use two pic boxes, one inside the other. The 'outer' box can be thought of as a viewport into the 'inner' box, which you resize and position as needed. The effect will be the same but the coding is much simpler.

How do you programatically change the source of an image whose name is ambiguous?

How do you say or achieve container.child.source = image.png?
I have a hexagon map built by specifying width and height. I draw a wireframe and place a base image for each hex into a canvas. Next, the canvas listens for a mouse click. I then run a calculation to determine which hex the mouse click was closest to. My intent is to change the source of the image that the user clicked on.
I know that mapSlate.getChildByName(mapProperties[closestHex]['baseName']) is the intended hex but I can't quite get to the point of doing a .source as Flex doesn't know that the selected object is an image.
If u are sure that mapSlate.getChildByName(mapProperties[closestHex]['baseName']) is the intended hex and that it is in fact an Image, can't you cast it into Image and change the source like:
Image(mapSlate.getChildByName(
mapProperties[closestHex]['baseName'])).source = "image.png";
or
(mapSlate.getChildByName(
mapProperties[closestHex]['baseName']) as Image).source = "image.png";

Resources