Dim dd As DirectDraw7, dx As New DirectX7
Set dd = dx.DirectDrawCreate("")
Call dd.SEtDisplayMode(A, B, Color, 0, DDSDM_DEFAULT)
Смена разрешения
Извините за глупый вопрос. Как сменить разрешение (VB6)?
EnumDisplaySettings, ChangeDisplaySettings :D
Извини, конечно, но я еще НИКОГДА не использовал API. Объясни подробно, пожалуйста, если тебе нетрудно.
смотри справку MS SDK, там всё написано
да вроде не такие трудные функции......
Код:
Здесь А и В - кол-во пикселей по X и Y соответсвенно, Color - глубина цвета (в битах). Переменные объявить надо в General - иначе вылетит обратно
Конечно, сначала нужно подключить DirectX7 (Project -> Preferences; DirectX 7 for Visual Basic Type Library)
ЗЫ. В ChangeDisplaySettings не возвращает настройки назад, а через DirectX - возвращает
А тебе так надо возвращать назад?Если ты пишешь игру,то DirectX-лучшее решение,а если нет-то WinAPI
Всем спасибо!
Еще один глупый вопрос - а как узнать текущее разрешение экрана и глубину цвета?:)
The EnumDisplaySettings function obtains information about one of a display device's graphics modes. You can obtain information for all of a display device's graphics modes by making a series of calls to this function.
BOOL EnumDisplaySettings(
LPCTSTR lpszDeviceName, // specifies the display device
DWORD iModeNum, // specifies the graphics mode
LPDEVMODE lpDevMode // points to structure to receive settings
);
Parameters
lpszDeviceName
Pointer to a null-terminated string that specifies the display device whose graphics mode the function will obtain information about.
This parameter can be NULL. A NULL value specifies the current display device on the computer that the calling thread is running on.
If lpszDeviceName is not NULL, the string must be of the form \\.\DisplayX, where X can have the values 1, 2, or 3.
Windows 95: lpszDeviceName must be NULL.
iModeNum
Index value that specifies the graphics mode for which information is to be obtained.
Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to EnumDisplaySettings, as follows: Set iModeNum to zero for the first call, and increment iModeNum by one for each subsequent call. Continue calling the function until the return value is FALSE.
When you call EnumDisplaySettings with iModeNum set to zero, the operating system initializes and caches information about the display device. When you call EnumDisplaySettings with iModeNum set to a non-zero value, the function returns the information that was cached the last time the function was called with iModeNum set to zero.
lpDevMode
Pointer to a DEVMODE structure into which the function stores information about the specified graphics mode.
The EnumDisplaySettings function sets values for the following five DEVMODE members:
dmBitsPerPel
dmPelsWidth
dmPelsHeight
dmDisplayFlags
dmDisplayFrequency
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
The function fails if iModeNum is greater than the index of the display device's last graphics mode. As noted in the description of the iModeNum parameter, you can use this behavior to enumerate all of a display device's graphics modes.
А это описание структуры DEVMODE:
typedef struct _devicemode { // dvmd
BCHAR dmDeviceName[CCHDEVICENAME];
WORD dmSpecVersion;
WORD dmDriverVersion;
WORD dmSize;
WORD dmDriverExtra;
DWORD dmFields;
short dmOrientation;
short dmPaperSize;
short dmPaperLength;
short dmPaperWidth;
short dmScale;
short dmCopies;
short dmDefaultSource;
short dmPrintQuality;
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
BCHAR dmFormName[CCHFORMNAME];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
DWORD dmDisplayFlags;
DWORD dmDisplayFrequency;
#if(WINVER >= 0x0400)
DWORD dmICMMethod; // Windows 95 only
DWORD dmICMIntent; // Windows 95 only
DWORD dmMediaType; // Windows 95 only
DWORD dmDitherType; // Windows 95 only
DWORD dmReserved1; // Windows 95 only
DWORD dmReserved2; // Windows 95 only
#endif /* WINVER >= 0x0400 */
} DEVMODE;
Наверное разберешсяс на скажу что те надо на всякий случай
DWORD dmBitsPerPel; //расширение
DWORD dmPelsWidth; // экрана
DWORD dmPelsHeight; //глубина цвета
это все что тебе надо... Обьявляешь структуру
DEVMODE dm;
потом вызываешь фанкцию
EnumDisplaySettings
и в структуре будут храниться нужные тебе данные
dm.dmPelsHeight; //глубина цвета и т. д.
Если что пиши...
Я ВБшник, поэтому приведу код на ВБ (для будущих поколений).
Код:
Type DEVMODE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmUnusedPadding As Integer
dmCollate As Integer
dmFormName As String * 32
dmBitsPerPixel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
' Только для Windows 95, 98, 2000
dmICMMethod As Long
dmICMIntent As Long
dmMediaType As Long
dmDitherType As Long
dmReserved1 As Long
dmReserved2 As Long
' Только для Windows 2000
dmPanningWidth As Long
dmPanningHeight As Long
End Type
Private Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
Dim dmode As DEVMODE, result as Long
Sub Razreshenie()
result = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dmode)
MsgBox Str(dmode.dmBitsPerPixel) + " " + Str(dmode.dmPelsHeight) + " " + Str(dmode.dmPelsWidth)
End Sub
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmUnusedPadding As Integer
dmCollate As Integer
dmFormName As String * 32
dmBitsPerPixel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
' Только для Windows 95, 98, 2000
dmICMMethod As Long
dmICMIntent As Long
dmMediaType As Long
dmDitherType As Long
dmReserved1 As Long
dmReserved2 As Long
' Только для Windows 2000
dmPanningWidth As Long
dmPanningHeight As Long
End Type
Private Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
Dim dmode As DEVMODE, result as Long
Sub Razreshenie()
result = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dmode)
MsgBox Str(dmode.dmBitsPerPixel) + " " + Str(dmode.dmPelsHeight) + " " + Str(dmode.dmPelsWidth)
End Sub
В ВБ нельзя, к сожалению, объявлять тип с неполным набором переменных (во как сказал).
Еще раз большое спасибо!:D