Listbox DragRow DragItem.DragPicture

Hi. I’ve noticed that if you assign a picture to the dragitem within the dragrow event of a listbox, Xojo (or Windows … not sure which) automatically manipulates the picture object differently depending on its width.

If it’s under approx 300px wide it simply makes the picture semi-transparent and if it’s over approx 300px wide it drastically fades the entire picture from semi-transparency to total transparency. The under 300px semi-transparent image actually looks nice and allows you to see the other listbox rows beneath the dragged picture while you’re dragging but the image > 300px wide makes it difficult to actually see the picture being dragged, especially if it has text in it.

I’m using Xojo 2013 R3.3 on WIndows 7.

Does anybody know if the drag item image can be manipulated so it is not faded out to nothing using code or declares?

And does this also happen on OS X?

I’ve noticed this on windows dragitems, but not specifically from a listbox… seems to be a MS feature?
Tried messing with dragitem.mousecursor with some success, but it would require drawing the current cursor onto the dragging image. Seems I can’t get any transparency to work that way either. Might be something to look at though if you can figure a way to draw the pointer back in.

Here’s an example (the standard mousecursor disappears though)

[code]Sub MouseDrag(X As Integer, Y As Integer)
dim p as new Picture(400,400,32)
p.Graphics.ForeColor=&cff0000
p.Graphics.fillrect(0,0,400,400)

dim d As new DragItem(self,0,0,0,0)
d.MouseCursor=new MouseCursor(p,200,200)
d.Text=“OK”
d.Drag

End Sub
[/code]

Hold on… looks easier than I thought.

dim p as new Picture(400,400,32) p.Graphics.ForeColor=&cff0000 p.Graphics.fillrect(0,0,400,400) declare Function DrawIcon lib "User32" (hDC as integer,X as int32,Y as int32, hIcon as integer) as Boolean declare Function GetCursor lib "User32" () as integer call DrawIcon(p.Graphics.Handle(Graphics.HandleTypeHDC),200,200,GetCursor() ) dim d As new DragItem(self,0,0,0,0) d.MouseCursor=new MouseCursor(p,200,200) d.Text="OK" d.Drag

Thanks, Jim. I’ll look into this.

I’ve been banging my head against the wall with this as well. I’m not seeing this on Mac OS. But on my Windows app, I could not figure out why I was getting the fade on my drags except for one listbox. As you mention, the one that is working without the fade is narrow, so that explains the exception.

If it is a MS “feature”, then I can live with it for my non-commercial app. I thought I may have been doing something wrong. Thanks for the heads up.

Glad I’m not the only one who found this troublesome, Steve.

That works great, Jim. Many thanks!

As you say, the only thing I can’t figure out is how to set the transparency. I’ve tried creating a grey mask but this doesn’t work.

It looks like using picture.transparent=1 works to allow clear parts of the image (but not semi-transparent), but then the white of the pointer becomes clear.

You might file a feature request for supporting alpha channel images for mousecursor in Win32. I don’t know if it’s doable, but a request can’t hurt.

Thanks.

Very old code to change the window Transparency for OS X (it have to be changed…):

[code]Sub ValueChanged()
#If TargetMacOS
Dim OSError As Integer
Dim inAlpha As Single

#If TargetMachO
  Declare Function SetWindowAlpha Lib "Carbon" (inWindow as WindowPtr, inAlpha as Single) as Integer
  
#ElseIf TargetCarbon
  Declare Function SetWindowAlpha Lib "CarbonLib" (inWindow as WindowPtr, inAlpha as Single) as Integer
#EndIf

// Set the new alpha value
inAlpha = (sTransparency.Value/100)

OSError = SetWindowAlpha(Self, inAlpha)

#EndIf
End Sub
[/code]

Thanks, Emile. I’m not sure if the problematic behavior actually exists on Mac because I haven’t tested it on OS X yet. It may just be a MS Windows issue but if it’s on OS X too I will investigate transparency.

There is an example (with a car ?) that have/show transparency, but since I do not changed the image (thus the size of the image) I do not know too.