Einzelnen Beitrag anzeigen

venice2
(Gast)

n/a Beiträge
 
#33

AW: Delphi 11 (Patch 1) zerstört Formulare

  Alt 9. Nov 2021, 14:18
Habe ich 100 Button auf der Form und setze diese alle Händisch bei jedem Resize, na dann viel Spaß dabei wenn man nicht selbst ein Anchor
Danke, den habe ich. Aber nicht so, wie du schreibst.
Na dann

So mache ich es. (Nicht für VCL gedacht)
Für die die es Interessiert.

Delphi-Quellcode:
// Anchor ENUM-Callback-Funktion
function AnchorEnum(WinHandle: HWND; lp: lParam): HWND; stdcall;
var
  pr: TRect;
  rc: TRect;
  pP: integer;
  X, Y, xW, yH: integer;

begin

  if IsIconic(GetParent(WinHandle)) then
  begin
    // Stope Aufzaehlung
    Result := integer(False);
    Exit;
  end;

  pP := SkinEngine.AnchorItem(WinHandle);
  if pP > -1 then
    if gProp[pP].anchor > ANCHOR_NONE then
    begin
      GetClientRect(WinHandle, rc);
      GetClientRect(GetParent(WinHandle), pr);

      X := 0;
      Y := 0;
      xW := 0;
      yH := 0;

      case gProp[pP].anchor of

        ANCHOR_WIDTH: //= 1
          begin
            X := gProp[pP].rc.Left;
            Y := gProp[pP].rc.Top;
            xW := MAX(pr.Right - gProp[pP].rc.Left - gProp[pP].rc.Right, 0);
            yH := rc.Bottom;
          end;
        ANCHOR_RIGHT: //= 2
          begin
            X := pr.Right - rc.Right - gProp[pP].rc.Right;
            Y := gProp[pP].rc.Top;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_CENTER_HORZ: //= 3
          begin
            X := (pr.Right div 2) + gProp[pP].centerx;
            Y := gProp[pP].rc.Top;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_HEIGHT: //= 4
          begin
            X := gProp[pP].rc.Left;
            Y := gProp[pP].rc.Top;
            xW := rc.Right;
            yH := MAX(pr.Bottom - gProp[pP].rc.Top - gProp[pP].rc.Bottom, 0);
          end;
        ANCHOR_HEIGHT_WIDTH: //= 5
          begin
            X := gProp[pP].rc.Left;
            Y := gProp[pP].rc.Top;
            xW := MAX(pr.Right - gProp[pP].rc.Left - gProp[pP].rc.Right, 0);
            yH := MAX(pr.Bottom - gProp[pP].rc.Top - gProp[pP].rc.Bottom, 0);
          end;
        ANCHOR_HEIGHT_RIGHT: //= 6
          begin
            X := pr.Right - rc.Right - gProp[pP].rc.Right;
            Y := gProp[pP].rc.Top;
            xW := rc.Right;
            yH := MAX(pr.Bottom - gProp[pP].rc.Top - gProp[pP].rc.Bottom, 0);
          end;
        ANCHOR_BOTTOM: //= 7
          begin
            X := gProp[pP].rc.Left;
            Y := pr.Bottom - gProp[pP].rc.Bottom - rc.Bottom;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_BOTTOM_WIDTH: //= 8
          begin
            X := gProp[pP].rc.Left;
            Y := pr.Bottom - gProp[pP].rc.Bottom - rc.Bottom;
            xW := MAX(pr.Right - gProp[pP].rc.Left - gProp[pP].rc.Right, 0);
            yH := rc.Bottom;
          end;
        ANCHOR_BOTTOM_RIGHT: //= 9
          begin
            X := pr.Right - rc.Right - gProp[pP].rc.Right;
            Y := pr.Bottom - gProp[pP].rc.Bottom - rc.Bottom;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_CENTER_HORZ_BOTTOM: //= 10
          begin
            X := (pr.Right div 2) + gProp[pP].centerx;
            Y := pr.Bottom - gProp[pP].rc.Bottom - rc.Bottom;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_CENTER_VERT: //= 11
          begin
            X := gProp[pP].rc.Left;
            Y := (pr.Bottom - rc.Bottom) div 2;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_CENTER_VERT_RIGHT: //= 12
          begin
            X := pr.Right - rc.Right - gProp[pP].rc.Right;
            Y := (pr.Bottom - rc.Bottom) div 2;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
        ANCHOR_CENTER: //= 13
          begin
            X := (pr.Right div 2) + gProp[pP].centerx;
            Y := (pr.Bottom div 2) + gProp[pP].centery;
            xW := rc.Right;
            yH := rc.Bottom;
          end;
      end;
      if lp <> 0 then
        DeferWindowPos(lp, WinHandle, 0, X, Y, xW, yH, SWP_NOZORDER or SWP_NOREDRAW)
      else
        MoveWindow(WinHandle, X, Y, xW, yH, False);
    end;

  Result := integer(True);

end;

Geändert von venice2 ( 9. Nov 2021 um 17:37 Uhr)
  Mit Zitat antworten Zitat