Solved

Visual Basic Form Background Picture Sizing/Positioning

Posted on 2000-04-10
12
235 Views
Last Modified: 2013-11-25
Is it possible to automatically set the system display settings or at least ignore the settings when a visual basic form loads?

In other words, we have visual basic forms that look differently, depending on which computer they are loaded onto.  We are trying to find a way to allow all users to see the forms in exactly the same way, without forcing everyone to change their computer display settings.
0
Comment
Question by:dekkyb
  • 3
  • 2
  • 2
  • +4
12 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2701248
Do you mean System Colors, Fonts, and Resolution?
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 2701270
0
 
LVL 2

Expert Comment

by:Crin
ID: 2701271
Hello dekkyb,

Most accurate way is to use 16 colors, and to check forms design at 640x480, or 800x600 at least...

Also read help about Scale, ScaleTop, ScaleLeft, ScaleWidth, ScaleHeight...

WBR

Crin
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Crin
ID: 2701272
Hello dekkyb,

Most accurate way is to use 16 colors, and to check forms design at 640x480, or 800x600 at least...

Also read help about Scale, ScaleTop, ScaleLeft, ScaleWidth, ScaleHeight...

WBR

Crin
0
 
LVL 4

Expert Comment

by:tmack
ID: 2701378
You have the choice to use either colors from the palette or the system. I usually use from the palette as I cn control the way the app looks at all times. Just make these changes to all your controls background, forground ect properties in the application.


T
0
 

Author Comment

by:dekkyb
ID: 2701798
Part of the issue is that we can't determine which settings are causing the problem.  On one system the form will look correct.  On another system, the form background image will be smaller than the form frame, causing a strip of gray to appear along one side.  Manually changing the screen resolution, font sizes, and/or color depth (24-bit, 32-bit, etc.) does not seem to correct the problem.
0
 

Author Comment

by:dekkyb
ID: 2701823
Part of the issue is that we can't determine which settings are causing the problem.  On one system the form will look correct.  On another system, the form background image will be smaller than the form frame, causing a strip of gray to appear along one side.  Manually changing the screen resolution, font sizes, and/or color depth (24-bit, 32-bit, etc.) does not seem to correct the problem.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2701852
if you port your program to another system with the identical settings you have on your computer that you created it on it still causes problems?
0
 
LVL 2

Expert Comment

by:Crin
ID: 2701878
Hmmm...

seems it depends on system setting of the borders width.

Try to play local with border appearance and if the trouble here - set BorderStyle to Fixed Single...

Otherwise - please send more detailed information.

Sincerely yours,

Crin


0
 
LVL 32

Expert Comment

by:Erick37
ID: 2701965
You can set the window's size to match the picture size at runtime with the AdjustWindowRect API.
Simple Example:

Option Explicit
Const WS_OVERLAPPED = &H0&
Const WS_CAPTION = &HC00000
Const WS_SYSMENU = &H80000
Const WS_THICKFRAME = &H40000
Const WS_DLGFRAME = &H400000
Const WS_MAXIMIZEBOX = &H10000
Const WS_MINIMIZEBOX = &H20000
Const WS_BORDER = &H800000
Const WS_POPUP = &H80000000
Const WS_FIXEDSINGLE = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_DLGFRAME)
Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Declare Function AdjustWindowRect Lib "user32" _
    (lpRect As RECT, ByVal dwStyle As Long, ByVal bMenu As Long) As Long

Private Sub Form_Load()
    Dim cx As Long, cy As Long
    Dim rc As RECT
    Dim bHasMenu As Boolean 'set true if window has a menu
    bHasMenu = False
    'get picture size in pixels
    cx = ScaleX(Me.Picture.Width, vbHimetric, vbPixels)
    cy = ScaleY(Me.Picture.Height, vbHimetric, vbPixels)
    rc.Right = cx
    rc.Bottom = cy
    'For Style 2 - Sizable
    'Call AdjustWindowRect(rc, WS_OVERLAPPEDWINDOW, bHasMenu)
    'For Style 1 - Fixed Single
    Call AdjustWindowRect(rc, WS_FIXEDSINGLE, bHasMenu)
    cx = ScaleX(rc.Right - rc.Left, vbPixels, vbTwips)
    cy = ScaleX(rc.Bottom - rc.Top, vbPixels, vbTwips)
    Me.Width = cx
    Me.Height = cy
    Debug.Print Me.Width; Me.Height
End Sub
0
 

Expert Comment

by:Olli083097
ID: 2703323
dekkyb:
It could be that the properties for the screen are different. Try to use Windows-Standard on both computers. If this solves the problem you could try the GetSystemMetrics API. This API will measure the width and the height of the borders. You can use this in the Resize event.

Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

'constants for GetSystemMetrics API
Public Const SM_CXFRAME = 32
Public Const SM_CYFRAME = 33

Look on the MSDN Library for more info.
0
 
LVL 3

Expert Comment

by:g_jones021500
ID: 2707780
why not have the image stretch to fit the form when the form loads?
Is this a MDIChild form?
Does the form automatically handle control resizing on form resize?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question