Board index » delphi » BitBtn palette problem - 2nd posting

BitBtn palette problem - 2nd posting

Hello all,

I'm still having that problem with Delphi's default BitBtn glyphs
showing their olive-green backgrounds when running 16-bit Delphi
applications under my (not-so-) new machine with Win95.  The problem
doesn't happen in 32-bits, so I suspect there's some 16-bit DLL that's
causing the problem.

I'm running 16-bit (high) color at 1024 x 768 on a Matrox Millenium.

Any ideas?  I really need to get this going as I have to finish screen
shots for my app's help file and it really looks tacky.

Thanks in advance

Jim Stanley
Jacobs Engineering

 

Re:BitBtn palette problem - 2nd posting


Another clue in the continuing saga:  the bitmap colors start out okay,
but when I bring up particular forms the buttons start showing their
backgrounds and it stays that way in all windows until I close the
application.

Thanks again for any help

Jim Stanley
Jacobs Engineering

Re:BitBtn palette problem - 2nd posting


Quote
jim.stanley wrote:

> Hello all,

> I'm still having that problem with Delphi's default BitBtn glyphs
> showing their olive-green backgrounds when running 16-bit Delphi
> applications under my (not-so-) new machine with Win95.  The problem
> doesn't happen in 32-bits, so I suspect there's some 16-bit DLL that's
> causing the problem.

> I'm running 16-bit (high) color at 1024 x 768 on a Matrox Millenium.

> Any ideas?  I really need to get this going as I have to finish screen
> shots for my app's help file and it really looks tacky.

> Thanks in advance

> Jim Stanley
> Jacobs Engineering

Yes, I solved that problem.

The following example demonstrates a technique where the transparent
portion
of the glyph is filled with the background color of the button, making
the glyph
appear transparent.

function InitStdBitBtn(BitBtn : TBitBtn;
                       kind : TBitBtnKind) : bool;
var
  Bm1 : TBitmap;
  Bm2 : TBitmap;
begin
  Result := false;
  if Kind = bkCustom then exit;
  Bm1 := TBitmap.Create;
  case Kind of
    bkOK : Bm1.Handle := LoadBitmap(hInstance, 'BBOK');
    bkCancel : Bm1.Handle := LoadBitmap(hInstance, 'BBCANCEL');
    bkHelp : Bm1.Handle := LoadBitmap(hInstance, 'BBHELP');
    bkYes : Bm1.Handle := LoadBitmap(hInstance, 'BBYES');
    bkNo : Bm1.Handle := LoadBitmap(hInstance, 'BBNO');
    bkClose : Bm1.Handle := LoadBitmap(hInstance, 'BBCLOSE');
    bkAbort : Bm1.Handle := LoadBitmap(hInstance, 'BBABORT');
    bkRetry : Bm1.Handle := LoadBitmap(hInstance, 'BBRETRY');
    bkIgnore : Bm1.Handle := LoadBitmap(hInstance, 'BBIGNORE');
    bkAll : Bm1.Handle := LoadBitmap(hInstance, 'BBALL');
  end;
  Bm2 := TBitmap.Create;
  Bm2.Width := Bm1.Width;
  Bm2.Height := Bm1.Height;
  bm2.Canvas.Brush.Color := ClBtnFace;
  bm2.Canvas.BrushCopy(Rect(0, 0, bm2.Width, bm2.Height),
                       Bm1,
                       Rect(0, 0, Bm1.width, Bm1.Height),
                       bm1.canvas.pixels[0,0]);
  bm1.Free;
  LockWindowUpdate(BitBtn.Parent.Handle);
  BitBtn.Kind := kind;
  BitBtn.Glyph.Assign(bm2);
  LockWindowUpdate(0);
  bm2.Free;
  Result := true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  InitStdBitBtn(BitBtn1, bkOk);
end;

Joe
--
Joe C. Hecht
joehe...@gte.net
(850) 689-0877 121 Louise Dr. Crestview, FL 32536
http://home1.gte.net/joehecht/index.htm

Other Threads