أخي ، لا تنفع هذه لأنه سيقوم بحفظ الLeft,Top للForm وذلك عند تغيير الجهاز ستختلف TOp وleft
هذا كود استخرجته من أحد المكونات به مبتغاي لكن أنا لم أستطع التعامل معه وأوده داخل البرنامج وليس في مكون
كود :
procedure TNxAlertWindow.DoPopupTimer(Sender: TObject);
var
Delta, h, Y, Sound: Integer;
TaskbarRect: TRect;
TaskbarPosition: Integer;
begin
Delta := 0;
TaskbarPosition := FindTaskbar(TaskbarRect);
case TaskbarPosition of
ABE_BOTTOM, ABE_TOP: Delta := TaskbarRect.Bottom - TaskbarRect.Top;
ABE_LEFT, ABE_RIGHT: Delta := TaskbarRect.Right - TaskbarRect.Left;
end;
case FAlertDirection of
adUp:
if Height + 5 >= FRealHeight then { full open }
begin
case TaskbarPosition of
ABE_BOTTOM, ABE_LEFT, ABE_RIGHT:
begin
SetWindowPos(Handle, HWND_TOPMOST, GetPopupLeft,
(Screen.Height - delta) - FRealHeight - FIndent, Width, FRealHeight, SWP_SHOWWINDOW);
end;
ABE_TOP:
begin
SetWindowPos(Handle, HWND_TOPMOST, GetPopupLeft,
TaskbarRect.Bottom + FIndent, Width, FRealHeight, SWP_SHOWWINDOW);
end;
end;
FPopupTimer.Enabled := False;
FDelayTimer.Enabled := FCloseDelay <> -1;
FFullOpen := True;
DoPopup;
if FPopupSound <> msNone then { play sound }
begin
Sound := 0;
case FPopupSound of
msIconAsterisk: Sound := MB_ICONASTERISK;
msIconExclamation: Sound := MB_ICONEXCLAMATION;
msIconHand: Sound := MB_ICONHAND;
msIconQuestion: Sound := MB_ICONQUESTION;
msOk: Sound := MB_OK;
end;
MessageBeep(Sound);
end;
end else
begin { in progress }
case TaskbarPosition of
ABE_BOTTOM, ABE_LEFT, ABE_RIGHT:
begin
h := Height + 5;
Y := TaskbarRect.Top - h - FIndent;
end;
else {ABE_TOP}
begin
h := Height + 5;
Y := TaskbarRect.Bottom + FIndent;
end
end;
SetWindowPos(Handle, HWND_TOPMOST, GetPopupLeft, Y,
Width, h, SWP_SHOWWINDOW);
end;
adDown:
if Height <= 0 then
begin
DoClosed;
end else
begin
case TaskbarPosition of
ABE_BOTTOM, ABE_LEFT, ABE_RIGHT:
begin
h := Height - 5;
Y := TaskbarRect.Top - h - FIndent;
end;
else {ABE_TOP}
begin
h := Height - 5;
Y := TaskbarRect.Bottom + FIndent;
end;
end;
SetWindowPos(Handle, HWND_TOPMOST, GetPopupLeft, Y,
Width, h, SWP_SHOWWINDOW);
end;
end; { case }
end;