PDA

View Full Version : سوال: تغییر انداره برنامه به اندازه مانیتور در سیستم های مختلف؟



elham99
چهارشنبه 11 دی 1392, 09:23 صبح
میخوام وقتی برنامه اجرا میشه ، اندازه برنامه به اندازه مانیتور طرف تبدیل بشه.

مثلافرقی نکنه که مانیتور 21 ، 19 ،17 و....... باشه.

خودم اینو نوشتم ولی جواب کاره منو نمیده:



public temp

Private Sub Form_Load()
temp=SystemParametersInfo(SPI_SCREENSAVERRUNNING ,1&,0&,0&)
...
.
.
end sub

hmbarnamenevis
چهارشنبه 11 دی 1392, 09:45 صبح
سلام اگر برای شما رزولوشن مهم نباشد و روی رزولوشن ثابت کار می کنید می توانید از این ترفند استفاده کنید:
یک PictureBox در فرم قرار دهید و تمام اشیاء خود را در آن طراحی کنید.
حالا اگر برنامه شما مثلا 800 در 600 است این کد ها رو بنویس:
Private Sub Form_Load()
Me.Move 0, 0, Screen.Width, Screen.Height
Picture1.Width = 12000
Picture1.Height = 9000
Picture1.Move (Me.Width - Picture1.Width) / 2, (Me.Height - Picture1.Height) / 2
End Sub

خاصیت BorderStyle فرم رو هم بر روی None قرار بده

elham99
چهارشنبه 11 دی 1392, 10:20 صبح
نه اتفاقا رزولوشن برام خیلی مهمه
چون برنامه من رو سیستم های مختلفی ممکن اجرا بشه و من نمیخوام تنظیمات سیستم مقابل رو بهم بریزم
برعکس میخوام برنامه ای من با سیستمی که تون اون اجرا میشه هماهنگ بشه....

hmbarnamenevis
چهارشنبه 11 دی 1392, 10:24 صبح
خوب کد من هم با تمام صفحه نمایش ها هماهنگ می شود و اصلا کاری به رزولوشن ندارد.

m.4.r.m
چهارشنبه 11 دی 1392, 14:47 عصر
Dim screenwidth,screenheight As Single

screenwidth = Screen.Width \ Screen.TwipsPerPixelX
screenheight = Screen.Height \ Screen.TwipsPerPixelY

hmbarnamenevis
چهارشنبه 11 دی 1392, 15:08 عصر
این کد شما که هیچ تغییری در اندازه فرم نخواهد داد!!

SlowCode
چهارشنبه 11 دی 1392, 17:19 عصر
این کد شما که هیچ تغییری در اندازه فرم نخواهد داد!!
خب مشخصه! این کد رزولیشن مانتیور رو به شما تحویل میده!
ببین شما خودت باید یه رابطه ای بین رزولیشن صفحه و اشیاء و عناصر برنامت پیدا کنی!
همه چیز ربط داره به ظاهر برنامت و ساختارشون.
ما که برنامه شما رو ندیدیم!

شما 2 راه داری:
1- با درصد کار کنی(مثلا اندازه فلان دکمه ها رو مثلا 10درصد width صفحه بزار) یا هرطور که خواستین و مناسب دیدین.
2-یه چیزی مثل طراحی ریسپانسیو تو صفحات وب! یعنی شما رزولیشن های مختلف رو بررسی میکنی و مثلا واسه رزولیشن های تو رنج فلان یه خاصیت هایی رو تنظیم میکنی، یا مثلا یه قسمت ها رو تغییر یا پنهان میکنی.


Dim screenwidth,screenheight As Single

screenwidth = Screen.Width \ Screen.TwipsPerPixelX
screenheight = Screen.Height \ Screen.TwipsPerPixelY

فقط یه نکته هست، اونم اینه که تو خط اول متغیر اول به عنوان variant در نظر گرفته میشه نه single

Fereshte.T
چهارشنبه 11 دی 1392, 17:50 عصر
سلام دوست عزیز
این یک نمونه از پروژه های خودمه که چند وقت پیش نوشتمش، شما به همین روش میتونی اندازه تمام کنترل های روی فرمتو کنترل کنی...
البته اگر الآن با آرایه ها آشنا باشی میتونی این کدهارو توی ده خط خلاصش کنی.
امیدوارم به کارت بیاد
موفق باشی

ma.andishe
شنبه 14 دی 1392, 08:32 صبح
Option Explicit

Public iHeight As Integer
Public iWidth As Integer
Public x_size As Double
Public y_size As Double
Public List() As Control
Public curr_obj As Object

Public Type RECT
X1 As Long
Y1 As Long
X2 As Long
Y2 As Long
End Type

Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, rectangle As RECT) As Long

Public Sub UserForm_Activate(UserForm1 As Form)
Dim R As RECT
Dim hwnd As Long
Dim RetVal As Long
Dim ScrRes As String
Dim FtSz As Integer
Dim curScreen As Object

hwnd = GetDesktopWindow()
RetVal = GetWindowRect(hwnd, R)

ScrRes = (R.X2 - R.X1) & "X" & (R.Y2 - R.Y1)

'Use ScrRes variable to decide how to size the userform.

If ScrRes = "640X480" Then
With UserForm1
UserForm1.Width = 7680
UserForm1.Height = 5760
End With
End If
If ScrRes = "800X600" Then
With UserForm1
UserForm1.Width = 11000
UserForm1.Height = 7000
End With
ElseIf ScrRes = "1024X768" Then
With UserForm1
UserForm1.Width = 12288
UserForm1.Height = 9612
End With
ElseIf ScrRes = "1280X800" Then
With UserForm1
UserForm1.Width = 15360
UserForm1.Height = 9600
End With

ElseIf ScrRes = "1360X768" Then
With UserForm1
UserForm1.Width = 16320
UserForm1.Height = 9612
End With

ElseIf ScrRes = "1680X1050" Then
With UserForm1
UserForm1.Width = 16800
UserForm1.Height = 10500
End With
End If

If ScrRes = "1600X900" Then
With UserForm1
UserForm1.Width = 16000
UserForm1.Height = 9000
End With

End If

' For Each curScreen In UserForm1
' ScrRes = curScreen.WorkingArea.Width.ToString + "X" + curScreen.WorkingArea.Height.ToString
'
' Select Case ScrRes
' Case "1024X768"
' End Select
' Next

End Sub

'Public Function FontSize()
'
'' Make sure x_size is greater than zero
'If Int(x_size) > 0 Then
''Set the font size
'FontSize = Int(x_size *
'End If
'End Function

Public Sub ResizeFormControls(frm As Form)

Dim I As Integer

'Set the forms height
' frm.Height = Screen.Height / 2
' 'Set the forms width
' frm.Width = Screen.Width / 2

iHeight = frm.Height
iWidth = frm.Width

'Get ratio of initial form size to current form size
x_size = frm.Height / iHeight
y_size = frm.Width / iWidth

'Loop through all the objects on the form
'Based on the upper bound of the # of controls
For I = 0 To UBound(List)
'Each control individually
For Each curr_obj In frm
'Check to make sure its the right control
If curr_obj.TabIndex = List(I).Index Then
'Resize control
With curr_obj
.Left = List(I).Left * y_size
.Width = List(I).Width * y_size
.Height = List(I).Height * x_size
.Top = List(I).Top * x_size
End With
End If
'Get next control
Next curr_obj
Next I

End Sub


اینو تو یه ماژول بنویس بعدش فرم رو به او پاس بده

navaroo
یک شنبه 13 مهر 1393, 12:03 عصر
جناب اندیشه سلام
اگه امکان داره ماژولتون رو طی یه پروژه اجرا کنید و بزارید . هرکاری کردم اجرایی نشد.
با تشکر

dividotaa
دوشنبه 14 مهر 1393, 18:45 عصر
چرا با این کد ها تو یه دکمه دستور دایره میدیم و بعد از اجرا دستور پرینت میدیم دایره ها را بیضی میگیره

dividotaa
دوشنبه 14 مهر 1393, 18:46 عصر
Option Explicit

Private Sub chap_Click()

Printer.Width = 14000
Printer.Height = 18000
Printer.Zoom = 100



Printer.PaintPicture Form1.Image, 100, 100, _
12600, 17350, 200, 200

Printer.EndDoc
End
End Sub


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx.Text = ""
yy.Text = ""
xx.Text = Form1.Width
yy.Text = Form1.Height

End Sub

Private Sub rasme_Click()
Dim r As Single
Dim b As Single
For r = 1000 To 6000 Step 500
DrawWidth = 5
Circle (0, 0), r, vbBlack
Next r

DrawWidth = 5
Form1.Line (0, 0)-(6000, 6000), vbRed

End Sub

Private Sub Form_Load()
Form1.Top = 0
Form1.Left = 0
Form1.Height = Screen.Height
Form1.Width = Screen.Width
Dim c As Single
c = Form1.Height / Form1.Width
Form1.Scale (-10000, 10 * c)-(10000, -10 * c)

End Sub