Me gustaria saber como puedo cambiar el minitor de "Color verdadero" a "256 colores" mediante código y usando Delphi5.
1 Respuesta
Respuesta de antipauli
1
1
antipauli, Analista/Programador de Sistemas Oracle
Aqui tienes un ejemplo, de EnumDisplaySettings y ChangeDisplaySettings: - Pon un TListView (ListView1) y un TButton (Button1) en tu form - Declara este array en el private de tu form: private { Private declarations } DevMode : array[0..20] of TDevMode; - Pon esto en el OnCreate de tu form: procedure TForm1.FormCreate(Sender: TObject); begin ListView1.ViewStyle := vsReport; ListView1.RowSelect := TRUE; ListView1.Columns.Add; ListView1.Columns.Add; ListView1.Columns.Add; ListView1.Columns[0].Caption := 'Width x Height'; ListView1.Columns[0].Width := 100; ListView1.Columns[1].Caption := 'Colores'; ListView1.Columns[1].Width := 100; ListView1.Columns[2].Caption := 'Frecuencia'; ListView1.Columns[2].Width := 100; end; - Esto otro en el OnCLick de Button1: procedure TForm1.Button1Click(Sender: TObject); var tmpStr1, tmpStr2, tmpStr3 : String; tmpDC : HDC; x, Selection, cxScreen, cyScreen, Resolution : Integer; begin tmpDC := getDC(Handle); try cxScreen := GetSystemMetrics(SM_CXSCREEN); cyScreen := GetSystemMetrics(SM_CYSCREEN); Resolution := GetDeviceCaps(tmpDC, BITSPIXEL); finally ReleaseDC(Handle, tmpDC); end; ListView1.Items.Clear; x := 0; while EnumDisplaySettings(nil,x,DevMode[x]) do begin tmpStr1 := IntToStr(DevMode[x].dmPelsWidth)+ 'x'+ IntToStr(DevMode[x].dmPelsHeight); case DevMode[x].dmBitsPerPel of 4 : tmpStr2 := '16 Colores'; 8 : tmpStr2 := '256 Colores'; 16 : tmpStr2 := 'High Color (16 Bit)'; 32 : tmpStr2 := 'True Color (32 Bit)'; end; tmpStr3:=IntToStr( DevMode[x].dmDisplayFrequency); with ListView1.Items.Add do begin Caption := tmpStr1; SubItems.Add(tmpStr2); SubItems.Add(tmpStr3); end; if ( cxScreen = DevMode[x].dmPelsWidth ) and ( cyScreen = DevMode[x].dmPelsHeight ) and ( Resolution = DevMode[x].dmBitsPerPel ) then Selection := x; inc(x); if x = 20 then Break; end; ActiveControl := ListView1; ListView1.Selected := ListView1.Items.Item[Selection]; end; - Y por fin, esto otro en el OnDblClick de ListView1: procedure TForm1.ListView1DblClick(Sender: TObject); var tmpDevMode : TDevMode; begin tmpDevMode := DevMode[ListView1.Items.IndexOf(ListView1.Selected)]; tmpDevMode.dmFields := DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT or DM_DISPLAYFLAGS or DM_DISPLAYFREQUENCY; if ChangeDisplaySettings(tmpDevMode, CDS_TEST) = DISP_CHANGE_SUCCESSFUL then ChangeDisplaySettings(tmpDevMode, CDS_UPDATEREGISTRY); end; De parte de Radikal - www.q3.nu