Einzelnen Beitrag anzeigen

CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: Fenster an Bildschirmrand / Taskleiste andocken lassen

  Alt 3. Apr 2005, 10:38
Von idontwantaname kommt folgende Portierung als nonVCL-Variante:
Delphi-Quellcode:
function WndProc(WndHWND: HWnd; uMsg: UInt; wParam: WParam; lParam: LParam): LResult; stdcall;
const
  DISTANCE = 20;
var
  MyWndPos: PWindowPos;
  WorkAreaRect: TRect;
begin
   Result := 0;

   case uMsg of
    WM_WINDOWPOSCHANGING: begin
      // Nötige Informationen holen
      SystemParametersInfo(SPI_GETWORKAREA, 0, @WorkAreaRect, 0);
      MyWndPos := PWINDOWPOS(lParam);

      // Oben und Unten
      if (MyWndPos.y <= DISTANCE) and
         (MyWndPos.y >= -DISTANCE) then
           MyWndPos.y := 0;
      if (MyWndPos.y + MyWndPos.cy > (WorkAreaRect.Bottom - DISTANCE)) and
         (MyWndPos.y + MyWndPos.cy < (WorkAreaRect.Bottom + DISTANCE)) then
           MyWndPos.y := WorkAreaRect.Bottom - MyWndPos.cy;

      // Links und Rechts
      if (MyWndPos.x <= DISTANCE) and
         (MyWndPos.x >= -DISTANCE) then
           MyWndPos.x := 0;
      if (MyWndPos.x + MyWndPos.cx > (WorkAreaRect.Right - DISTANCE)) and
         (MyWndPos.x + MyWndPos.cx < (WorkAreaRect.Right + DISTANCE)) then
           MyWndPos.x := WorkAreaRect.Right - MyWndPos.cx;
    end;

    WM_DESTROY: begin
      PostQuitMessage(0);
    end;

     else Result := DefWindowProc(WndHWND, uMsg, wParam, lParam);
   end;
end;
  Mit Zitat antworten Zitat