SetCursor_() - Pippet in paint??

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I'm a retard, it's the mask that's buggered up, and I know for sure that leaving the depth parameter off CreateImage is a mistake. Updated, could you try?
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Works okay here.

This is weird!
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Still green :(
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

OK, guaranteed to fix it:

Code: Select all

SetWindowColor(0, #Green)
:twisted:
BERESHEIT
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

netmaestro wrote:I'm a retard, it's the mask that's buggered up, and I know for sure that leaving the depth parameter off CreateImage is a mistake. Updated, could you try?
No, I watched the mask in the library viewer and it's correct. It should probably be 1-bit instead of 24-bit, though? But I just discovered that PB has some problems with low-images (see bug forum).
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

netmaestro wrote:OK, guaranteed to fix it:

Code: Select all

SetWindowColor(0, #Green)
:twisted:
That made a white rectangle. :P

Edit: It looks good when I change the background colour of the pipette image to black.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

[removed for relevance]
Last edited by netmaestro on Mon Nov 27, 2006 11:51 pm, edited 1 time in total.
BERESHEIT
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Netmaestro, I think Trond and I have issues with our PC's. I'll be home in an hour and I can see what it looks like there.

Seeing as how my work PC and home PC are acting differently with various pieces of code, there must be a common denomenator for all of this.

edit...sorry Netmaestro...still green
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

OK, a minor breakthrough at least. I found a laptop here that the green background shows on, so I can continually test potential solutions. I'll post when I've got it beat.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Got it beat. Source is in the original post. The solution was to give the color bitmap a black background. Should work everywhere now.
BERESHEIT
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

As I thought, it (the original code) works perfectly for me on my home PC. :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

It's OK now but I'd like to understand just what happened a bit better. The green background makes sense if Windows is XOR'ing the color bitmap and the transparent part of the mask. The transparent part of the mask is white and the transparent color of the bitmap was pink. White XOR'ed with pink results in green, which was showing. But then, why didn't it show on all computers instead of just a few? Is something different in newer video cards? Mine's new, and the laptop it showed green on is two years old. At any rate, with a black background for the color bitmap, white XOR'ed with black leaves nothing, so that really should be safe everywhere. If anyone understands a bit more than I do about what's going on (which doesn't take much!) I'd appreciate a tip or two.
BERESHEIT
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post by Shardik »

Tranquil wrote: Unfortunately I dont have this icon on my harddisc. But you can surely extract it from Paint with some Icontools.
srod wrote: The following 'icon extractor' only locates 6 icons embedded within mspaint.exe
This code example demonstrates how to use the cursor resource from MSPaint.Exe (tested with WinNT SP6 and WinXP Pro SP2):

Code: Select all

CursorID.S = "#1204"
CursorLib.S = "MSPaint.Exe"
CursorLibHandle.L = LoadLibrary_(CursorLib)

If CursorLibHandle = 0
  MessageRequester("Error", CursorLib + " couldn't be loaded!", #MB_ICONERROR)
  End
EndIf  

CursorHandle = LoadImage_(CursorLibHandle, @CursorID, #IMAGE_CURSOR, 0, 0, #LR_DEFAULTCOLOR)

If CursorHandle = 0
  MessageRequester("Error", "Cursor " + CursorID + " couldn't be loaded from " + CursorLib, #MB_ICONERROR)
  End
EndIf  

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, CursorHandle) 
Repeat 
  ev=WaitWindowEvent() 
Until ev=#PB_Event_CloseWindow 
DestroyIcon_(CursorHandle) 
End
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Very nice, thanks for posting. Where did you get the value "#1204" and how do I look through an executable to find what's in there?
BERESHEIT
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post by Shardik »

netmaestro,

I used ResourceHacker (http://www.angusj.com/resourcehacker) to list all resources from MSPaint.Exe. When using resource hacker to open MSPaint.Exe you have to open the tree view node "Cursor Group" and take a look at the different cursor nodes. When opening node 1204 and clicking on 1031 you will see the pipette cursor on the right side. So you have to use #1204 to load the pipette cursor resource.

If you want some examples for simple resource handling take a look at the code of GPI:
http://www.purebasic.fr/english/viewtop ... 58&start=4
Post Reply