Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Points for ptmcomp: Why setClassLong isn't working

Posted on 2000-05-06
1
Medium Priority
?
473 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
[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
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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

670 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