Solved

Detect/trigger change of resolution/color

Posted on 1997-08-30
5
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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