Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Picture Sizing To Fit Screen

I have various picture sizes 800x600, 640x480... is there a way to shrink and expand them automatically to fit the image box I create on a form?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Form Sizing Vs. Screen Sizing
I wanted to know if there is some sort of AutoScaleMode for VB 6.0 for forms and controls? I am having trouble running my program on a smaller screen of resolution 800 x 600. I am currently working on 1024 x 768 resolution.

Sizing For Different Screen Sizes
Is there any system variable that will tell me the size of the screen that is being used to view an application.

If I have a 19" screen and develop my application for that screen, what happens when I distribute the application and the user has a 15" screen.

Is there a way to make sizing of forms and controls on the forms dynamic, without allowing the user to do the resizing?

Sizing A Flexgrid To Fit The Screen
I was wondering if anyone knows how to make the flexgrid increas in size with the window if you hit the maximize button. i haven't figured out what property it would be....

Sizing A Form To Fit Different Screen Settings
I have created my main form for the application, however, since am using a computer screen setting of 800 by 600 pixels, it displays fine but when I tried it on a screen of 1024 by 768 pixels, it looked so bad coz of extra space created.

How can I ensure that my form opens while maximised to fit the whole screen and that irrespective of the scrren settings, the display remains the same?

Form Sizing To Fit Within A Given Screen Size
I have an application whose main form is centred on the screen and barely fits at the top and bottom on a screen resolution of 1024 X 1268. Though things fit and look fine at this resolution (on a large monitor to boot) I know that in order for this application to be transferable it must be able to display on smaller monitors and coarser resolutions.

My question is this: Where in the project's code would you put the code that finds the screen dimensions of the monitor the App is being loaded up on, at the display resolution the user is operating on?

Is it just as simple as giving a minimum distance (in twips) from the screen height to the form height and one for the difference from the bottom of the screen to the bottom of the form? Where does one look to find the Property "Screen.Height"?

Re-Sizing A Form To The Screen Dimensions
Just a quick question here. I know that various users have their screen dimensions (resolutions) set to different levels. If I create an application in one resolution but it ends up on another it is going to turn out to be smaller or bigger depending upon the user's setup. How can I code for this occurrence so that when my form loads on anybody's machine it takes up the same screen space as it did on the development system?

Sizing A Form To Fit Different Screen Settings
I have created my main form for the application, however, since am using a computer screen setting of 800 by 600 pixels, it displays fine but when I tried it on a screen of 1024 by 768 pixels, it looked so bad coz of extra space created.

How can I ensure that my form opens while maximised to fit the whole screen and that irrespective of the scrren settings, the display remains the same?

Sizing The Picture
Does anyone have any idea how to resize a .jpg file and save it using VB.

For example: You have a .jpg file, size 800x600 and you want to make a thumbnail (small image) of size 80x60.

Thanx, Slither

Picture Sizing
Hi guys!
I looked over previous threads about pictures, but i didn't find what i want. Here is my problem:
I have done a very simple pictures viewer. Each time the command is clicked, a new picture is loaded in the Image box (not picturebox). To make it easy, I set the stretch property to True. Like this, whatever is the size of my picture, it fits properly in the box of my window. The problem is that some of my pictures are not in landscape orientation but portrait !! So, because of the stretch property, there is a very bad ratio for the picture size.... and Grandma looks like a fat cow !

What can I do to keep initial ratio of pictures? Or to detect orientation property of pictures?

Thank you

Picture Box Sizing

is there any code that we can small the picture and the resulotion is kept? and we can put it on a standard size picture box, I want to have a review of a big picture, like making a thumbnail size.

thanks for your help

Picture Sizing && Save JPG
I need a new stdpicture as sized

Dim pic as New StdPicture
pic.Width = 32
pic.Height = 32

this appears error
"Object does not support this method"

I need corrected this code or similar


I need save a picture as jpeg, gif, and other formats

Capture Entire Picture Of Picture Box Though Picture Exceeds Screen Height
please give me details how to capture entire portion of picture in a picture box control though the picture height is greater than the screen height.

Help With Sizing Picture In Picture Box
a user enters the directory and extension that
then in turn loads the images into an array.
if the image width and height are larger than the
picture box, how can i resize the image to fit into
the picture box without becoming distorted?
i prefer not to use the image control in this situation.

i have tried to use the scalewidth and scaleheight of the
picture box, but can't seem to get it right,
any suggestions to point me in right direction?

thanks in advance,

'loop through the directory to find only the files
'that the user chose by extension and load them into
'an array
For Each MyFile In MyFolder.Files
If Mid$(MyFile.Name, Len(MyFile.Name) - 3) = Mid(sExt, 2, 4) Then
'e.g. Mid(sExt, 2, 4) = jpg
ReDim Preserve pics(iX)
pics(iX) = MyFolder & "" & MyFile.Name
iX = iX + 1
End If
Next MyFile

'loop through all the images that were found by
'extension chosen and show them in the picure box
'according to the time chosen by user for interval
'between each image.
For iX = LBound(pics()) To UBound(pics())
Set Picture1.Picture = LoadPicture(pics(iX))

Sleep (lTime)

How Do You Print Screen Then Load That Picture Into The Form.picture Property?
This is something that I've been trying to do for ages, but I've never had any success- Does anyone know how to print screen with code and then load that picture onto a form? I've got most of my program written, but I can't figure how to load a picture from the clipboard onto my form. I have a SendKeys to send a print screen keypress, but I don't know if it works properly. Can anyone help me?

Now, don't get me wrong, 'cause baseball's a great sport.
It teaches little children simple eye-hand coordination with little effort or exhaustion.


Screen Picture
I'm trying to get a screen picture (like PrintScreen) and save it to a file. Does anyone have any examples or anything like that?

How Do I Keep A Picture In The Screen.
When I use the stretch feature of an image box, if a picture is too big, it will only show part of that picture in the screen. What can I do to make the picture appear fully inside of the screen.

Take A Copy Of The Screen Picture
I want to take a copy of the screen (entire picture from the monitor). Then shrink to 25% and send to an other computer. I know how to shrink the picture and how to send/receive it, but how to take screen-copy from VB?

I do not want to go through clipboard. Better to go directly to VB.

Grabbing A Picture Out Of The Screen
As you may or may not know, when Autoredrew is set to False, APIs draw on the screen, not in the .Image or .Picture property. Is there any way to nab this picture?

Keeping The Picture Across The Screen
i have this program where i want a picture to start at the right of the screen and go to the left and off the screen, once it is off i want it to come back from the right, can any one help?

Picture In Centre Of Screen
Helle Folks,

As a new member I've made a screensaver, but the only thing I would like to know:

How do I get the pictures with different heigth and length always in the centre of the screen? This must be independent from the screenresolution I use.

Greetings Hans

BltBlk The Controls In A Off Screen Picture Box
Hi everyone,

I've tried all manner of combinations of auto draw and visibility and cant BltBlk controls inside an offscreen picture box.

What I need to do is create a form with a picture box which has a user control in it and some labels, this form is offscreen and I need to BltBlk the picture box to a form on screen. But having changed all the auto draw properties it only works when the offscreen form isnt offscreen. I can however BltBlk the picture when its offscreen but not the controls inside it.

If anyone can help in anyway I would be very greatful.
Thanks a million Gary

Picture Full Screen Stretch
How do you make a picture stretch to fullscreen? Sorry n00b here..

Painting Large Picture To Screen...
Hi All -

I've got a program that paints a large image to the screen (captured from a framegrabber in a separate DLL and returned to my VB program in an array).

Here's the general outline of the code I've been using:

hBMP = CreateCompatibleBitmap(Picture.hdc, Picture.ScaleWidth, Picture.ScaleHeight)
hDestDC = CreateCompatibleDC(Picture.hdc)
SelectObject hDestDC, hBMP

(... Some code to collect the image, stored in DisplayImageArray() ...)

' Paint the image to the screen
For i = 0 To DisplayWidth - 1
For j = 0 To DisplayHeight - 1
indx = i + j * DisplayWidth
SetPixelV hDestDC, i, j, RGB(DisplayImageArray(indx), DisplayImageArray(indx), DisplayImageArray(indx))

BitBlt Picture.hdc, 0, 0, Picture.ScaleWidth, Picture.ScaleHeight, hDestDC, 0, 0, &HCC0020

Call DeleteDC(hDestDC)
Call DeleteObject(hBMP)

This is working OK for me with smaller images (like 512x512 pixels), but when I increase the images to 1024x1024, there is a very noticeable delay before the image is painted to the screen. Is there any way for me to speed this up?

For example, could I write a C++ function in a DLL which would take the handle of picture object and the image array and then paint that onto the form? If so, how would I go about doing that? I am not all that familiar with Windows API functions, and the above code was constructed by looking at examples from other people...

Thanks for any advice!


Resize Picture Not Bigger Than Screen
hi all
im trying to load my picture up and resize the picture so that it is not bigger than the screen i have tryed a couple of things with no look any help on this would be great

With Me
.ScaleMode = vbPixels
End With

'Set up picturebox
With pic
.ScaleMode = vbPixels
.AutoRedraw = True
.AutoSize = True
.DrawMode = vbInvert
.DrawStyle = vbDashDot

.MousePointer = vbCrosshair
.Picture = LoadPicture("C: emp.jpg")
End With

Print Screen And Put Contents Into Picture Box
is there a way that i can take a screenshot like pressing print screen, but have the program do it, and put the image in a picture box?
if someone can help me with this that would be great.

ps. also is there a way to scan over the now pasted image for a certain color pixel, and get its location? any help would be greatly appreciated.

Position Of Picture Box In A Windows Screen
Help me friends,
i have a problem, how to get coordinate X & Y in pixel scale of our object controls such as form or picture box. I want to know where top & left properties of picture box in our windows screen.
Our screen can be in different resolution.

Help With Picture Updates - Screen Shots From Network
I need to know the best way, Network traffic wise and CPU resources wise to copy a small JPG from a network drive and then display it in an image box.

6 second cycle
3 seconds it copies the file from the network to local
3 seconds later it displays it in the application.

I have about 100 people that will be using the app at the same time. The JPG is created from a screen shot that is taken every 3 seconds.

The reason I am not just having eveyone update the image control with the network image is because sometimes the jpg is in the process of being saved and causes errors.

Maybe there is a better way all together to get this done?
I currently have it working but it drags down the cpu and sometimes the program freezes for up to 20 seconds.

Any help is appriciated
Thank you

Putting The Preview Picture To A Screen Saver??
Now that I've made a few so-so screensavers, i'd like to ask if anybody here knows how to put the preview image into the box, so that when the user selects my screensaver an image will appear on the little preview monitor in win95 and win98.

Can anybody help me on this one?


Auto Resizing A Picture Box With Image To Match Screen Resolution

I have created a picturebox. inside this picturebox is an image, of, in this case, a cellphone. I have added buttons over the pictures of buttons on the phone and textboxes over the picture of the screen of the phone. As you can see, i am working on an app that simulates a real cell phone. One problem, though...

I wrote the application on a machine with a screen resolution of 1400x1050, and the phone image/interface takes up the entire height of the screen. So, if it is viewed/run on a computer with less resolution, say, 800x600, most of the phone interface/picture is cut off.

How do I automatically resize the picturebox, the image in the picturebox, and all the controls that are part of the picturebox container based on the screen resolution?

Very important! Please aid me!

Thanks in advance!

Semi Transparent Screen ( Picture Control) Visual Basic
Hi All,

Please help me out in to achive the semi transparent effect for picture box.
Find the attached screen shots which is wat the exact requirement.

Images should look like disabled i.e, there should be some layer (blueish) on the whole
Assign Stamp Art part as shown in Snap1.bmp.

This is very urgent.....


Semi Transparent Screen ( Picture Control) Visual Basic
Hi All,

Please help me out in to achive the semi transparent effect for picture box.
Find the attached screen shots which is wat the exact requirement.

Images should look like disabled i.e, there should be some layer (blueish) on the whole
Assign Stamp Art part as shown in Snap1.bmp.

This is very urgent.....


Screen.MouseIcon = Picture1.picture; Doesn't Assign . Any Clues ?
Form with PictureBox Control with small .BMP assigned to Picture1.Picture

screen.mousepointer = 99
screen.mouseicon = Picture1.Picture

Causes a wrong property assignment error
although the VB Help states this syntax.
It only works if Picture1.picture is an .ico file and not a .BMP.

Am I missing something ?

R:- ( ..................................

Print Picture Box (print A Form That Is Too Large For The Screen Or Page)
I got a picture box (Picture1), which contain several picture box'es, labels and
Flex Grid tables, -which I would like to print. Picture1 is quite high (higher than the screen). I found some code that i modified, but the printing only get the labels proper. The Flex Grids and picture box'es only show the border, and not the contents.

Code:Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4& ' Draw the window's client area.
Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
Private Const PRF_OWNED = &H20& ' Draw all owned windows.

Private Declare Function SendMessage Lib "user32" Alias _
   "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
   ByVal wParam As Long, ByVal lParam As Long) As Long

Private Sub Print_Click()
Dim rv As Long
   Me.ScaleMode = vbTwips ' default
   With Picture2
      .Top = Picture1.Top
      .Left = Picture1.Left
      .Width = Picture1.Width
      .Height = Picture1.Height
   End With
   Me.Visible = True
   Picture2.AutoRedraw = True
   rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
   rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
   Picture2.Picture = Picture2.Image
   Picture2.AutoRedraw = False

   Printer.Print ""
   Printer.PaintPicture Picture2.Picture, 0, 0
End Sub

Edited by - Zigar on 11/27/2003 3:31:21 AM

Screen.Width / Screen.TwipsPerPixelX, Screen.Height ..
VB Code:
SetWindowPos Me.hWnd, HWND_TOPMOST, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, formx.Width, formx.Height, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE


I cant undestand the meaning of the fowlloing code. it make me some confussion. please explain what it tells.

VB Code:
Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY

Get Screen Resolution Without Screen.width Or Screen.height
these 2 ways really look in accurate. when the user changes the resolution of his desktop it wont detect it.. while i check it every second.. this makes my window not appear in the most left down corner (of screen or in the center) , also at a resolution of 1600x1200 the window is allready not located exactly in the left down corner but also out of the screen :S any other way to get the resolution?

ok, so i have a borderstyle = none form and i want my user to be able to resise it. In the bottom right corner, there is a small image box. This is what they will use to resize it diagonaly. so far i have this code which doesn't seem to work?? i have no idea what i need to do to get the form to resise like normal forms??

Option Explicit

Dim oldX As Single
Dim oldY As Single
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then 'draging effect
oldX = X
oldY = Y
End If
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbLeftButton) Then 'if mouse is clicked then move form to position of it.
Me.Height = Me.CurrentX + (Y - oldY)
Me.Width = Me.CurrentY + (X - oldX)
End If
End Sub
any halp is much appreciated

stead ;)

Hi ok well I want to have all 3 buttons on the toolbar. The minimize maximize and close but I dont want the user to be able to expand it or resize it is there a way so they cant still with all 3 buttons in the toolbar?Thx for help and any will do

How do I allow my program to be minimized but not resizable. It has to be able to be minimized but my sizing it will reveal things that I do not want shown until certain actions are performed. I know there is a simple fix for this but I cannot remember it.

Icons And Sizing
I've created an icon which contains several sizes/color depths, and as per standard they are in order from smallest/least, to largest/greatest

using vb6 I wanted to dynamically assign the form icon based on the user enviroment setting

(ex. normal(96dpi) which yields 16x16 icons and large(120dpi) which yields 24x24 icons)

currently if I set the form icon it only uses the first entry which makes it blurry if too big, or poorly stretched if too small

I tried using
frmMe.Icon = setResPicture(101, 1)
with the icon added in the .res file as id 101 but this only selects the first resolution

the question is
A: must I add each resolution seperately?
B: how do I detect the users current dpi to choose the correct resolution(since it doesn't seem to detect this automatically)

I also was wondering how I might provide the user with a button to set my application as the default for files of the type it uses, and set a custom icon for those... but this may be the wrong forum for that question

Problems With Sizing
Hey -great to be back (haven't done a lot of VB in the mean-time :-( )

I have a problem with sizing...
I attached 2 pictures, one in design time (left) and one in
runtime (right). It's the only form I have this problem
(half-hidden buttons) with and changing the default-window
size doesn't solve it.

Am I missing a form(size) property?


Sizing A PictureBox
I have a picturebox on the form and want to know if there is anyway I can allow the user to resize (drag the corner) the picturebox by putting their mouse on it's corner and then dragging it to be a new size.

Any ideas?


MDI Children Re-sizing
My MDI child forms occassionaly re-size when loading - despite the fact they are windowstate = maximised - does anyone have any ideas why this might happen?

MshfGrid Re-sizing
I have an MSHFGrid which opens on my main(first child form loaded) form in my MDI app. I calculate the column widths proportionally depeding on the form size and this works fine except for when I set the MDIMainForm to open maximised.

I am calculating the widths in an 'Initgrid' procedure which is run from the child form load event and the child form resize event.

I have used the debugger and it appears to go through the child form resize code when loading, but the columns haven't been resized when the main form is loaded maximised.

They resize OK when you change the size, but I need them to open correctly if the main form is maximised. Hope someone can help!

Sizing Of Form
How can I resize a form in a way that there is gonna be a scrollbar so I could put more controls into it. I wanted to do it in the design and run time.

Can anybody help me out?

Sizing At Runtime
I am trying to construct an IDE that has panels which can be sized at runtime. You know, when you place your mouse over the edge of the panel, it turns into a sizing arrow and you can click and drag out the panel to the size you want, then the child controls in the panel are resized accordingly. Is there a panel control available that can handle this easily? The control also needs an alignment property as I am using MDI. If this can be done without using an extra control, but a simple picturebox, that method would be preferred.

Sizing Problem
Can anyone help me. i wrote a program and it works great on my computer, but when i take to to work to use, part of the form is off the screen and there is no way to get to it. is there a way to have the form recognize the monitor its on and size itself properly (i.e. shrink or grow so that it is on the screen wholly). Thanks for any help.

Sizing Program
I have finished a program and have compiled it and created an .exe. However when I run it on computers with different resolutions it does not adjust to the resolution. (It is too large for the screen) Is there a property that takes care of thi issue. If not any suggestions.


Texture Sizing In DX8
Question for ya...I have a texture that is 650 by 64. But i only want to show a section of the whole bitmap on the polygon. The section is 29 pixels long (starting at 0) and 64 high.

How can i change to following code to show only that section? Thanks.

'vertex 0
TrisStrip3(0) = CreateTLVertex(100, 100, 0, 1, RGB(255, 255, 255), 0, 0, 0)

'vertex 1
TrisStrip3(1) = CreateTLVertex(129, 100, 0, 1, RGB(255, 255, 255), 0, 1, 0)

'vertex 2
TrisStrip3(2) = CreateTLVertex(100, 164, 0, 1, RGB(255, 255, 255), 0, 0, 1)

'vertex 3
TrisStrip3(3) = CreateTLVertex(129, 164, 0, 1, RGB(255, 255, 255), 0, 1, 1)

Sizing .X Files
Hello all,

I'm having a problem with .X files. What I have is a 3DS file which I've converted into a .X file. The file is huge. I want to know if you can resize the actual size of the mesh from the VB application? I'm using DX8. If so, how?

Copyright 2005-08, All rights reserved