Form Transparent

Please discuss general Delphi programming topics here.

Form Transparent

Postby Sina » June 27th, 2006, 8:45 am

HI
I have a problem :
when I enable form color transparent or alpha blend then at run time when i drag the form the dragging speed is low how can I prevent it?
any idea?
best regards
User avatar
Sina
Junior Member
Junior Member
 
Posts: 32
Joined: August 29th, 2005, 8:33 am
Location: United States

Postby Johnny_Bit » June 27th, 2006, 12:41 pm

get ussed to it. really, there's no other way... maybe you should check you hardware rather than software
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby kokkoras » June 27th, 2006, 11:53 pm

It's mainly a matter of how powerfull is your VGA card.
Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Maybe!

Postby Sina » June 30th, 2006, 5:41 am

well I've got a 128mb ATI VGA card and I don't think it is weak!
but there's something else is there any api doing transparency?
because I saw other programs using transparency with normal speed !
;)
User avatar
Sina
Junior Member
Junior Member
 
Posts: 32
Joined: August 29th, 2005, 8:33 am
Location: United States

Postby kokkoras » June 30th, 2006, 7:28 am

DirectX and/or OpenGL comes in mind. Sorry, can't help nore.
Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby Johnny_Bit » June 30th, 2006, 9:13 am

atually, there is. alphablend is pretty normal for windows, but to make special points invisible, you have to use some sick windows api, also remember that sometimes making things in pure winapi saves you many moments of "argh, this is so slow", so check msdn and have happy progamming
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby kokkoras » June 30th, 2006, 1:32 pm

Transparency exists since Win2K. I remember making transparent the windows of some nice tool apps (like the legendary Total Commander) by using some hacks but moving the transparent window around was like a slide show that time. It was quite acceptable though in an nVidia Ti4200 (that I still use BTW).
Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby Kambiz » June 30th, 2006, 4:01 pm

Which level of transparency you need?

If you don't need semi-transparency, you should use Windows regions to improve speed.

By the way, in opposite of alpha belending, all 32 bit version of Windows support regions.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

?

Postby Sina » July 1st, 2006, 8:09 am

Mr.Kambiz I need to hide one part of my form to make it more stylish I think it means full transparensy level
But I don't want to use win regions because my form doesn't want a simple shape
thanks
User avatar
Sina
Junior Member
Junior Member
 
Posts: 32
Joined: August 29th, 2005, 8:33 am
Location: United States

Postby kokkoras » July 1st, 2006, 12:54 pm

By the way, I had alpha blending in mind.
Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Re: ?

Postby Kambiz » July 1st, 2006, 6:02 pm

Sina wrote:Mr.Kambiz I need to hide one part of my form to make it more stylish I think it means full transparensy level
But I don't want to use win regions because my form doesn't want a simple shape
thanks


A region can be any complex shape. For example, look at the Office Assistant package, trancparency of each frame is achieved by applying a region. The oaBitmap unit of the package has some routines for creating a region from a bitmap.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Kambiz » July 1st, 2006, 6:15 pm

Here is a sample: ;)
Attachments
sample.jpg
Using region for transparency
sample.jpg (208.85 KiB) Viewed 7261 times
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Thanks

Postby Sina » July 2nd, 2006, 9:17 am

Thank you I'll try it
User avatar
Sina
Junior Member
Junior Member
 
Posts: 32
Joined: August 29th, 2005, 8:33 am
Location: United States

Postby Sina » July 9th, 2006, 7:56 am

Mr.Kambiz would you plz release the sample program code {one in your previous post picture}
?
//////////////
Thanx
User avatar
Sina
Junior Member
Junior Member
 
Posts: 32
Joined: August 29th, 2005, 8:33 am
Location: United States

Postby Kambiz » August 4th, 2006, 12:54 pm

Sorry for being so late. I was not on the forum for a while.

Code: Select all
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    btnClose: TButton;
    Image: TImage;
    procedure FormCreate(Sender: TObject);
    procedure btnCloseClick(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  oaBitmap;

procedure TForm1.FormCreate(Sender: TObject);
var
  rgnForm: HRGN;
  rgnTemp: HRGN;
begin
  BorderStyle := bsNone;
  with Image.Picture do
    rgnForm := CreateBitmapRgn(Bitmap, Bitmap.Canvas.Pixels[0,0]);
  rgnTemp := CreateRectRgnIndirect(btnClose.BoundsRect);
  try
    CombineRgn(rgnForm, rgnForm, rgnTemp, RGN_OR);
  finally
    DeleteObject(rgnTemp);
  end;
  SetWindowRgn(Handle, rgnForm, False);
  // Windows owns rgnForm, therefore we might not delete it.
end;

procedure TForm1.btnCloseClick(Sender: TObject);
begin
  Close;
end;

end.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Next

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron