AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Handcursorgrafik

Ein Thema von kroete · begonnen am 18. Apr 2008 · letzter Beitrag vom 28. Aug 2008
Antwort Antwort
Seite 2 von 2     12
Nachteule

Registriert seit: 22. Mär 2007
Ort: München
37 Beiträge
 
Delphi 2009 Enterprise
 
#11

Re: Handcursorgrafik

  Alt 27. Aug 2008, 18:51
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:
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.
so funzt es prima unter WinXP SP3
Miniaturansicht angehängter Grafiken
handcursor_132.jpg  
  Mit Zitat antworten Zitat
blackdrake

Registriert seit: 22. Aug 2003
Ort: Bammental
618 Beiträge
 
Delphi 10.3 Rio
 
#12

Re: Handcursorgrafik

  Alt 27. Aug 2008, 19:53
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:
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;
(Huch? TCursor kompatibel mit Integer Cardinal? )

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
Daniel Marschall
  Mit Zitat antworten Zitat
blackdrake

Registriert seit: 22. Aug 2003
Ort: Bammental
618 Beiträge
 
Delphi 10.3 Rio
 
#13

Re: Handcursorgrafik

  Alt 27. Aug 2008, 20:20
So müsste es nun eigentlich funktionieren. Ich teste es morgen auf meinem 95-Testpc

Delphi-Quellcode:
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;
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?

Gruß
blackdrake
Daniel Marschall
  Mit Zitat antworten Zitat
Nachteule

Registriert seit: 22. Mär 2007
Ort: München
37 Beiträge
 
Delphi 2009 Enterprise
 
#14

Re: Handcursorgrafik

  Alt 27. Aug 2008, 20:30
könnte man nicht einfach den crHandPoint überschreiben?
  Mit Zitat antworten Zitat
blackdrake

Registriert seit: 22. Aug 2003
Ort: Bammental
618 Beiträge
 
Delphi 10.3 Rio
 
#15

Re: Handcursorgrafik

  Alt 27. Aug 2008, 20:36
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.
Daniel Marschall
  Mit Zitat antworten Zitat
blackdrake

Registriert seit: 22. Aug 2003
Ort: Bammental
618 Beiträge
 
Delphi 10.3 Rio
 
#16

Re: Handcursorgrafik

  Alt 28. Aug 2008, 01:11
Sowohl

if Screen.Cursors[NIDC_HAND] = NULL then als auch

if Screen.Cursors[NIDC_HAND] = 0 then sind unter Windows 95 (kein IDC_HAND) unwahr. (Erwartet: wahr)

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 Weiteres habe ich hier http://www.delphipraxis.net/internal...=932775#932775
Daniel Marschall
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:25 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