![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
"приклеивание" окна к краям экрана [Delphi, Windows]
Aotd © (2003-10-05 18:59:00)Для "приклеивания" окна к краям экрана использую процедуру:
procedure WMExitSizeMove(var Msg:TMessage);message WM_ExitSizeMove;
...
procedure TForm1.WMExitSizeMove;
const a=20;
var WorkArea:TRect;
begin
inherited;
SystemParametersInfo(SPI_GETWORKAREA,0,@WorkArea,0);
if left<=a then left:=0;
if top<=a then top:=0;
if left>=screen.width-width-a then left:=screen.width-width;
if top>=screen.height-height-a then top:=screen.height-height;
if Abs(Left-WorkArea.Left)<=a then Left:=WorkArea.Left;
if Abs(Top-WorkArea.Top)<=a then Top:=WorkArea.Top;
if Abs(Left+Width-WorkArea.Right)<=a then Left:=WorkArea.Right-Width;
if Abs(Top+Height-WorkArea.Bottom)<=a then Top:=WorkArea.Bottom-Height;
Invalidate;
end;
При адаптации под KOL она приобрела следующий вид:
procedure WMExitSizeMove(var Msg:TMessage);message WM_ExitSizeMove end;
...
Procedure TFMain.WMExitSizeMove;
const a=20;
var WorkArea:TRect;
begin
inherited;
SystemParametersInfo(SPI_GETWORKAREA,0,@WorkArea,0);
if FMain.Form.left<=a then FMain.Form.left:=0;
if FMain.Form.top<=a then FMain.Form.top:=0;
if FMain.Form.left>=KOL.ScreenWidth-FMain.Form.width-a then FMain.Form.left:=KOL.ScreenWidth-FMain.Form.width;
if FMain.Form.top>=KOL.ScreenHeight-FMain.Form.height-a then FMain.Form.top:=KOL.ScreenHeight-FMain.Form.height;
if Abs(FMain.Form.Left-WorkArea.Left)<=a then FMain.Form.Left:=WorkArea.Left;
if Abs(FMain.Form.Top-WorkArea.Top)<=a then FMain.Form.Top:=WorkArea.Top;
if Abs(FMain.Form.Left+FMain.Form.Width-WorkArea.Right)<=a then FMain.Form.Left:=WorkArea.Right-FMain.Form.Width;
if Abs(FMain.Form.Top+FMain.Form.Height-WorkArea.Bottom)<=a then FMain.Form.Top:=WorkArea.Bottom-FMain.Form.Height;
FMain.Form.Invalidate;
end;
Но отказывается выполнять свое предназначение... Не подскажете в чем дело? С KOL я знаком 3-й день, посему прошу не судить меня слишком стро
SerB (2003-10-09 05:43:00) [1]Опять поспешил, все работает нормально, забыл "подключить" функцию к свойству KOLForm OnMessage в инспекторе объектов :(
SerB (2003-10-09 05:33:00) [2]Вроде все нормально с кодом но (D7, KOL_MCK) не хочет работать
Aotd (2003-10-08 11:34:00) [3]Всем спасибо, разобрался ;)
Boguslaw (2003-10-06 20:23:00) [4]Try this:
function TForm1.KOLFormMessage(var Msg: tagMSG;
var Rslt: Integer): Boolean;
const a=20;
var WorkArea:TRect;
begin
Result := false;
if Msg.message = WM_EXITSIZEMOVE then begin
SystemParametersInfo(SPI_GETWORKAREA,0,@WorkArea,0);
with Form^ do begin
if left<=a then left:=0;
if top<=a then top:=0;
if left>= KOL.ScreenWidth-width-a then left:=KOL.ScreenWidth-width;
if top>= KOL.ScreenHeight -height-a then top:= KOL.ScreenHeight-height;
if Abs(Left-WorkArea.Left)<=a then Left:=WorkArea.Left;
if Abs(Top-WorkArea.Top)<=a then Top:=WorkArea.Top;
if Abs(Left+Form.Width-WorkArea.Right)<=a then Left:=WorkArea.Right-Width;
if Abs(Top+Height-WorkArea.Bottom)<=a then Top:=WorkArea.Bottom-Height;
Invalidate;
Result := true;
end;
end;
Just a 5 minute solution , but it works for me ;-)
You should fix one problem here (if You want) - it ignores desktop toolbar.
Gandalf (2003-10-05 21:05:00) [5]
> procedure WMExitSizeMove(var Msg:TMessage);message WM_ExitSizeMove
> end;
> ...
> Procedure TFMain.WMExitSizeMove;
> const a=20;
> var WorkArea:TRect;
Что то мне это не нравится, в KOL обработка событий идет через OnMessage...
http://kol.mastak.ru/FAQ.htm#1