![]() |
Re: Handcursorgrafik
Liste der Anhänge anzeigen (Anzahl: 1)
habe das hier gefunden:
// crHandPoint is slightly different from IDC_HAND // Derived from postings to borland.public.cppbuilder.winapi and // borland.public.delphi.winapi by CC Chong and MrBaseball34 on // 18-19 Dec 2000 // Comments from CC Chong: // "Yes IDC_HAND is the hidden resource of Windows. On Win98 and above (or since // ActiveDesktop Update in IE4, if I'm not mistaken) Windows has the IDC_HAND // cursor built in to the system." // "But it is not the same as Delphi's crHandPoint. Delphi doesn't use Windows' // IDC_HAND. crHandPoint is Delphi's own inclusion in it's Controls.res (found // in your Delphi\lib)." // // "Delphi copies crHandPoint into your exe during linking.: // // Below, crHandpoint has a black "wrist band" that is not present with IDC_HAND.
Delphi-Quellcode:
so funzt es prima unter WinXP SP3
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; const // Declare the cursor constant that contains the resource identifier // of the system Hand cursor. IDC_HAND = MakeIntResource(32649); // Declare the cursor constant for our own use. Constant value must // not conflict with any existing Delphi cursor constant. NIDC_HAND = 32649; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin // oder on FormCreate Screen.Cursors[NIDC_HAND] := LoadCursor(0, IDC_HAND); Screen.Cursor := NIDC_HAND end; end. |
Re: Handcursorgrafik
Hallo.
Vielen Dank für den Code! Ich hatte meine Recherchen bereits über Tage partiell verteilt, aber nie etwas passendes gefunden. Hier der vereinfachte Code:
Delphi-Quellcode:
(Huch? TCursor kompatibel mit Integer Cardinal? :o )
const
crWindowsHand = 32649; IDC_HAND = MakeIntResource(crWindowsHand); procedure TForm1.FormCreate(Sender: TObject); begin Screen.Cursors[crWindowsHand] := LoadCursor(0, IDC_HAND); end; procedure TForm1.Button1Click(Sender: TObject); begin Panel1.Cursor := crWindowsHand; end; Ich werde noch prüfen, wie das Verhalten bei Windows 95 sein wird (ich möchte keine Exceptions haben). Eventuell müsste ich prüfen, ob das LoadCursor fehlschlägt (wie?) und dann auf crHandPoint zurückspringen. Wenn ich ein Ergebnis habe, werde ich es hier und in der CodeLib posten. Gruß blackdrake |
Re: Handcursorgrafik
So müsste es nun eigentlich funktionieren. Ich teste es morgen auf meinem 95-Testpc
Delphi-Quellcode:
Mich ärgert, dass ich crWindowsHand nun als Variable machen musste. Andernfalls hätte ich nicht auf crHandPoint zurückspringen können (da Konstanten unveränderbar sind). Oder gibt es eine elegantere Lösung?
const
NIDC_HAND = 32649; IDC_HAND = MakeIntResource(NIDC_HAND); var crWindowsHand: TCursor; procedure TForm1.FormCreate(Sender: TObject); begin Screen.Cursors[NIDC_HAND] := LoadCursor(0, IDC_HAND); if Screen.Cursors[NIDC_HAND] = NULL then begin crWindowsHand := crHandPoint; end else begin crWindowsHand := NIDC_HAND; end; end; procedure TForm1.Button1Click(Sender: TObject); begin Panel1.Cursor := crWindowsHand; end; Gruß blackdrake |
Re: Handcursorgrafik
könnte man nicht einfach den crHandPoint überschreiben?
|
Re: Handcursorgrafik
crHandPoint ist eine Konstante. Eigentlich sollte mein crWindowsHand, das crHandPoint substituieren soll, auch eine Konstante sein, ansonsten kann ja jeder das Teil verändern und damit ungültig machen. :|
|
Re: Handcursorgrafik
Sowohl
Delphi-Quellcode:
als auch
if Screen.Cursors[NIDC_HAND] = NULL then
Delphi-Quellcode:
sind unter Windows 95 (kein IDC_HAND) unwahr. (Erwartet: wahr)
if Screen.Cursors[NIDC_HAND] = 0 then
Zumindestens kommt keine Exception o.ä., sondern der Zeiger bleibt normal. Ich würde eben gerne eine Fallback-Methode haben, die bei Nicht-Verfügbarkeit von IDC_HAND auf crHandPoint umspringt (möglichst ohne crWindowsHand als Variable zu haben, sofern das überhaupt möglich ist) Hat jemand eine Idee? (Anmerkung: In der Onlinehilfe steht, dass LoadCursor im Fehlerfall NULL ausgeben sollte... Irgendwie stimmt das aber hier nicht ganz. Gruß blackdrake // Edit: Ich habe eine Lösung gefunden (die sogar ganz banal ist). Und das mit dem crHandPoint überschreiben ging irgendwie tatsächlich, wenn auch die Konstante unverändert blieb :wink: Weiteres habe ich hier ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:48 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz