Solved

Detect/trigger change of resolution/color

Posted on 1997-08-30
5
207 Views
Last Modified: 2010-05-18
How can Delphi 3.0 detect whether the resolution and
colordepth has changed (e.g. with QUICKRES.EXE).

Actually I want to have my program invoke a procedure
which does some rearranging of labels and buttons and
so on. So, if someone changes the colordepth of Windows
and/or the resolution I want my program to automatically
execute a procedure in which the new colordepth must be
known.

I also like to know how I can perform the same operation
as quickres does.
0
Comment
Question by:yonasb
5 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1343084
I think you should built OnMessage event (see delphi help),
and do what you want to do when you get the message WM_DISPLAYCHANGE (see api help).
0
 
LVL 1

Expert Comment

by:sassas081597
ID: 1343085
I Think this is your case. A new form component, which can answer the message WM_DisplayChange.

WM_DISPLAYCHANGE
cBitsPerPixel = wParam;
cxScreen = LOWORD(lParam);
cyScreen = HIWORD(lParam);

unit sf;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TDForm = class(TFORM)
  private
    FOnDisplayChange: TNotifyEvent;
    procedure WMDisplayChanged(var Message: TMessage); message WM_DISPLAYCHANGE;
  protected
    procedure WndProc(var Message: TMessage); override;
  published
    property OnDisplayChange: TNotifyEvent read FOnDisplayChange write FOnDisplayChange stored IsForm;
  end;

procedure Register;

implementation

procedure TDForm.WndProc(var Message: TMessage);
begin
  with Message do
    case Msg of
      WM_DISPLAYCHANGE:
      begin
           {You can place the procedure or its part here}
      end;
  inherited WndProc(Message);
end;

{or let the user assign his own procedure}

procedure TDForm.WMDisplayChanged(var Message: TMessage);
begin
  inherited;
  if Assigned(FOnDisplayChange) then FOnDisplayChange(Self);
end;

procedure Register;
begin
  RegisterComponents('SAS', [TDForm]);
end;

end.
0
 

Author Comment

by:yonasb
ID: 1343086
Thank you for your component Sassa.
Rejecting it seems a bit hash, but
it didn't run on my system, so my
problem remains.

Is it Delphi 2.0 incompatible, but fine for
3.0?

Can you adjust it in such a way it will run under both?
(I've added some points, in fact all the few I have right now)



0
 

Author Comment

by:yonasb
ID: 1343087
Adjusted points to 215
0
 
LVL 4

Accepted Solution

by:
itamar earned 210 total points
ID: 1343088
This is a simple way to do it:
>>>>
unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
{
WM_DISPLAYCHANGE
cBitsPerPixel = wParam;
cxScreen = LOWORD(lParam);
cyScreen = HIWORD(lParam);
}

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
              protected
              procedure WndProc(var Message: TMessage); override;
      private
    { Private declarations }
  public
        { Public declarations }

      end;

var
      Form1: TForm1;

implementation

{$R *.DFM}
procedure TForm1.WndProc(var Message: TMessage);
begin
      If (Message.Msg = WM_DISPLAYCHANGE) Then
      begin
            Label1.Caption := IntToStr(Message.lParamLo) + ' X '+
                                                IntToStr(Message.lParamHi);
            Label2.Caption := IntToStr(Message.wParamLo);
      end;
      inherited WndProc(Message);
end;

end.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now