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 Cursor aus Bitmap laden (https://www.delphipraxis.net/139649-cursor-aus-bitmap-laden.html)

FrEEzE2046 2. Sep 2009 07:37


Cursor aus Bitmap laden
 
Hallo,

ich habe eine Bitmap-Datei, die ich bei einem Drag&Drop Vorgang als Cursor verwenden möchte. Das mache ich im Moment so:

Delphi-Quellcode:
procedure TfrmMain.CreateCursor();
var
  bmpMask, bmpColor : TBitmap;
  iiIconInfo       : TIconInfo;
begin
  bmpMask := TBitmap.Create();
  bmpColor := TBitmap.Create();

  try
    bmpMask.LoadFromFile( ExtractFilePath(ParamStr(0)) + '\cursor\list_drag_small.bmp' );
    bmpColor.LoadFromFile( ExtractFilePath(ParamStr(0)) + '\cursor\list_drag_small.bmp' );

    with iiIconInfo do
    begin
      fIcon   := false;
      xHotspot := 15;
      yHotspot := 15;
      hbmMask := bmpMask.Handle;
      hbmColor := bmpColor.Handle;
    end; (* of with *)

    Screen.Cursors[crLVDrag] := CreateIconIndirect(iiIconInfo);
  finally
    bmpMask.Free();
    bmpColor.Free();
  end; (* of finally *)
end; (* of CreateCursor *)
(* -------------------------------------------------------------------------- *)

Das Problem dabei ist, dass rund um meinen Cursor ein viereckiger schwarzer Hintergrund ist.

turboPASCAL 2. Sep 2009 08:54

Re: Cursor aus Bitmap laden
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hi,

von deinem Sourcecode her ist soweit alles in Ordnung.
Der Fehler liegt warscheinlich an deinen Bitmaps.

Da du beschreibst das um deinen Cursor ein viereckiger schwarzer Hintergrund ist,
nehme ich einfach mal an das du folgendes nicht beachtet hast:

Zitat:

hbmMask
Specifies the icon bitmask bitmap. If this structure defines a black and white icon, this bitmask is formatted so that the upper half is the icon AND bitmask and the lower half is the icon XOR bitmask. Under this condition, the height should be an even multiple of two. If this structure defines a color icon, this mask only defines the AND bitmask of the icon.

hbmColor
Identifies the icon color bitmap. This member can be optional if this structure defines a black and white icon. The AND bitmask of hbmMask is applied with the SRCAND flag to the destination; subsequently, the color bitmap is applied (using XOR) to the destination by using the SRCINVERT flag.
Verwende mal die Bitmaps aus dem Anhang.
Die Namen der Bitmaps sind hoffe ich eindeutig.


Noch eine Frage, wieso nutzt du nicht gleich Icons als Cursor ?

FrEEzE2046 2. Sep 2009 09:23

Re: Cursor aus Bitmap laden
 
Liste der Anhänge anzeigen (Anzahl: 2)
Zitat:

Zitat von turboPASCAL
Noch eine Frage, wieso nutzt du nicht gleich Icons als Cursor ?

Hallo

danke für deine Antwort.

Meinst du warum ich kein *.ico-Files benutze für den Cursor oder wie ist das gemeint?

Deine Cursor Bitmaps funktionieren. Ich kann aber nicht den Unterschied zu meinen erkennen (siehe Anhang)

turboPASCAL 2. Sep 2009 11:07

Re: Cursor aus Bitmap laden
 
Die Maske soll ein S/W-Bitmap sein. ;)

Man kann auch ein Icon als Cursor verwenden. oder gleich aus einem Icon ein Cursor erstellen.
Irgend wo in der DP schwirrt noch 'n Demo rum.

FrEEzE2046 2. Sep 2009 12:40

Re: Cursor aus Bitmap laden
 
Zitat:

Zitat von turboPASCAL
Die Maske soll ein S/W-Bitmap sein. ;)

Man kann auch ein Icon als Cursor verwenden. oder gleich aus einem Icon ein Cursor erstellen.
Irgend wo in der DP schwirrt noch 'n Demo rum.

Zur Maske:
Sie ist eigentlich auch ein S/W-Bitmap. Ich habe leider die richtige Datei nur nicht hier (sondern an der Arbeit) und habe daher schnell eine andere erstellt. Ich schätze du beziehst dass insbesondere auf die rötliche Umrandung; die ist aber eigentlich nicht vorhanden. Eine andere Idee woran es liegen kann?

Zum Icon:
Das bringt mir auch nicht viel. Ich habe den Cursor selbst modelliert und er liegt mir eben im reinen bmp | png | jpgeg (etc.) Format vor.

turboPASCAL 2. Sep 2009 17:22

Re: Cursor aus Bitmap laden
 
Liste der Anhänge anzeigen (Anzahl: 1)
Also meinerseits funktioniert es wie es soll. ;)

Anderer seits würde ich mir die Arbeit sparen und auf AniFX (Freeware) zurück greifen.

FrEEzE2046 3. Sep 2009 14:41

Re: Cursor aus Bitmap laden
 
Wenn ich mal dumm nachfragen darf:

Was genau meinst du da jetzt? Mit AniFX kann ich doch auch "nur" mir die Bitmaps erstellen ... was soll dass ändern?

turboPASCAL 3. Sep 2009 15:29

Re: Cursor aus Bitmap laden
 
Ne, du kannst dir mit AniFX eine Cursor Datei erstellen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:04 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