?
Solved

Detect/trigger change of resolution/color

Posted on 1997-08-30
5
Medium Priority
?
214 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 420 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 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