the gdi+x samples have a form that displays a "halo" for text. so taking that idea i adapted it for these glowing buttons.

to use these buttons you will need the gdi+x classes on the vfpx site.

http://www.codeplex.com/wiki/view.aspx?projectname=vfpx&title=gdiplusx

click on the link on this page that says latest release of gdiplusx and download the latest stable release. do not download the beta as that is not complete and may not work properly.

i havd also posted a tutorial on how to use my classes including the supplied builder. you can find the post here. most of the points are relevant here too.

ok. using these buttons is just a matter of dropping them on a form, sizing them to the required size and then running the builder provided in the favourites tab. you may have to delete the image stored in the picture property of the sample form as these images are not included. however the builder will show what exactly the button will look like at runtime and also generate a new image.

all the properties you need to change are in the favourites tab except for the enabled property.this can be set at design or runtime as i have hooked into the enabled_assign. the colours assigned can be tested for the best mix of font and glow and you get immediate feedback in the builder.

here are some samples i created earlier. the form is included.

note what the disabled button looks like.

and here is the above form where the button "glows" when the mouse passes over it (2nd down on the left in case you miss it)

the button also gives feedback when clicked where the border becomes black.

lastly some interesting toolbar buttons are possible using the wingdings and similar fonts, resizing the button and a judicious use of colours.

finally if you create a great big button as big as your screen, switch off the lights at night and pass the mouse over it, you will actually see that the button does "glow in the dark" 🙂

unfortunately because of the amount of junk mail being generated from the weblog i have switched off comments. please post your comments, if any, at www.foxite.com

7 Responses to Glow-In-The-Dark Buttons with GDI+X

  • Looks nice here, pity though I could not make it run on my machine, no glow no glory. The pictures are stored like: c:\docume~1\bbout\locals~1\temp\38347065.bmp
    In the zipfile there are NO pictures included. Maybe we need those as well?

    Hi BL

    Thanks for not just lurking but actually posting a comment. No you dont need those.

    From your query, it is obvious you have not read my post properly. Here is what the post says with regard to the images:

    “You may have to delete the image stored in the Picture property of the sample form as these images are not included. However the builder will show what exactly the button will look like at runtime and also generate a new image”

    So all you really need to do is delete the path stored in the form property and re run the builder and click “Apply” to have your very own bitmaps.

  • juanz says:

    son fantasticos…muchas gracias  espero y sigan publicando mas cosas nuevas de fox..por alguna cosa ahi esta mi correo…soy programador de fox …y felicidades por los ejemplos muy bueno… desde el salvador…

    Gracias por su reconocimiento, Juanz

  • ********Bernard : can filter what is good for you to publish ***************************************

    Bravo Bernard ,this is my remarks.

    1-can put Mousepointer=15 (hand)

    -when clic the button,a variant is the halo flashes with another color and hear to a sound(this property can be enabled/disabled)

    i just add a property isSound and  this in the click class

    if this.isSound=.t.

    TRY

    LOCAL lcBell

    lcBell = SET(“Bell”)

    SET BELL TO (ADDBS(GETENV(‘windir’)))+”MEDIA\tada.WAV”

    ?? CHR(7)

    SET BELL TO (lcBell)

    CATCH

    ENDTRY

    endi

    That can be done but I prefer to work silently 🙂

    2-If i choice a small button ,the font is wide and looks not synchronizable with the button width.Can use some ratio (caption width/button width)

    I see that the gdiplus function  measureSTring can measure the pixels of string caption and can arrange it with the adequat font ( to stretch the caption in the button).Its like the classic function TxtWidth.

    Good idea. I will look into that.

    That can be doing with the anchor property(in certain limit).

    I see also the builder by dbclick on can return visual setting directly.

    for reproduce the wrapmode effect of a commandbutton,i see this solution:

    in imgcanvas.beforedraw

    lnLeft = this.width/10    &&2

    lnTop = This.Height/10     &&2

    This.drawhalotext(loHalocolour,lcFont,lnFontsize,loFontColour,lcText,lnLeft,lnTop,This.mouseover)

    in imgcanvas.drawhalotext

    loPath.AddString(tcText, ;

    .FontFamily.New(tcFont), ;

    .FontStyle.Bold, ;

    tnFontsize, ;

    .Rectangle.New(tnLeft,tnTop,0.8*this.width,0.8*this.height),;

    loStringFormat)

    that can draw multiline caption,centered.

    Another good idea for improvement. I will check it out

    3-very nice trick with font wingding effect.

    4-When apply the builder in a button this is drawn on design time (dbclick on  aGlowBuilder).

     can we  automatically do that for each button with the properties set at design time – (many pictures in temp folder)-without viewing the builder ?

    I will check it out

    5-why the font monotype corsiva dont work anywhere in gdiplusX ?

    No idea

    6-Button can be also circular,elliptic,..

    Yes it can like my other buttons. I showed a small square button anyway.

    Conclusion: great work with beautiful new effects and nice designs.

    Thanks for your comments Yousfi
    Thanks Bernard.

  • Jimmy Alcala says:

    fantastics Buttons.., i like very much, i have a problem when put this buttons in a container, and form is resize, they no resize, until i put the mouse on. how can I fix this?

    Have you set the Anchor property of the buttons and the container?

  • Jimmy Alcala says:

    Yes, i set the anchor property, when button is in form work fine, but button is in container only resize with mouse on….

    Gracias por tu atención

    Do this:

    1. Add a container to the form. Set the container.Anchor = 15

    2. Place a button inside the container. Set button Anchor property = 15

    3. Run form. Resize form and see that the button also increases.

  • yonko says:

    when i programmatically create a form and add to it more buttons, it takes a few seconds for all the buttons are rendered. can accelerate it somehow?

    • Bernard Bout says:

      Use the VFP visual designer. Also one way to make it appear that the buttons update fast is :
      1. On your form set the VISIBLE = .F. for the button
      2. In the Button.AfterDraw() add this code

      IF NOT This.Visible
      This.Visible = .T.
      ENDIF

      That way the button will be rendered and then it will show rather than the ugly empty box with an “X” in it.
      Also depends on the number of buttons you have.

Leave a Reply

Your email address will not be published. Required fields are marked *