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

Shrink To Fit

I have a MDI form and open up other fixed forms inside. Is there
a way to "Shrink to Fit" the MDI so that it is the same size (roughly) as the form(s) that are loaded?
I am able to do this if one form is loaded but I need to be able to
do this if more than one form is loaded because they would be
in different positions.


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Shrink Map
Is there a way that will allow mi to shrink my map in the picture box at the click of a button?

Thank You.

Shrink Images
I am using bitblt in my project. I have to draw about 10 times the same image on my form. That's not much of a problem, but...

I want to know if it is possible to bitblt the same image in different sizes on my form?
Do I need any API's?


Used Shrink W SQL Server
I have a problem how coding line in VB 6.0: reduction the one base by means shrink in SQL Sever

Shrink A String?
is there a way to shrink a string like this:

httttttttttttttttttttttttdklfkgdlgkdlgk33333333333 (this is 50 characters long)

is there a way to shrink it to 45 characters?

Can You Shrink To Fit Text.
I am creating a program that will print several forms, some of the text box sizes ( on the printed form ) are predetermined sizes.
Is there a way to automatically shrink the text input to fit the area. Sort of like the excel shrink-to-fit does. Thank You!

Shrink This Code....
Any ideas on how I can shorten the code below?? Cause I'm going to have to add a few more ifs, and its going to get really long...

VB Code:
Private Sub Command1_Click()Dim pos As Integerpos = InStr(txtSend.Text, "Hello")If pos > 0 Then pos = InStr(txtSend.Text, Username)If pos > 0 ThenSleep (1000) txtoutput.Text = txtoutput.Text + Username + ": Hi there" + vbCrLfEnd IfElsepos = InStr(txtSend.Text, "Hi")If pos > 0 Thenpos = InStr(txtSend.Text, Username)If pos > 0 ThenSleep (1000)txtoutput.Text = txtoutput.Text + Username + ": Hi there" + vbCrLfEnd If End IfEnd IftxtSend.Text = ""End Sub

Is There A Way You Can Shrink An Everything In It To Fit On A The Screen?
I'm trying to do something like MS Word and a lot of different apps do where they can change the size of the working area to a different size so it can fit on the users screen. Where is has the % or Fit to screen. Is there a API function or anyway of doing something like this.

I am trying to have a form to be filled out that will be the same size as a sheet of paper. I want all the info to fit on the users screen but when it get's printed with a Form Print it fills the paper.

I want my printed form to have the same layout as the from itself. With Some of the background colors of textboxes being different so I can just print the text.

Stretch / Shrink Pix ...
I am making a screen saver that loops through images, but i need to "adjust to screen" - if pic is too short, make it bigger, too big - smaller. I use a picturebox for pictures. How do i make the picture adjust to the new picturebox size ?

How To Shrink A Database?
Is there any way to programmatically shrink an Access database? By using, let say, some ADO function?

Shrink An Image File!
Dear All,

I have notice that a file as either a BMP or JPG when Loaded in PaintBrush and then Saved as a JPG, encounters a massive shrinkage in the file size. However searching through this forum I haven't been able to find how to do this automatically as VB appears not to be able to automate the Save JPG paintbrush!

Would anyone have any ideas?

Thanks in advance


Subreport - Shrink When No Result
I have an access report where I have a subreport with another subreport.

I link Child Field to Master Field.

Sometimes however no result is returned for the detail section.
Each time nothing is returned the subreport takes up a considerable (too much) space in the report.

When no result is returned, I want that space to shrink.

I have the "Can Grow" and "Can Shrink" properties set to yes however this does not accomplish what I'm trying to do.

Is there another property I can use or does anyone know how to do this?


Listboxes That Shrink Or Grow
Pardon me if this was already answered, but I searched and could not find an answer to this. I am trying to create a form that allwos someone to respond to questions. The questions are stored in a dbase III file, but I will never know how many questions will be asked. Put another way, there is a table with two fields (Question, and Answer) and I do not know how many records there will be. I know how to do this in Access, as I would use a subform (and when printing a subreport) and set the cangrow and canshrink properties to true. I am going to be using DAO (exclusively, if I can get away with it) and would actually prefer to do this all in code. The reason I would never know programmatically how many records is that I am giving the user the ability to modify how many questions are asked. Any ideas would be appreciated.

"Keyboard error or no keyboard present. Press F1 to continue."

How To Shrink Print Output ?
Hi everybody,
I tried to shrink the printer output by assigning the Printer.Zoom property of the printer object to 80 as follows :
Printer.Zoom = 80
, before issuing Printer.Print commands, but this is not working. MSDN help says that all Printers don't support zoom, but I believe my printer does because it shrunk the print output to 75% in Excel. I believe, if not in this way, by some other way, e.g. API could achieve this. Please help.

Shrink Wrap Form
Funny name huh?

Anyway, I know there is a method of resizing a control (such as a text box) to the client size of a form. I need to resize the form so it's client size is the size of a control.

Grid Control - Shrink
I'm placing a picture in one of the cells in a grid control. Is it possible to shrink/stretch the picture, like the image control does when the stretch property is on? Thanks in advance.

Shrink Database Size
How can i shrink a database size in SQL Server 7.0

Shrink SQL 2000 Database With VB Code
Hello all...

I am trying to find a way with Visual Basic 6.0 code to shrink a SQL 2000 database. Currently we have many databases deployed in the field that store data for a Point-of-Sale application. This summer we are running a process on that application that removes a lot of data, however the programmers for that application failed to put a shrink method in to their code, so after they remove all of this data, the database files are still big file sizes.

I am trying to find the command I can issue in my Visual Basic 6.0 project that will shrink the database files to the smallest possible after all the records are removed.

Any help would be great.

Garry B

Shrink Pic In Image Control Not Very Clear
I'm using an IMAGE control to display a JPG.

I am shrinking it down a bit - setting the .Stretch=True and setting the .Height and .Width proportionally.

But the result is not a clear image.

I'm comparing that to what the Windows Picture and Fax Viewer is showing for an image of the same size.

Is the image control just poor at doing image re-sizing?

Is there a better method for this???

Addin-Be Able To Shrink/enlarge Subs Etc?
Is there a plugin that anyone uses that lets you have a +- button next to your sub so you can shrink the sub when you dont need it? Vb code gets to out of hand to quickly..

Picture Shrink:Vb-->C Dll Doesn't Work...
Hello, I just "translated" an algorithm from VB to C. I put it in a DLL but it doesn't work. I'm doing this because I think in C is faster... It's an algorithm to shrink a picture. Surely better than StretchBlt API. Found in this forum...
When I use VB code I have no problem, but when I use my DLL it enters in a loop and stops my program...

Can anyone have a look at both codes, pls?!?
And how can I debug my DLL?!?


Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long) As Long
Public Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long

Public Function ShrinkPict(DestDC As Long, SourceDC As Long, _
fx1 As Integer, fx2 As Integer, fy1 As Integer, _
fy2 As Integer, tx1 As Integer, tx2 As Integer, _
ty1 As Integer, ty2 As Integer)
Dim yScale As Single
Dim xScale As Single
Dim tx As Integer
Dim ty As Integer
Dim RedAvg As Long
Dim GrnAvg As Long
Dim BluAvg As Long
Dim x As Integer
Dim y As Integer
Dim BaseCol As Long
Dim R As Long
Dim G As Long
Dim B As Long

xScale = (tx2 - tx1) / (fx2 - fx1)
yScale = (ty2 - ty1) / (fy2 - fy1)

For ty = ty1 To ty2 - 1
Y1 = Int((ty - ty1) / yScale + fy1)
Y2 = Int((ty + 1 - ty1) / yScale + fy1) - 1
For tx = tx1 To tx2 - 1
X1 = Int((tx - tx1) / xScale + fx1)
X2 = Int((tx + 1 - tx1) / xScale + fx1) - 1
RedAvg = 0: GrnAvg = 0: BluAvg = 0
For y = Y1 To Y2
For x = X1 To X2
BaseCol = GetPixel(SourceDC, x, y)
ColorCodeToRGB BaseCol, R, G, B
RedAvg = RedAvg + R
GrnAvg = GrnAvg + G
BluAvg = BluAvg + B
Next x
Next y
If RedAvg > 0 Then
RedAvg = RedAvg / (X2 - X1 + 1) / (Y2 - Y1 + 1)
RedAvg = 0
End If
If GrnAvg > 0 Then
GrnAvg = GrnAvg / (X2 - X1 + 1) / (Y2 - Y1 + 1)
GrnAvg = 0
End If
If BluAvg > 0 Then
BluAvg = BluAvg / (X2 - X1 + 1) / (Y2 - Y1 + 1)
BluAvg = 0
End If
SetPixelV DestDC, tx, ty, RGB(RedAvg, GrnAvg, BluAvg)
Next tx
Next ty
End Function
Public Function GetRed(RGBCol As Long) As Long
GetRed = RGBCol And &HFF
If GetRed > 255 Then GetRed = 255
If GetRed < 0 Then GetRed = 0
End Function

Public Function GetGrn(RGBCol As Long) As Long
GetGrn = (RGBCol And &HFF00)
If GetGrn <> 0 Then GetGrn = GetGrn / &HFF
If GetGrn > 255 Then GetGrn = 255
If GetGrn < 0 Then GetGrn = 0
End Function

Public Function GetBlu(RGBCol As Long) As Long
GetBlu = (RGBCol And &HFF0000)
If GetBlu <> 0 Then GetBlu = GetBlu / &HFFFF
If GetBlu > 255 Then GetBlu = 255
If GetBlu < 0 Then GetBlu = 0
End Function

Public Function ColorCodeToRGB(lColorCode As Long, iRed As Long, _
iGreen As Long, iBlue As Long) As Boolean
' 1996/01/16 Return the individual colors for lColorCode.
' 1996/07/15 Use Tip 171: Determining RGB Color Values, MSDN July 1996.
' Enter with:
' lColorCode contains the color to be converted
' Return:
' iRed contains the red component
' iGreen the green component
' iBlue the blue component
Dim lColor As Long
lColor = lColorCode 'work long
iRed = lColor Mod &H100 'get red component
lColor = lColor &H100 'divide
iGreen = lColor Mod &H100 'get green component
lColor = lColor &H100 'divide
iBlue = lColor Mod &H100 'get blue component

ColorCodeToRGB = True
End Function


#include <windows.h>;
#pragma warning(once : 4244 4700);

long GetRed(long RGBCol);
long GetGrn(long RGBCol);
long GetBlu(long RGBCol);
bool ColorCodeToRGB(long *lColorCode,long *iRed,long *iGreen,long *iBlue);

extern "C" __declspec( dllexport ) long __stdcall ShrinkPict(long DestDC,
long SourceDC,long fx1,long fx2,long fy1,long fy2,long tx1,long tx2,long ty1,long ty2)
float yScale,xScale;
long tx,ty,RedAvg,GrnAvg,BluAvg,x,y,BaseCol,R,G,B,X1,X2,Y1,Y2;

if(RedAvg>0) RedAvg=RedAvg/(X2-X1+1)/(Y2-Y1+1); else RedAvg=0;
if(GrnAvg>0) GrnAvg=GrnAvg/(X2-X1+1)/(Y2-Y1+1); else GrnAvg=0;
if(BluAvg>0) BluAvg=BluAvg/(X2-X1+1)/(Y2-Y1+1); else BluAvg=0;
return 0;

long GetRed(long RGBCol)
long Color;

Color=RGBCol & 0xFF;
if(Color>255) Color=255;
else if(Color<0) Color=0;

return Color;

long GetGrn(long RGBCol)
long Color;

Color=(RGBCol & 0xFF00);
if(Color>255) Color=255;
else if(Color<0) Color=0;

return Color;

long GetBlu(long RGBCol)
long Color;

Color=(RGBCol & 0xFF0000);
if(Color>255) Color=255;
else if(Color<0) Color=0;

return Color;

bool ColorCodeToRGB(long *lColorCode,long *iRed,long *iGreen,long *iBlue)
long lColor;

*iRed=lColor % 0x100;
lColor=lColor / 0x100;
*iGreen=lColor % 0x100;
lColor=lColor / 0x100;
*iBlue=lColor % 0x100;

return true;

ShrinkPict Picture2.hdc, Picture1.hdc, 0, Picture1.ScaleWidth, 0, _
Picture1.ScaleHeight, 0, Picture2.ScaleWidth, 0, Picture2.ScaleHeight

Can I Shrink The Size Of An Array After It's Dimmed?
If i have an array with 100 elements.... but later only the first 75 have values in the elements, can i shrink it to a 75 element array w/out losing the data?

Basically I want to trim the last 25 elements and have the new Ubound be 74!

Shrink A .jpg File But Keep Aspect Ratio

i was just wondering if there is any way to shrink a jpg and keep the aspect ratio using VB only.


Shrink A Picture So It Fits In A Flexgridcell
Hello there,

This may be an easy question but how do I resize e picture that is in a cell of a flexgrid??

I need to show many pictures (I develop some sort of thumbnail viewer) but I always get the 'Out of memory' error when creating too many imageBoxes...So I searched the web and found out you can store pictures in a flexgrid. COOL! now I use only one control for many pictures, but...I can't manage to resize them...the cells of a flexgrid have no strech property or something like that.

Can someone help me out? I want to shrink the picture so it fits in a cell !

Thanks for your help!


Help With VB In Excel To Shrink Entire Worksheet
I have used an excel spreadsheet to draw a map. I have used 3000 rows and all of the columns to draw the entire map. The row height is set at 1.5 and column width is set at 1. I need to view the entire map on my 17 inch monitor without scrolling.

When I zoom the worksheet to 25% I am able to see the map clearly BUT I have to scroll to view the entire map.
I have tried to zoom by placing my cursor on A1 and together pressing CTL + moving scroll wheel, this shrinks the map so small that I cannot see anything. I think the zoom is NOT decreasing at a small enough increment.

Can anyone assist me with VB code that can solve my problem in excel.



How Do I Shrink A Picture To A Preset Picturebox Size?
Hi everyone!

I am writing a program that will load a gif or jpg photo into a picturebox. However, only the top left corner of the photo appears in the box. If I set the autosize property "on", it doesn't shrink my picture, it expands the picturebox which wrecks my form.

I want to take a photo of someone, store it in a folder, and then be able to show the photo of the person in a form along with information about the person. Not being a digital camera person or an experienced VB programmer yet, I could use some ideas. Does anyone have any ideas about this? How can I get small pictures of someone into my form?


Textbox Auto Grow/Shrink Like MS Access
Hello anybody please help me how to have a Autogrow/Shrink a textbox in VB 6.0. Please any help would be appreciated. I can do this in MS Access. Thank you so very much.

EASY ONE: How Can I Shrink An Image To Place It On A Button?
I placed a pushbutton on my form and want to play an image on it. I realize there is a "Picture" property which could be set to the image I want, but I can not find a "StretchToFit" property for the button so my image does not shrink to the button size. Instead I just get the small corner of my complete image showing up on the button.

I tried looking into using another control which could be used like a button, but could not find something like this.

How To Make Image Shrink Or Stretch To Fit A Defined Picture Box?
With .bmp or .jpg
Thanks in advance!

Please visit my websites!

VBA Shrink Text To Text Box
I want to insert a text box in a Word doc. Insert some text, then shrink/grow the text to fit the text box. Can someone pls explain a possible way of doing this?

Copyright 2005-08, All rights reserved