Главная страница
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.047 c
1-1103294387
Frozzen
2004-12-17 17:39
2005.01.02
Не могу сделать перекодировку


14-1102650897
Думкин
2004-12-10 06:54
2005.01.02
С днем рождения! 10 декабря


3-1102427097
zom
2004-12-07 16:44
2005.01.02
Как в запросе использовать набор данных, возвращаемый sp_who2?


1-1103364229
Хакер
2004-12-18 13:03
2005.01.02
Сортировка строк и удаление дубликатов


14-1102938643
antonn
2004-12-13 14:50
2005.01.02
Звуки на мобилу