Главная страница
    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.45 MB
Время: 0.033 c
3-1102021579
ali_t
2004-12-03 00:06
2005.01.02
sql запрос в TQuery


1-1103108075
pashtet
2004-12-15 13:54
2005.01.02
Как программно вытащить номер звонящего с модема?


6-1095142357
Vit@ly
2004-09-14 10:12
2005.01.02
Как заставить "Сетевое окружение"


1-1103294334
Nata
2004-12-17 17:38
2005.01.02
RXlib


14-1102938286
Sandman25
2004-12-13 14:44
2005.01.02
Тест на грамотность





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский