Solved

Detect/trigger change of resolution/color

Posted on 1997-08-30
5
209 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

805 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