![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
SetWindowRgn
Merl © (2005-04-22 22:25:00)Скажите пожалуйста, каким образом можно установить произвольную форму окна - не эллипс, не круг, а именно произвольную - например, как в тех же скинах для винампа - они хранят информацию о регионах окна в файле Regions.txt.
Или хотя бы скажите, как чуть-чуть скруглить только края формы?
Хинт (2005-04-22 22:34:00) [1]Установка формы окна по изображению (маске)
procedure SetBitmapRgn(Image: TBitmap);
var
TmpRgn: HRGN;
x, y: integer;
ConsecutivePixels: integer;
CurrentPixel: TColor;
CurrentColor, TransColor: TColor;
Result:HRGN;
begin
Result := CreateRectRgn(0, 0, Image.Width, Image.Height);
if (Image.Width = 0) or (Image.Height = 0) then exit;
TransColor:=Image.Canvas.Pixels[0,0];
for y := 0 to Image.Height - 1 do
begin
CurrentColor := Image.Canvas.Pixels[0,y];
ConsecutivePixels := 1;
for x := 0 to Image.Width - 1 do
begin
CurrentPixel := Image.Canvas.Pixels[x,y];
if CurrentColor = CurrentPixel
then inc(ConsecutivePixels)
else begin
if CurrentColor = TransColor then
begin
TmpRgn := CreateRectRgn(x-ConsecutivePixels, y, x, y+1);
CombineRgn(Result, Result, TmpRgn, RGN_DIFF);
DeleteObject(TmpRgn);
end;
CurrentColor := CurrentPixel;
ConsecutivePixels := 1;
end;
end;
if (CurrentColor = TransColor) and (ConsecutivePixels > 0) then
begin
TmpRgn := CreateRectRgn(x-ConsecutivePixels, y, x, y+1);
CombineRgn(Result, Result, TmpRgn, RGN_DIFF);
DeleteObject(TmpRgn);
end;
end;
SetWindowRgn(Self.Handle, Result, True);
end;
Ученик (2005-04-22 22:32:00) [2]А как сделать круг ? Эллипс ?