View Full Version : تغییر رزولوشن ....
uliya110
جمعه 08 آبان 1388, 01:43 صبح
چطور می شه رزولوشن رو هنگام باز شدن برنامه , به اندازه دلخواه تغییر داد و سپس موقع بسته شدن یا مینیمایز شدن, به اندازه قبلی برگرده .
reza1944
جمعه 08 آبان 1388, 03:44 صبح
ميتونه مقدار قبلي رو از
My.Computer.Screen اونجا ذخيره كن توي متغير
بعد يه كلاس
Imports System.Runtime.InteropServices
Public Class Scr_resolation
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Friend Structure DEVMODE
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Public dmDeviceName As String
Public dmSpecVersion As Short
Public dmDriverVersion As Short
Public dmSize As Short
Public dmDriverExtra As Short
Public dmFields As Integer
Public dmPositionX As Integer
Public dmPositionY As Integer
Public dmDisplayOrientation As Integer
Public dmDisplayFixedOutput As Integer
Public dmColor As Short
Public dmDuplex As Short
Public dmYResolution As Short
Public dmTTOption As Short
Public dmCollate As Short
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Public dmFormName As String
Public dmLogPixels As Short
Public dmBitsPerPel As Short
Public dmPelsWidth As Integer
Public dmPelsHeight As Integer
Public dmDisplayFlags As Integer
Public dmDisplayFrequency As Integer
Public dmICMMethod As Integer
Public dmICMIntent As Integer
Public dmMediaType As Integer
Public dmDitherType As Integer
Public dmReserved1 As Integer
Public dmReserved2 As Integer
Public dmPanningWidth As Integer
Public dmPanningHeight As Integer
End Structure
Friend Class NativeMethods
' PInvoke declaration for EnumDisplaySettings Win32 API
<DllImport("user32.dll", CharSet:=CharSet.Ansi)> _
Public Shared Function EnumDisplaySettings( _
ByVal lpszDeviceName As String, _
ByVal iModeNum As Integer, _
ByRef lpDevMode As DEVMODE) As Integer
End Function
' PInvoke declaration for ChangeDisplaySettings Win32 API
<DllImport("user32.dll", CharSet:=CharSet.Ansi)> _
Public Shared Function ChangeDisplaySettings( _
ByRef lpDevMode As DEVMODE, _
ByVal dwFlags As Integer) As Integer
End Function
End Class
Public Class ResolutionChanger
Private Shared Function CreateDevMode() As DEVMODE
Dim dm As New DEVMODE
dm.dmDeviceName = New String(New Char(32) {})
dm.dmFormName = New String(New Char(32) {})
dm.dmSize = CShort(Marshal.SizeOf(dm))
Return dm
End Function
Public Enum DisplayChangeResultCode
DISP_CHANGE_SUCCESSFUL = 0
DISP_CHANGE_RESTART = 1
DISP_CHANGE_FAILED = -1
DISP_CHANGE_BADMODE = -2
DISP_CHANGE_NOTUPDATED = -3
DISP_CHANGE_BADFLAGS = -4
DISP_CHANGE_BADPARAM = -5
DISP_CHANGE_BADDUALVIEW = -6
End Enum
Public Shared Sub ChangeResolution(ByVal width As Integer, ByVal height As Integer, ByVal freq As Integer)
Const DM_PELSWIDTH As Integer = &H80000
Const DM_PELSHEIGHT As Integer = &H100000
Const DM_DISPLAYFREQUENCY As Integer = &H400000
Const ENUM_CURRENT_SETTINGS As Integer = -1
Dim DevM As DEVMODE = CreateDevMode()
Dim enumResult As Integer
Dim changeResult As DisplayChangeResultCode
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY
enumResult = NativeMethods.EnumDisplaySettings(Nothing, ENUM_CURRENT_SETTINGS, DevM)
DevM.dmPelsWidth = width
DevM.dmPelsHeight = height
DevM.dmDisplayFrequency = freq
changeResult = CType(NativeMethods.ChangeDisplaySettings(DevM, 0), DisplayChangeResultCode)
If changeResult <> DisplayChangeResultCode.DISP_CHANGE_SUCCESSFUL Then
Throw New Exception("Failed to change resolution: " & changeResult.ToString)
End If
End Sub
End Class
End Class
بعد استفاده كن و لذت ببر
elnazii
یک شنبه 06 دی 1388, 14:26 عصر
لطفا طرز استفاده از اين كد رو مفصلا بگيد.
چطور فراخوانيش كنيم و يا چه طور مقدار my.computer.screen رو ذخيره كنيم؟
ممنون
majid_vb_2008
یک شنبه 06 دی 1388, 20:38 عصر
چطور می شه رزولوشن رو هنگام باز شدن برنامه , به اندازه دلخواه تغییر داد و سپس موقع بسته شدن یا مینیمایز شدن, به اندازه قبلی برگرده .
سلام دوست من اگر جستجو مي كردي زود تر به نتيجه مي رسد
http://barnamenevis.org/forum/showpost.php?p=852775&postcount=2
Navid Asadi
دوشنبه 07 دی 1388, 14:34 عصر
بابا خدا وکیلی موضوع اینقدر تکراری میشه...
تو تاپیک کد های مفید پیداش میکنی...
saadi2
چهارشنبه 09 دی 1388, 09:24 صبح
http://barnamenevis.org/forum/showpost.php?p=870684&postcount=15
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.