Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to set the resolution of your screen Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
22-Jun-03
Category
System
Language
Delphi 3.x
Views
113
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Rainier Mertens

This article shows how to set the resolution of your screen I pasted my whole unit 
below.

Answer:

1   unit Unit4;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
7   StdCtrls,
8       ExtCtrls, Buttons;
9   
10  type
11    TForm4 = class(TForm)
12      ComboBox1: TComboBox;
13      BitBtn1: TBitBtn;
14      Bevel1: TBevel;
15      procedure ComboBox1Change(Sender: TObject);
16      procedure FormCreate(Sender: TObject);
17      procedure FormActivate(Sender: TObject);
18      procedure Label4Click(Sender: TObject);
19      procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
20        Shift: TShiftState; X, Y: Integer);
21      procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
22        Shift: TShiftState; X, Y: Integer);
23      procedure BitBtn1Click(Sender: TObject);
24      procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
25        Shift: TShiftState; X, Y: Integer);
26      procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
27        Shift: TShiftState; X, Y: Integer);
28    private
29      { Private declarations }
30    public
31      { Public declarations }
32    end;
33  
34  var
35    Form4: TForm4;
36    Modes: array[0..255] of TDevMode;
37  
38  implementation
39  
40  uses cliprex2;
41  
42  {$R *.DFM}
43  
44  procedure TForm4.ComboBox1Change(Sender: TObject);
45  begin
46    bitbtn1.Enabled := combobox1.ItemIndex >= 0;
47    bitbtn1.enabled := true;
48  end;
49  
50  procedure TForm4.FormCreate(Sender: TObject);
51  var
52    DC: THandle;
53    Bits: Integer;
54    HRes: Integer;
55    VRes: Integer;
56    DM: TDevMode;
57    ModeNum: LongInt;
58    Ok: Bool;
59    I: Byte;
60  begin
61  
62    DC := Canvas.Handle;
63    Bits := GetDeviceCaps(DC, BITSPIXEL);
64    HRes := GetDeviceCaps(DC, HORZRES);
65    VRes := GetDeviceCaps(DC, VERTRES);
66  
67    ModeNum := 0;
68    EnumDisplaySettings(nil, ModeNum, DM);
69    Modes[ModeNum] := DM;
70    Ok := True;
71    while Ok do
72    begin
73      Inc(ModeNum);
74      Ok := EnumDisplaySettings(nil, ModeNum, DM);
75      Modes[ModeNum] := DM;
76    end;
77  
78    for I := 0 to ModeNum - 1 do
79    begin
80      ComboBox1.Items.Add(Format('%d x %d, %d bits',
81        [TDevMode(Modes[I]).dmPelsWidth,
82        TDevMode(Modes[I]).dmPelsHeight,
83          TDevMode(Modes[I]).dmBitsPerPel]));
84      ComboBox1.ItemIndex := 0;
85    end;
86  end;
87  
88  procedure TForm4.FormActivate(Sender: TObject);
89  
90  var
91    DC: THandle;
92    Bits: Integer;
93    HRes: Integer;
94    VRes: Integer;
95  
96  begin
97  
98    DC := Canvas.Handle;
99    Bits := GetDeviceCaps(DC, BITSPIXEL);
100   HRes := GetDeviceCaps(DC, HORZRES);
101   VRes := GetDeviceCaps(DC, VERTRES);
102 
103   combobox1.text := Format('%d x %d, %d bits', [HRes, VRes, Bits]);
104   bitbtn1.enabled := false;
105 end;
106 
107 procedure TForm4.Label4Click(Sender: TObject);
108 begin
109   form4.hide;
110 end;
111 
112 procedure TForm4.Button1MouseDown(Sender: TObject; Button: TMouseButton;
113   Shift: TShiftState; X, Y: Integer);
114 begin
115   bitbtn1.Font.Color := clblue;
116 end;
117 
118 procedure TForm4.Button1MouseUp(Sender: TObject; Button: TMouseButton;
119   Shift: TShiftState; X, Y: Integer);
120 begin
121   bitbtn1.Font.Color := clblack;
122 end;
123 
124 procedure TForm4.BitBtn1Click(Sender: TObject);
125 var
126   NewMode: TDevMode;
127   ChResult: LongInt;
128 
129 begin
130   NewMode := TDevMode(Modes[ComboBox1.ItemIndex]);
131   NewMode.dmDisplayFrequency := 0;
132   NewMode.dmDisplayFlags :=
133     DM_BITSPERPEL and
134     DM_PELSWIDTH and
135     DM_PELSHEIGHT and
136     DM_DISPLAYFLAGS;
137   ChResult := ChangeDisplaySettings(NewMode, CDS_UPDATEREGISTRY);
138 
139   form4.hide;
140 end;
141 
142 procedure TForm4.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
143   Shift: TShiftState; X, Y: Integer);
144 begin
145   bitbtn1.font.color := clblue;
146 end;
147 
148 procedure TForm4.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
149   Shift: TShiftState; X, Y: Integer);
150 begin
151   bitbtn1.font.color := clblack;
152 end;
153 
154 end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC