Page 1 of 2
Form Transparent

Posted:
June 27th, 2006, 8:45 am
by Sina
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

Posted:
June 27th, 2006, 12:41 pm
by Johnny_Bit
get ussed to it. really, there's no other way... maybe you should check you hardware rather than software

Posted:
June 27th, 2006, 11:53 pm
by kokkoras
It's mainly a matter of how powerfull is your VGA card.
Maybe!

Posted:
June 30th, 2006, 5:41 am
by Sina
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 !


Posted:
June 30th, 2006, 7:28 am
by kokkoras
DirectX and/or OpenGL comes in mind. Sorry, can't help nore.

Posted:
June 30th, 2006, 9:13 am
by Johnny_Bit
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

Posted:
June 30th, 2006, 1:32 pm
by kokkoras
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).

Posted:
June 30th, 2006, 4:01 pm
by Kambiz
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.
?

Posted:
July 1st, 2006, 8:09 am
by Sina
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

Posted:
July 1st, 2006, 12:54 pm
by kokkoras
By the way, I had alpha blending in mind.
Re: ?

Posted:
July 1st, 2006, 6:02 pm
by Kambiz
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.

Posted:
July 1st, 2006, 6:15 pm
by Kambiz
Here is a sample:

Thanks

Posted:
July 2nd, 2006, 9:17 am
by Sina
Thank you I'll try it

Posted:
July 9th, 2006, 7:56 am
by Sina
Mr.Kambiz would you plz release the sample program code {one in your previous post picture}
?
//////////////
Thanx

Posted:
August 4th, 2006, 12:54 pm
by Kambiz
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.