|
-
Oct 3rd, 2000, 06:19 PM
#1
Thread Starter
Fanatic Member
Does someone have code that makes a program's controls display correctly to fit the resolution of the computer that it's running on?
Thx.
-
Oct 3rd, 2000, 06:34 PM
#2
Fanatic Member
yes, this should do it, however, it's a little buggy.
Code:
Private ResHeight As Integer
Private ResWidth As Integer
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Private Const Design_Width = 800 'set to Width Res of Design Enviroment
Private Const Design_Height = 600 ' set to Height res of Design Enviroment
Private Sub GetScreenResolution()
Dim lTemp As String
' Temporary string to hold returned screen
' resolution
ResWidth = GetSystemMetrics(SM_CXSCREEN)
ResHeight = GetSystemMetrics(SM_CYSCREEN)
' Call the API function twice to return
' screen size for each axis as format into
' the temporary string
End Sub
Private Sub ResizeAll()
GetScreenResolution
On Error Resume Next
Dim WidthProp As Double
Dim HeightProp As Double
Dim frm As Form
WidthProp = ResWidth / Design_Width
HeightProp = ResHeight / Design_Height
Dim Ctrl As Control
For Each frm In VB.Forms
For Each Ctrl In frm.Controls
If TypeOf Ctrl Is Label Then
Ctrl.FontSize = Ctrl.FontSize * HeightProp
End If
If TypeOf Ctrl Is Image Then Ctrl.Stretch = True
Ctrl.Height = Ctrl.Height * HeightProp
Ctrl.Top = Ctrl.Top * HeightProp
Ctrl.Left = Ctrl.Left * WidthProp
Ctrl.Width = Ctrl.Width * WidthProp
DoEvents
End if
Next
Next
End Sub
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 3rd, 2000, 06:51 PM
#3
_______
<?>
email me if you want a dll to do the job.
Wayne
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 3rd, 2000, 07:01 PM
#4
Thread Starter
Fanatic Member
Thanks, guys
I'll give gwdash's code a try (although I see that I'll need to alter it a bit because it only accounts for Labels and Images).
If I have problems, I'll send you an email HeSaidJoe.
Thx.
-
Oct 3rd, 2000, 07:03 PM
#5
_______
<?>
No problem..I have it a class module as well if you don't want the dll...I just find the dll is cleaner..with no messing around.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 4th, 2000, 02:31 PM
#6
Thread Starter
Fanatic Member
Problem not solved.
Thanks for reading.
Gwdash's code is incomplete and buggy (by his own admission) and HeSaidJoe didn't send me the dll after I emailed him. I said all that to say, will someone please post the code to make a program's controls display correctly to fit the resolution of the computer that it's running on?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|