• Olá Visitante, se gosta do forum e pretende contribuir com um donativo para auxiliar nos encargos financeiros inerentes ao alojamento desta plataforma, pode encontrar mais informações sobre os várias formas disponíveis para o fazer no seguinte tópico: leia mais... O seu contributo é importante! Obrigado.

Altera Resolução de Tela

helldanger1

GForum VIP
Entrou
Ago 1, 2007
Mensagens
29,631
Gostos Recebidos
1
O exemplo a seguir, que pode ser melhorado, leva dois botões no form e mostra um caminho para se alterar a resolução de tela, de acordo com uma das opções fornecidas pelo usuário ao Windows:


//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

HDC Video = GetDC(NULL);
int horizontal=GetDeviceCaps(Video,HORZRES);
int vertical=GetDeviceCaps(Video,VERTRES);
// int freq=GetDeviceCaps(Video,VREFRESH); // apenas para Windows NT
ReleaseDC(NULL, Video);
horizontal=1024;
vertical=768;
DEVMODE dvmd;
ZeroMemory(&dvmd, sizeof(DEVMODE));
dvmd.dmSize = sizeof(DEVMODE);
dvmd.dmPelsWidth = horizontal;
dvmd.dmPelsHeight = vertical;
// dvmd.dmDisplayFrequency = freq;
dvmd.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
ChangeDisplaySettings(&dvmd, 0);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
HDC Video = GetDC(NULL);
int horizontal=GetDeviceCaps(Video,HORZRES);
int vertical=GetDeviceCaps(Video,VERTRES);
// int freq=GetDeviceCaps(Video,VREFRESH);
ReleaseDC(NULL, Video);
horizontal=800;//1024; // 640;
vertical=600;//768; // 480;
DEVMODE dvmd;
ZeroMemory(&dvmd, sizeof(DEVMODE));
dvmd.dmSize = sizeof(DEVMODE);
dvmd.dmPelsWidth = horizontal;
dvmd.dmPelsHeight = vertical;
// dvmd.dmDisplayFrequency = freq;
dvmd.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
ChangeDisplaySettings(&dvmd, 0);
}


//---------------------------------------------------------------------------
 
Topo