السلام عليكم,
سؤالي هو: هل يمكن جعل عرض البرنامج يتكيف مع جميع أنواع الشاشات من (640ْx480 الى 1024x768)؟
Is there a way i can make my program display window suits all the screen display settings from 640x480 to 1024x768?
ولكم جزيل الشكر
السلام عليكم,
سؤالي هو: هل يمكن جعل عرض البرنامج يتكيف مع جميع أنواع الشاشات من (640ْx480 الى 1024x768)؟
Is there a way i can make my program display window suits all the screen display settings from 640x480 to 1024x768?
ولكم جزيل الشكر
طبعا ممكن :
Option Explicit
Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Const HORZRES = 8 ' Horizontal size in pixels
Private Const VERTRES = 10 ' Vertical size in pixels
Private Const BITSPIXEL = 12 ' Bits per Pixel
Private Const LOGPIXELSX = 88 ' Pixel/inch in X
Private Const LOGPIXELSY = 90 ' Pixel/inch in Y
'In module
Public Sub GetVideoCaps(hDC As Long, Colors As Long, XResolution As Long, YResolution As Long)
Dim i As Integer
Dim BitsPerPixel As Long
BitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL)
Colors = 1
For i = 1 To BitsPerPixel
Colors = Colors * 2
Next
XResolution = GetDeviceCaps(hDC, HORZRES)
YResolution = GetDeviceCaps(hDC, VERTRES)
End Sub
Public Sub GetPixelsInch(hDC As Long, PX As Long, PY As Long)
PX = GetDeviceCaps(hDC, LOGPIXELSX)
PY = GetDeviceCaps(hDC, LOGPIXELSY)
End Sub
'in form
Private Sub Form_Load()
Dim c As Long
Dim x As Long
Dim y As Long
GetVideoCaps Form1.hDC, c, x, y
MsgBox x & "x" & y & " - " & c & " colors"
GetPixelsInch Form1.hDC, x, y
MsgBox x & " Pixels/Inch in X" & vbCrLf & y & " Pixels/Inch in Y"
End Sub
جرب الكود. ثم قم بتعديله حسب احتياجاتك.
ستتضطر لكتابه الكود المسؤول عن تكييف البرنامج مع كل resolution
Thnx , i'll try that asap -- take care
هذا الموضوع مغلق.