Q&A

  • DBGrid에서 휠마우스 사용
DBGrid에서 휠마우스를 사용하려면

procedure TForm1.AnyMessage(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_MouseWheel then
if ActiveControl is TDBgrid then
   begin
     if Msg.wParam > 0 then
     begin
       keybd_event(VK_UP, VK_UP, 0, 0);
       keybd_event(VK_UP, VK_UP, KEYEVENTF_KEYUP, 0);
     end
   else if Msg.wParam < 0 then
     begin
       keybd_event(VK_DOWN, VK_DOWN, 0, 0);
       keybd_event(VK_DOWN, VK_DOWN, KEYEVENTF_KEYUP, 0);
     end;
   end;
end;

이렇게 하면 된다는데

제가 잘못하거나 빠트린 부분이 있나 안되네요..

답변기다리겠습니다. -_-
1  COMMENTS
  • Profile
    김경록 2003.05.23 20:10
    Form생성부분에
    Application.OnMessage := MOUSEWHEELMessage;

    위와같이 넣어주고요..

    procedure MOUSEWHEELMessage(var Msg: TMsg; var Handled: Boolean);
    begin
       if Msg.Message = WM_MOUSEWHEEL then
          if ActiveControl = TControl(dbgrid1) then
          Begin
             if Msg.wParam > 0 then begin
                 keybd_event(VK_UP, VK_UP, 0, 0);
                 keybd_event(VK_UP, VK_UP, KEYEVENTF_KEYUP, 0);
             end
             else if Msg.wParam < 0 then begin
                 keybd_event(VK_DOWN, VK_DOWN, 0, 0);
                 keybd_event(VK_DOWN, VK_DOWN, KEYEVENTF_KEYUP, 0);
             end;

             ActiveControl.Invalidate;
          End;
    end;