Autor Beitrag
René R.Fo.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Mo 25.05.09 14:42 
Hallo Ich wolte wissen ob man die maus mit einem Bild B.z. Cursor ''Belegen'' Kann?
d.h. nicht mit der eigenschaft Cursor, sonder einer .cur Dartei (Cursor Datei)/ .bmp Datei.


Moderiert von user profile iconNarses: Topic aus Multimedia / Grafik verschoben am Mo 25.05.2009 um 15:29
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 25.05.09 14:46 
Du musst diesen Cursor mit LoadCursor laden und das zugehörige Handle dann der Mouse.Courser-Eigenschaft zuweisen. Freigeben am Ende deines Programms nicht vergessen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 25.05.09 15:13 
Vorher musst du den Cursor aber noch als Ressource einbinden. Das geht zum Beispiel mit dem in Delphi mitgelieferten Programm, das du im Menü "Tools" findest. Dann kannst du LoadCursor so aufrufen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
const crMyCursor = 1;

var CursorHandle: THandle;
begin
  CursorHandle := LoadCursor(HInstance, 'NameDerRessource');
  if CursorHandle <> 0 then Screen.Cursors[crMyCursor] := CursorHandle;
end;

Die Konstante crMyCursor kannst du dann nachher z.B. statt crHourGlass oder crArrow verwenden. Verwende nur positive Werte, die negativen sind für die Standard-Cursors vorbehalten.
René R.Fo. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Di 26.05.09 14:33 
Das klappt irgendwie nicht der Zeiger ändert sich nicht
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 26.05.09 14:41 
Aber die neue Mauszeigerkonstante hast du dann auch benutzt um sie irgendwo zuzuweisen, z.B. an FormX.Cursor?
René R.Fo. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Mi 27.05.09 14:42 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Aber die neue Mauszeigerkonstante hast du dann auch benutzt um sie irgendwo zuzuweisen, z.B. an FormX.Cursor?

Nein habe ich nicht. W muss ich das denn einsetzen

z.B. an FormX.Cursor?

Form1

Moderiert von user profile iconNarses: Zitat gekennzeichnet.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.05.09 14:45 
Naja, nach dem Laden des Cursors musst du den auch benutzen, also der Eigenschaft Cursor z.B. deines Formulars zuweisen, wie gesagt.
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Mi 27.05.09 19:10 
Also wenn ich das gerade richtig überblicke, dann müsste es doch zum Beispiel so gehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure Form1.CursorAendern();
 const crMyCursor = 1;
 var CursorHandle: THandle;
begin
  CursorHandle := LoadCursor(HInstance, 'NameDerRessource');
  if not CursorHandle=0 then 
     begin
     Screen.Cursors[crMyCursor] := CursorHandle;
     end;
end;

- Oder?
Wobei Du dann die procedure Form1.CursorAendern(); erst mal oben noch unter Public oder private declarieren müsstest, damit Du vor den Procedur-Namen "Form1." schreiben kannst.
- Sonst reicht es, wenn Du das ganze ohne das "Form1." ziemlich zu Anfang Deines Quelltextes schreibst.


Zuletzt bearbeitet von ffgorcky am Mi 27.05.09 19:17, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.05.09 19:16 
Da fehlt aber wie gesagt noch die Benutzung des damit geladenen Cursors. ;-)
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Mi 27.05.09 19:29 
Jaenicke meinte gerade per PN, dass man dann auch noch dieses setzen sollte:
ausblenden Delphi-Quelltext
1:
Form1.Cursor := crMyCursor;					

So gut kenne ich mich leider nun auch wieder nicht in dem Gebiet aus, also wenn er das sagt...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.05.09 19:35 
Ja, hatte ich oben ja auch schon geschrieben, dass der neue Cursor auch zugewiesen werden muss.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mi 27.05.09 21:36 
user profile iconffgorcky hat folgendes geschrieben Zum zitierten Posting springen:
Also wenn ich das gerade richtig überblicke, dann müsste es doch zum Beispiel so gehen

Ach nee - das ist exakt mein Codebeispiel, wenn auch schlechter formatiert :P
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 27.05.09 21:41 
user profile iconYogu hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconffgorcky hat folgendes geschrieben Zum zitierten Posting springen:
Also wenn ich das gerade richtig überblicke, dann müsste es doch zum Beispiel so gehen

Ach nee - das ist exakt mein Codebeispiel, wenn auch schlechter formatiert :P
Nein, deins funktionierte, seine Änderung nicht...
user profile iconffgorcky hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
  if not CursorHandle=0 then					
Denn das ist nicht gleich dem Original...
user profile iconYogu hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
  if CursorHandle <> 0 then					
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mi 27.05.09 21:50 
Hoppla, hab ich übersehen. In C(++|#) hätte is IMHO funktioniert (da wird ! als bool'scher Operand angesehen), aber in Delphi wird dann ja erst CursorHandle bitweise invertiert und dann auf <> 0 überprüft. Klappt nicht, denn ein invertiertes Handle ist so ziemlich immer <> 0 ;)
René R.Fo. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Do 28.05.09 19:51 
user profile iconYogu hat folgendes geschrieben Zum zitierten Posting springen:
Hoppla, hab ich übersehen. In C(++|#) hätte is IMHO funktioniert (da wird ! als bool'scher Operand angesehen), aber in Delphi wird dann ja erst CursorHandle bitweise invertiert und dann auf <> 0 überprüft. Klappt nicht, denn ein invertiertes Handle ist so ziemlich immer <> 0 ;)

Toll, hilfreich, Egel :lol: :roll: :wink: .

Irgend wie gibt es ein Problem Bei der Wandlung des Cursors denn der PC wandelt ihn nicht ich habe alles doppelt getestet und euer gepostetes mit einbezogen.

Moderiert von user profile iconNarses: Quote-Tags hinzugefügt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 28.05.09 19:55 
Wie hast du die Ressource jetzt erstellt? Also wie sieht ggf. das .rc Skript aus und wie sieht dein aktueller Quelltext aus?
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 28.05.09 20:26 
user profile iconRené R.Fo. hat folgendes geschrieben Zum zitierten Posting springen:
Hoppla, hab ich übersehen. In C(++|#) hätte is IMHO funktioniert (da wird ! als bool'scher Operand angesehen), aber in Delphi wird dann ja erst CursorHandle bitweise invertiert und dann auf <> 0 überprüft. Klappt nicht, denn ein invertiertes Handle ist so ziemlich immer <> 0


Toll, hilfreich, Egel :lol: :roll: :wink: .

In C#:
ausblenden C#-Quelltext
1:
if (!CursorHandle == 0)					

könnte man mit "Windschutzklammern" (wie sie mein früherer Mathelehrer immer genannt hat) versehen, ohne dass sich wirklich was verändedrt:

ausblenden C#-Quelltext
1:
if (!(CursorHandle == 0))					

Also: Zuerst wird innen verglichen, dann wird außen invertiert. Denn man arbeitet sich in der Mathematik ja immer von der innersten Klammer zur äußersten :idea:


In Delphi:
ausblenden Delphi-Quelltext
1:
if not CursorHandle = 0					

hieße

ausblenden Delphi-Quelltext
1:
if (not CursorHandle) = 0					

Hier sieht man, dass zuerst CursorHandle invertiert wird, und dann das ganze auf 0 geprüft wird. Und eben das wollen wir nicht.

Das aber nur am Rande, ich hatte grad ein bisschen zu viel Zeit ;)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 28.05.09 20:30 
So, ich habe gerade eine Demo in einem ähnlichen Thema gepostet...
www.delphi-forum.de/....php?p=564373#564373
René R.Fo. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Mo 01.06.09 16:08 
Danke :zustimm: :flehan:

Nurnoch wo Kann ich die Datei Laden?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm185.FormCreate(Sender: TObject);
var
  CursorHandle: THandle;
begin
  if CursorHandle <> 0 then
    Screen.Cursors[crMyCursor] := CursorHandle;
  Self.Cursor := crMyCursor;
end;

Wo wird das den geladen? Ich hatte gedacht das dass ihr wäre.

ausblenden Delphi-Quelltext
1:
CursorHandle := LoadCursor(HInstance, 'Test');					


allerdings ist in den Ordner keine Datei mit den Namen
in der Resorss Datei steht auch nichts bitte erklärt mir das :nixweiss: den ich versehe das nicht.

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt


Zuletzt bearbeitet von René R.Fo. am Mo 01.06.09 16:46, insgesamt 1-mal bearbeitet
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Mo 01.06.09 16:18 
Wie schon oben beschrieben: Du musst die Datei als Ressource einbinden. Wie, steht weiter oben.

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell