Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.01.02;
Скачать: CL | DM;

Вниз

Формы   Найти похожие ветки 

 
[shade]   (2004-12-20 13:29) [0]

Здравствуйте, уважаемые тов. опытные программисты. У меня 2 вопроса:
1) Если у формы свойство borderstyle=none то как можно осуществить перетаскивание с помощью мыши;
2) Как сделать чтобы форма была не прямоугольный формы(отображалась как картинка)


 
antonn ©   (2004-12-20 13:34) [1]

1 - Запихать в обработчик OnMouseDown формы
const
SC_DRAGMOVE : Longint = $F012;
 begin
if Button <> mbRight then begin
ReleaseCapture;
SendMessage(Handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0);
end;

2 - создать регион

function TMainForm.BitmapToRgn(Image: TBitmap): HRGN;
var
 TmpRgn: HRGN;
 x, y: integer;
 ConsecutivePixels: integer;
 CurrentPixel: TColor;
 CreatedRgns: integer;
 CurrentColor: TColor;
begin
 CreatedRgns := 0;
 Result := CreateRectRgn(0, 0, Image.Width, Image.Height);
 inc(CreatedRgns);

 if (Image.Width = 0) or (Image.Height = 0) then
   exit;

 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 = clWhite then
       begin
         TmpRgn := CreateRectRgn(x-ConsecutivePixels, y, x, y+1);
         CombineRgn(Result, Result, TmpRgn, RGN_DIFF);
         inc(CreatedRgns);
         DeleteObject(TmpRgn);
       end;
       CurrentColor := CurrentPixel;
       ConsecutivePixels := 1;
     end;
   end;

   if (CurrentColor = clWhite) and (ConsecutivePixels > 0) then
   begin
     TmpRgn := CreateRectRgn(x-ConsecutivePixels, y, x, y+1);
     CombineRgn(Result, Result, TmpRgn, RGN_DIFF);
     inc(CreatedRgns);
     DeleteObject(TmpRgn);
   end;
 end;
end;

procedure TMainForm.RegionCreate;
begin
MainForm.BorderStyle:= bsNone;
SetWindowRgn(Handle,BitmapToRgn( MainFormImageRegion.Picture.Bitmap ) , true);
end;


 
TUser ©   (2004-12-20 13:46) [2]

1. Перекрыть обработчик wm_nchittest и прописать там
inherited;
Result:=htCaption;
2. Использовыать регионы



Страницы: 1 вся ветка

Текущий архив: 2005.01.02;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.053 c
6-1097249272
pirate
2004-10-08 19:27
2005.01.02
Узнать IP у удаленного компа(TCP/IP)


14-1102569513
Layner
2004-12-09 08:18
2005.01.02
ИТ-специалистов вытеснят новые технологии


4-1100149622
hyper_omsk
2004-11-11 08:07
2005.01.02
com и мобильник


1-1103207093
Bless
2004-12-16 17:24
2005.01.02
Что вызывается вместо inherited в данном случае?


1-1103186106
Mishenka
2004-12-16 11:35
2005.01.02
Добавление элементов в GroupBox?