SetCursor_() - Pippet in paint??
Posted: Mon Nov 27, 2006 12:28 pm
How could i set the cursor to be the same as the one used for the pippet in paint when used over an imagegadget???
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure IconExtract(File.s,Icon.l)
ProcedureReturn ExtractIcon_(0,File,Icon)
EndProcedure
;/ Test
#file="c:\windows\system32\mspaint.exe"
Count=IconExtract(#file,-1)
OpenWindow(0,0,0,130,70,Str(Count)+" Icons",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ButtonImageGadget(0,10,10,48,48,IconExtract(#file,pointer))
TextGadget(1,80,30,40,20,"n° 1")
Repeat
event=WaitWindowEvent()
If event= #PB_Event_Gadget And EventGadget()=0 And EventType()=#PB_EventType_LeftClick
pointer+1
If pointer=Count : pointer=0 : EndIf
SetGadgetState(0,IconExtract(#file,pointer))
SetGadgetText(1,"n° "+Str(pointer+1))
EndIf
Until event=#PB_Event_CloseWindow
Code: Select all
;===================================================
; Program: Pipette Cursor Demo
; Author: Lloyd Gallant (netmaestro)
; Date: November 27, 2006
; As taught by: Sparkie
;===================================================
;
ProcedureDLL PipetteCursor()
*unpacked = AllocateMemory(3128)
UnpackMemory(?PicPak, *unpacked)
imgcolor = CatchImage(#PB_Any, *unpacked, 3128)
bmpcolor = ImageID(imgcolor)
DataSection
PicPak:
Data.b $4A,$43,$38,$0C,$00,$00,$2A,$D9,$47,$2B,$B3,$A9,$D0,$20,$69,$14,$61,$88,$12,$CA
Data.b $08,$B0,$48,$40,$27,$90,$04,$8E,$01,$C6,$5B,$28,$31,$10,$AB,$03,$0C,$02,$12,$09
Data.b $46,$FF,$BF,$AD,$8F,$22,$59,$84,$F0,$43,$E6,$3B,$8A,$18,$1B,$B2,$0F,$F5,$11,$A8
Data.b $22,$E4,$21,$C3,$5E,$47,$83,$EE,$43,$FF,$C0,$E6,$BB,$31,$B1,$35,$06,$01,$29,$94
Data.b $CC,$A6,$1B,$63,$E6,$77,$77,$F2,$14,$1B,$33,$02,$70,$ED,$FB,$33,$36,$1B,$00,$5F
Data.b $53,$28,$98,$CC,$48,$11,$5F,$14,$21,$00,$1B,$03,$6A,$6D,$8D,$41,$00,$A2,$F9,$3C
Data.b $00,$98,$6D,$5F,$63,$06,$11,$4C,$02,$40,$8C,$0D,$EA,$49,$4F,$8B,$C2,$EA,$C1,$BD
Data.b $46,$00,$23,$00,$CE,$81,$DC,$E6,$AE,$2E,$55,$E8,$30,$01,$53,$21,$9B,$D0,$86,$82
Data.b $6E,$42,$D5,$98,$8D,$26,$8D,$E1,$AD,$F9,$1B,$69,$56,$17,$75,$23,$14,$33,$36,$02
Data.b $10,$6E,$04,$50,$D5,$62,$5D,$AD,$D5,$1B,$90,$C9,$98,$79,$22,$D0,$4F,$02,$46,$30
Data.b $F9,$8E,$E1,$BE,$9A,$22,$00,$00,$20,$12
PicPakend:
EndDataSection
imgmask = CreateImage(#PB_Any, 32, 32, #PB_Image_DisplayFormat)
bmpmask = ImageID(imgmask)
StartDrawing(ImageOutput(imgmask))
DrawImage(ImageID(imgcolor),0,0)
transcol=Point(0,0)
For i=0 To 31
For j=0 To 31
If Point(i,j)=transcol
Plot(i,j,#White)
Else
Plot(i,j,#Black)
EndIf
Next
Next
StopDrawing()
icoInf.ICONINFO
icoInf\fIcon = #False
icoInf\xHotspot = 8
icoInf\yHotspot = 23
icoInf\hbmMask = bmpmask
icoInf\hbmColor = bmpcolor
CustomCursor = CreateIconIndirect_(icoInf)
ProcedureReturn CustomCursor
EndProcedure
;=======================================================================
; Test program - you can save everything before this as pipette.pbi
; and include it in programs to get the pipette cursor
;=======================================================================
customcursor = PipetteCursor()
CreateImage(0, 100,100)
StartDrawing(ImageOutput(0))
Box(0,0,100,100,#White)
StopDrawing()
OpenWindow(0,0,0,400,300,"Pipette Demo",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ImageGadget(0,120,80,0,0,ImageID(0),#PB_Image_Border)
SetClassLong_(GadgetID(0), #GCL_HCURSOR, customcursor)
Repeat
ev=WaitWindowEvent()
Until ev=#PB_Event_CloseWindow
DestroyIcon_(customCursor)
End
No, I've used this exact method many times over several months now and I've never seen a problem with it. I can't imagine what might cause that, but all the sourcecode is right there, maybe you can see something? Any suggestions/fixes are welcome.It has an ugly green background and it flickers
Still the same problem. Almost newly installed Windows XP Pro and everything. It looks almost like the background of the cursor is XORed with whatever is behind it.netmaestro wrote:http://www.networkmaestro.com/pipette.bmp
Could you try pulling the bmp in with LoadImage and see if it helps?
Code: Select all
SetClassLong_(GadgetID(0), #GCL_HCURSOR, customcursor)