Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#8

AW: Key's funktionieren nicht

  Alt 6. Apr 2018, 11:57
WM_GETDLGCODE könnte dir dabei helfen. Damit kannst du Windows Bescheid sagen, dass du bestimmte Systemtasten selber behandeln möchtest.
Über die Accelerator table?
Wenn ja muss ich mal testen Danke.

@jaenicke Super Idee, das war's.
In meiner DLL!

Delphi-Quellcode:
    WM_GETDLGCODE:
      begin
        result := DLGC_WANTALLKEYS or DLGC_WANTARROWS;
        exit;
      end;
Und Auswertung in der Anwendung.
Ohne Hook oder der gleichen.

Delphi-Quellcode:
      WM_KEYDOWN:
        begin
          ObjectID := gSprCtrl.GI_GetObjectFocusID;
          if ObjectID > 0 then
          begin
            gSprCtrl.GD_GetObjectXY(ObjectID, x, y);
            x1 := x;
            y1 := y;

            if gSprCtrl.GI_IsCtrlKeyPressed then
            begin
              UseStep := 4;
              if gSprCtrl.GI_IsShiftKeyPressed then
                UseStep := 16;
            end else
              if gSprCtrl.GI_IsShiftKeyPressed then
                UseStep := 2
            else
            UseStep := 1;

            if gSprCtrl.GD_GetObjectScroll(ObjectID) then
            begin
              gSprCtrl.GI_GetBitmapSize(gSprCtrl.GI_GetBMP(WinHandle), Width, Height);
            end else
            begin
              GetClientRect(WinHandle, rc);
              Width := rc.Right;
              Height := rc.Bottom;
            end;
            gSprCtrl.GD_GetObjectBound(ObjectID, BoundWidth, BoundHeight);

            x2Div2 := BoundWidth div 2;
            y2Div2 := BoundHeight div 2;

            case wp of
              VK_HOME:
                x1 := 0;
              VK_END:
                x1 := MAX(Width - BoundWidth, 0);
              VK_PRIOR:
                y1 := 0;
              VK_NEXT:
                y1 := MAX(Height - BoundHeight, 0);
              VK_LEFT, VK_NUMPAD4:
                if x1 > -x2Div2 then
                  x1 := MAX(x1 - UseStep, -x2Div2);
              VK_UP, VK_NUMPAD8:
                if y1 > -y2Div2 then
                  y1 := MAX(y1 - UseStep, -y2Div2);
              VK_RIGHT, VK_NUMPAD6:
                if x1 < Width - x2Div2 then
                  x1 := MIN(x1 + UseStep, Width - x2Div2);
              VK_DOWN, VK_NUMPAD2:
                if y1 < Height - y2Div2 then
                  y1 := MIN(y1 + UseStep, Height - y2Div2);
            end;

            if (x <> x1) or (y <> y1) then
            begin
              x := x1;
              y := y1;
              gSprCtrl.GD_SetObjectXY(ObjectID, x1, y1, true);
            end;
            sMessage := 'Object ' + IntToStr(ObjectID) + ' coordinates ' + IntToStr(x) + ',' + IntToStr(y);
            ShowTip(true, sMessage);
          end;
        end;
Hat sich erledigt..

SHIFT + CONTROL + VK_DOWN geht nun ohne Probleme.
Das verschieben des Objects findet dann mit 16Facher Geschwindigkeit statt.

gruss

Geändert von EWeiss ( 6. Apr 2018 um 12:20 Uhr)
  Mit Zitat antworten Zitat