Icon in Statusbar

Started by Rolf Brandt, November 20, 2009, 01:40:32 PM

Previous topic - Next topic

Rolf Brandt

Hi everyone,

I want to display an icon in one of the panels of a statusbar to visualize that the program is connected to the  SQLitening Server. (Red = Not Connected, Green = Connected) . Basically no problem, but is there a possibility to resize the icon. I would like it to fit the height of the panel. This works fine when I add the icon in the GUI, but when I change the icon programmatically it does not get resized.

     
      hIcon     = LoadIcon (App.hInstance, "IMAGE_CONNGREEN")
      dwResult  = StatusBar_SetIcon (HWND_FORM1_STATUSBAR, 1, hIcon)


See attached pictures.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Haakon Birkeland

First thing that comes to mind is your "second" defined User Tool. 8o)
But I assume you prefer not solving it at the source.
Haakon 8o)

Rolf Brandt

Hi Haakon,

I thought of that too, but but even if I take a 16x16 icon it shows as big as a 32x32 icon.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Rolf Brandt

#3
OK, I found the solution. By carefully checking the generated code I found how FF3 does it.
Originally I used this code to load the icon:

      hIcon = LoadIcon (App.hInstance, "IMAGE_CONGREENS")

This is what works correctly:
      hIcon = LoadImage( App.hInstance, "IMAGE_CONNGREEN", %IMAGE_ICON, 16, 16, 0 )
      dwResult  = StatusBar_SetIcon (HWND_FORM1_STATUSBAR, 1, hIcon)

Now the icon gets properly sized (See picture).
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Paul Squires

Can't wait to see this app! Cool!
Paul Squires
PlanetSquires Software

Rolf Brandt

Runs pretty good so far, hope to get a basic version out in a couple of days.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Roger Garstang

I have this issue a lot too when using icons with multiple sizes...even the evil Visual Studio can't give me a large button with 48x48 icon unless I only have a 48x48 icon in the ico file.  The Icon Size property was the best edition to FF and allows me to finally have one ico file with multiple sizes and use the 48x48 from it on my button.  Sounds like the same option is needed for Statusbars so it uses the correct icon for you.

Rolf Brandt

That's true, Roger. But the workaround using LoadPicture instead of LoadIcon works very good.

If you assign the icon in FF it resizes properly. I think Paul should change the example code in the Function Library's 'FF_StatusBar_SetIcon' procedure to LoadPicture. There you set the size to 16x16 and it resizes correctly.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Roger Garstang

Yeah, I guess that would be better to just hardcode it to use 16x16...for some reason I was thinking allowing for larger statusbars when there is no option for such.  If no 16x16 in the file the API should handle the sizing from a 32x32 or whatever on its own and not have FF worry about it.