Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Points for ptmcomp: Why setClassLong isn't working

Posted on 2000-05-06
1
Medium Priority
?
484 Views
Last Modified: 2012-06-27
Hi, ptmComp. Please post the same answer you gave to my othe question and I'll give you the points.

In Delphi 5 I'm using setClassLong to replace the window class background brush but it's not working. I tried with a solid brush and a bitmap brush.

var
brushBackGround : HBrush;
bm:graphics.tbitmap;
begin
bm := graphics.TBitmap.create;
try
bm.loadFromFile('patron1.bmp');
// brushBackGround := createPatternBrush(bm.handle);
brushBackGround := createSolidBrush(clRed);
setClassLong(application.handle,GCL_HBrBackGround,brushBackGround);
try
Application.Initialize;
Application.CreateForm(TForm1, Form1); // form1 is an empty form
// setClassLong(form1.handle,GCL_HBrBackGround,brushBackGround); tried this, didn't work neither
Application.Run;
finally
deleteObject(brushBackGround);
end;
finally
bm.Free;
end;
end.

0
Comment
Question by:ms99
1 Comment
 
LVL 10

Accepted Solution

by:
ptmcomp earned 100 total points
ID: 2785599
The problem is that Delphi overrides the WM_ERASEBKGND message handler.

procedure TWinControl.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  { Only erase background if we're not doublebuffering or painting to memory. }
  if not FDoubleBuffered or
    (TMessage(Message).wParam = TMessage(Message).lParam) then
    FillRect(Message.DC, ClientRect, FBrush.Handle); // here Delpi uses FBrush.Handle instead of the window class brush
  Message.Result := 1; // message handled
end;

If you want to change to color of your window class, change the color property in the constructor.

But this works:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.Brush.Bitmap:= TBitmap.Create;
  Form1.Brush.Bitmap.LoadFromFile('c:\winnt\Santa Fe-Stuck.bmp');
end;

Regards, ptm.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

916 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