Главная страница
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.035 c
4-1100520863
Tria
2004-11-15 15:14
2005.01.02
Как из моей проги открыть html-файл в броузере по-умолчанию?


14-1102571731
Dmitriy O.
2004-12-09 08:55
2005.01.02
Почему хранение данных в Эксель занимают так много места ?


3-1102386152
dolphin
2004-12-07 05:22
2005.01.02
таблица в таблице


14-1102777344
Gusto
2004-12-11 18:02
2005.01.02
ASMEdit 3.5 - GUI-оболочка ассемблера.


3-1102332746
Dimedrol
2004-12-06 14:32
2005.01.02
TTable дублирует записи в Grid-e...