Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.09.09;
Скачать: CL | DM;

Вниз

Как узнать, какой курсор в данный момент   Найти похожие ветки 

 
JanMihail ©   (2007-06-30 12:58) [0]

Мне нужно узнать, какой курсор в данный момент. Например, если курсор над текствоым полем, чтоб программа сказала что курсор crIBeam, если обычный, то crDefault
Пробовал:
GetCursor
Screen.Cursor
CursorToString

Но все это работает только если курсор водишь над формой, а мне нужно, чтоб не только над формой приложения работало.


 
Anatoly Podgoretsky ©   (2007-06-30 13:33) [1]

Попробуй SetCapture


 
Savek   (2007-06-30 14:02) [2]


function GetCursorHandle: HCURSOR;
var
  hWindow: HWND;
  pt: TPoint;
  pIconInfo: TIconInfo;
  dwThreadID, dwCurrentThreadID: DWORD;
begin
  // Find out which window owns the cursor
 // Das zum Mauszeiger zugehцrige Fenster finden
 GetCursorPos(pt);
  hWindow := WindowFromPoint(pt);

  // Get the thread ID for the cursor owner.
 // Thread ID des Fensters ermitteln
 dwThreadID := GetWindowThreadProcessId(hWindow, nil);

  // Get the thread ID for the current thread
 // Thread ID fьr den aktuellen Thread ermitteln
 dwCurrentThreadID := GetCurrentThreadId;

  // If the cursor owner is not us then we must attach to
 // the other thread in so that we can use GetCursor() to
 // return the correct hCursor

 // Wenn der Mauszeiger zu einem anderen Thread gehцrt, mьssen wir
 // an den anderen Thread anhдngen.

 if (dwCurrentThreadID <> dwThreadID) then
  begin
    if AttachThreadInput(dwCurrentThreadID, dwThreadID, True) then
    begin
      // Das Handle des Mauszeigers ermitteln
     // Get the handle to the cursor
     Result := GetCursor;
      AttachThreadInput(dwCurrentThreadID, dwThreadID, False);
    end;
  end else
  begin
    Result := GetCursor;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  CurPosX, CurPoxY: Integer;
  MyCursor: TIcon;
  pIconInfo: TIconInfo;
begin
  MyCursor := TIcon.Create;
  try
    MyCursor.Handle := GetCursorHandle;
    // Retrieves information about the specified cursor.
   // Informationen ьber den Mauszeiger auslesen
   GetIconInfo(MyCursor.Handle, pIconInfo);
    CurPosX := pIconInfo.xHotspot;
    CurPoxY := pIconInfo.yHotspot;
    // Draw the Cursor on the form
   // Den Mauszeiger auf die Form zeichnen
   Canvas.Draw(CurPoxY, CurPoxY, MyCursor);
  finally
    MyCursor.ReleaseHandle;
    MyCursor.Free;
  end;
end;

// Another Solution:
// Andere Mцglichkeit:

procedure TForm1.Timer1Timer(Sender: TObject);
var
  CI: TCursorInfo;
begin
  CI.cbSize := SizeOf(CI);
  GetCursorInfo(CI);
  Image1.Picture.Icon.Handle := CI.hCursor;
end;


 
JanMihail ©   (2007-06-30 18:05) [3]

Спасибо, Savek!!!



Страницы: 1 вся ветка

Текущий архив: 2007.09.09;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.022 c
2-1187526149
Тимофей_ка
2007-08-19 16:22
2007.09.09
почему то происходит обращение к удаленному Shape


15-1187079106
gnl
2007-08-14 12:11
2007.09.09
Подскажите библиотеку для работы с большими числами


4-1174383793
Magedon
2007-03-20 12:43
2007.09.09
Поиск элементов на форме.


2-1187163260
WebSQLNeederr
2007-08-15 11:34
2007.09.09
Разбор строки


15-1187131986
iZEN
2007-08-15 02:53
2007.09.09
Что нужно сделать в Windows, чтобы запретить установку