Solved

Visual Basic Form Background Picture Sizing/Positioning

Posted on 2000-04-10
12
225 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
Comment Utility
Do you mean System Colors, Fonts, and Resolution?
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
Comment Utility
0
 
LVL 2

Expert Comment

by:Crin
Comment Utility
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 2

Expert Comment

by:Crin
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:dekkyb
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 …
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now