Главная страница
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.061 c
3-1102318362
Mid
2004-12-06 10:32
2005.01.02
проблема с таблицами


1-1103182543
ASMiD
2004-12-16 10:35
2005.01.02
Перехват операций с файлами


1-1103201990
SbtON
2004-12-16 15:59
2005.01.02
Можно ли добавить в процесс компонент NMFTP?


14-1102936256
Kolan
2004-12-13 14:10
2005.01.02
Ни как я с map ом не разберусь.


14-1102729271
avk02
2004-12-11 04:41
2005.01.02
Несколько цитат из Дугласа Адамса