winforms - VB.NET Fading out button properly -


how fade out/in button in vb.net properly? can fadeout/in labels using:

controls(i).forecolor = color.fromargb(255, alpha, alpha, alpha) 

(where controls(i) label for next loop through controls in me.controls; alpha value of rgb, for next loop).

this did not work me buttons because changing forecolor leaves rest of buttons' uis visible!

so, way i'm trying uses saved resource image of button (from screenshot) , creates faded in/out version displayed image in picturebox:

public function setimageopacity(byval imgpic image, byval imgopac double) image     dim bmppic new bitmap(imgpic.width, imgpic.height)     dim grpic graphics = graphics.fromimage(bmppic)     dim imgatt new imageattributes()     dim cmxpic new colormatrix()     cmxpic.matrix33 = imgopac     imgatt.setcolormatrix(cmxpic, colormatrixflag.[default], coloradjusttype.bitmap)     grpic.drawimage(imgpic, new rectangle(178, 144, bmppic.width, bmppic.height), imgpic.width, imgpic.height, imgpic.width, imgpic.height, graphicsunit.pixel, imgatt)     grpic.dispose()     imgatt.dispose()     return bmppic end function 

(where imgpic resource image of button, , imgopac opacity on scale of 1 0, 0 transparent).

i use image set picturebox's image:

picbox.image = setimageopacity(my.resources.nextbutton, 1) 

however, glitch where, though picturebox located @ coordinates 178, 144, image showing displayed @ left edge of form (i.e. wrong x coordinate), y coordinate correct!

i have feeling may lie call of .drawimage(...) (at line 8 of function) - the msdn docs on subject unclear me.

please link if has been asked before!

the coordinates in graphics grpic client coords relative image itself, not form. (0, 0) top left of image regardless of image ends being displayed in kind of control.

try changing (0, 0):

grpic.drawimage(imgpic, new rectangle(0, 0, bmppic.width, bmppic.height), imgpic.width, imgpic.height, imgpic.width, imgpic.height, graphicsunit.pixel, imgatt) 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -