Solved

Visual Basic Form Background Picture Sizing/Positioning

Posted on 2000-04-10
12
231 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change the path of the data source in my Excel pivot table with macro 4 43
Best book to learn C++ 4 79
Hide vba in gp 7 94
Add and format columns in vb6 7 57
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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