Solved

Detect/trigger change of resolution/color

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

22 Experts available now in Live!

Get 1:1 Help Now