?
Solved

Visual Basic Form Background Picture Sizing/Positioning

Posted on 2000-04-10
12
Medium Priority
?
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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