Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi [Win32 API] Trotz setzen von hCursor nur die Sanduhr (https://www.delphipraxis.net/107921-%5Bwin32-api%5D-trotz-setzen-von-hcursor-nur-die-sanduhr.html)

igel457 4. Feb 2008 17:11


[Win32 API] Trotz setzen von hCursor nur die Sanduhr
 
Hallo.

Für das Win32-Windowframework von Andorra 2D erzeuge ich ein Fenster via Windows-API. Der darüber angezeigte Mauszeiger ist jedoch immer ein "Sanduhr"-Zeiger, bis ich den Fensterbereich einmal verlassen habe.
Hier ist mein Fenstererzeugungscode:
Delphi-Quellcode:
FWnd.cbSize := SizeOf(TWndClassEx);
FWnd.style := CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS;
FWnd.lpfnWndProc := FWndProc;
FWnd.cbClsExtra := 0;
FWnd.cbWndExtra := 0;
FWnd.hbrBackground := CreateSolidBrush(0);
FWnd.lpszMenuName := nil;
FWnd.lpszClassName := 'WndClass';
FWnd.hIconSm := 0;
FWnd.hInstance := hInstance;
FWnd.hIcon := LoadIcon(hInstance, MAKEINTRESOURCE(100));
FWnd.hCursor := LoadCursor(0, IDC_ARROW);;

RegisterClassEx(FWnd);
FHandle := CreateWindowEx(0, 'WndClass', PChar(Title), WndStyle,
  0, 0, AProps.Width, AProps.Height, 0, 0, hInstance, nil);
Den gesamten Sourcecode gibt es hier:
http://andorra.cvs.sourceforge.net/a...as?view=markup

Vielleicht kann sich das mal jemand der sich mit der Win32-API auskennt ansehen.

Danke,
Andreas

Dezipaitor 4. Feb 2008 17:42

Re: [Win32 API] Trotz setzen von hCursor nur die Sanduhr
 
Schau dir das an:
http://blogs.msdn.com/oldnewthing/ar...25/421707.aspx

igel457 4. Feb 2008 18:12

Re: [Win32 API] Trotz setzen von hCursor nur die Sanduhr
 
Vielen Dank, das hat mir geholfen.

Mein jetziger Code:
Delphi-Quellcode:
FHCur := LoadCursor(0, IDC_ARROW);

FWnd.cbSize := SizeOf(TWndClassEx);
FWnd.style := CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS;
FWnd.lpfnWndProc := FWndProc;
FWnd.cbClsExtra := 0;
FWnd.cbWndExtra := 0;
FWnd.hbrBackground := CreateSolidBrush(0);
FWnd.lpszMenuName := nil;
FWnd.lpszClassName := 'WndClass';
FWnd.hIconSm := 0;
FWnd.hInstance := hInstance;
FWnd.hIcon := LoadIcon(hInstance, MAKEINTRESOURCE(100));
FWnd.hCursor := FHCur;

RegisterClassEx(FWnd);
FHandle := CreateWindowEx(0, 'WndClass', PChar(Title), WndStyle,
  0, 0, AProps.Width, AProps.Height, 0, 0, hInstance, nil);

SetCursor(FHCur);
Nochmal vielen Dank!

Edit:
In der Ereignissverarbeitungsprozedur sollte man noch ein
Delphi-Quellcode:
case
  WM_SETCURSOR:
    SetCursor(FHCur);
einfügen.

Edit 2:
Noch besser ist folgender Code:
Delphi-Quellcode:
case
  WM_SETCURSOR:
    if (lParam and $0000FFFF) = (HTCLIENT) then
      Windows.SetCursor(FHCur)
    else
      Result := DefWindowProc(hWnd, uMsg, wParam, lParam);


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:47 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz