April 25, 2024, 10:00:05 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Using bitmap buttons

Started by Egil, November 21, 2016, 03:45:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

November 21, 2016, 03:45:43 AM Last Edit: November 21, 2016, 03:47:47 AM by Egil
When updating one of my programs I added Bitmap Button Controls to obtain a more intuitive user interface. Some of the buttons should only be "active" when the program is in Standby mode. But when using ENABLECONTROL to make the button temporarily inactive, the bitmap is replaced with a grey square.
I have solved this problem by leaving the button continuously active, and showing a messagebox if the button is clicked when program is in "Active mode".
(code shown below)


' HFDL input file 1:
CASE 20
   if status10 = 1 then MESSAGEBOX(win,"Allowed in Standby Mode ONLY","Oooops!",@MB_ICONEXCLAMATION)

   if status10<>1

      if status20 = 0 
         SETCONTROLTEXT win,20,"1021"   :' Indicating that function parameter is set - blue background
         status20 = 1 
      else
         SETCONTROLTEXT win,20,"1020"   :' Indicating that function parameter is NOT set - gray background
         status20 = 0 
      endif
 
   endif



Would appreciate if anyone know if it is possible to make a bitmap button inactive, and still show the bitmap?



Regards,
Egil
Support Amateur Radio  -  Have a ham  for dinner!

Brian

Egil,

Off the top of my head, you could have two buttons, one "normal" and one "fuzzy"
and then swap as needed

Brian

Egil

Thanks Brian!

In Norway we say that you can't see the forrest because of all the trees....
This is such a case. Was not able to see it my self.


Egil
Support Amateur Radio  -  Have a ham  for dinner!

Brian

Ha,

In a proper country, we say "Can't see the wood for the trees" !!!

Brian

Andy

November 21, 2016, 08:18:34 AM #4 Last Edit: November 21, 2016, 08:40:40 AM by Andy
Egil,

In my experience, enablecontrol only greys out a control when disabled, which is not what you are after.

You could try hiding the button using the showwindow command.

If you wanted the bitmap to still show when the button is hidden, you could use loadimage to load them in and show them at the same location as the hidden button.

You could even take the bitmap image and perhaps use a copy of it made slightly grey?

When you want to enable the button again, just use showwindow command again at the same location.

Just a thought,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Egil,

Been messing with the bitmap button thingy. It's simple, but it works...

Brian

Egil

Brian

Thanks for the snippet. Had already done sometihing similar, plus loading the bitmats from embedded recourse.
Using the  bitmap colors to indicate working status of the program using two sets of bitmaps, so planned to make a third set of bitmap for doing what both you and Andy suggested.
Tonight I sent emails to all users that have registered with me, asking their advise, and all answers so far are asking for a messagebox to warn them that the program is "Active"...

Attaching a compiled demo. Will post full source code when all changes have been done.


Egil
Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

Understand it's just a demo
definitely need that 3rd set of bitmaps so that all the buttons show a "disabled" state when thing is "active"
then when thing is in "standby" each button switches between "off" and "on"

or is it that yo are wanting to select one of the buttons in "standby" and maintain it when you go "active"?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

Quote from: LarryMc on November 21, 2016, 05:55:45 PM
....or is it that yo are wanting to select one of the buttons in "standby" and maintain it when you go "active"?

When the program starts, all you see is a  row of seven grey colored buttons that indicate that the program does nothing (...yet). Plus two blu buttons.
The idea is to make the user able to see how the program is presently operating, by just a quick glance.

The program parameters then can be set, either by clicking buttons number two to seven counted from the left, or by clicking the tool button (second from right). And let the six above mentioned buttons change their colors to indicate that the "channel" is set and ready.

Then making the program the selected tasks by clicking the "Start/Stop" button. And change this button's bitmap text and color to indicate that the program is active or not.
When the program is in the "Active" state, the only buttons you are allowed to click, is the "Start/Stop" and the "Help" buttons. The rest of the buttons will be disabled.
And how to disable these was my question. Both Andy and Brian have indicated that the best way to do this is to hide these buttons and show a bitmap faking them instead. So I have to make a third set of bitmaps for these.

Last night I emailed all the users that have bothered to register with me, asking their opinion about this, and the answers returned indicate that they also would like a messagebox to pop up if they click one of these "disabled" buttons.

This program was originally just a quick hack intended for my own use, in an attempt to reduce the CPU load when decoding multiple datatransmission channels simultaniously, by separating the presentation (map viewing) and database programs from the software defined radios and decoder programs. Soon the program was shared with other decoding enthusiasts,

This upgrade is a result of suggestions and whishes made by the other users. Their main wishes are reduced window size, and the ability to communicate with other decoding enthusiasts.
So after this upgrade the program have a "new look", collects data from max four channels, and output this to a common file and/or sending it to another computer via UDP comms.
Support Amateur Radio  -  Have a ham  for dinner!

Brian

Egil,

You could always use tooltips on the buttons to indicate what state they are in

Messageboxes could become a nuisance if you have to clear them all the time

Brian

Andy

November 22, 2016, 06:39:37 AM #10 Last Edit: November 22, 2016, 06:45:59 AM by Andy
Egil,

Here is a quick example of my suggestion.


window win
uint bmp[1]

bmp[1] = loadimage(getstartpath + "bit1.bmp",@IMGBITMAP)

OPENWINDOW win,0,0,1000,730,@SIZE|@MINBOX|@MAXBOX,0,"",&Hnd

CONTROL win,@BUTTON,"",10,20,20,20,@CTLBTNBITMAP,1

CONTROL win,@RADIOBUTTON,"Prog Active",10,50,200,20,@CTEDITLEFT,2
CONTROL win,@RADIOBUTTON,"Prog In-active",10,80,200,20,@CTEDITLEFT,3

setcontroltext win,1,getstartpath + "bit1.bmp"
setstate win,2,1


waituntil win = 0
end

sub Hnd(),int
SELECT @MESSAGE
CASE @IDCREATE
   CENTERWINDOW win

    CASE @IDCONTROL
   SELECT @CONTROLID

             Case 2 'active
                  showwindow win,@SWSHOW,1

             Case 3 'inactive
                  showwindow win,@SWHIDE,1
                  SHOWIMAGE win,bmp[1], @IMGBITMAP,10,20,20,20

         endselect

    case @idclosewindow
         end

endselect

RETURN 0
ENDSUB


Use the bitmap attached here in the same folder as the source code.

To use:
Click Prog inactive to hide the button and show the bitmap,
Click Prog active to show the button again.

You may have to play around a little with the size of the bitmap image when using the showimage command.

Don't forget to use DELETEIMAGE on exit (not included here as I didn't have time) to free memeory.

Hope this gives you an idea for your buttons.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Brian,

In this case I do not think that using tooltips is the way to go. Since there are so many other things that need to use the mouse when decoding, a messagebox is probably the way to go. That is also what the other users want.


Andy,

Thanks for the code! That is a great idea, and I had already decided to do it that way. In addition the button background color is changed when the start/stop button is clicked.
BTW, right now I'm waiting for the "assistants" I mentioned in a PM. Their bus will pass here in just a few minutes. So the rest of the evening we are going to fly the CB colors here.... ;D


Regards
Egil
Support Amateur Radio  -  Have a ham  for dinner!

Andy

Egil,

As always, no problem, i had just 45 minutes to dig out the code inbetween doing other things and obaying Anne (the boss).

What you need to do is make two copies of each bitmap, one for the button, and one slightly a different colour when then button is hidden.

That will do it for you I think.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

QuoteWhat you need to do is make two copies of each bitmap, one for the button, and one slightly a different colour when then button is hidden.

We have similar thoughts about this. The demo above already use two bitmaps for each button, and now I'll use your idea to hide the buttons.
The visitors I had last night did not like my color scheme, and I think they might be right, so tonight I'll experiment a little with other colors.

Right now I'll escort two of my bosses (9 and 11 year old granddaughters)  to town,  and buy christmas presents  for one of their friends is spending her first of three years in Costa Rica.


Egil
Support Amateur Radio  -  Have a ham  for dinner!

Andy

Egil,

I've amended the program a little more.

This one has 4 buttons, when the program is set to in-active, buttons 1, 2, and 4 are hidden.

Button 3 remains "active".

I've also adjusted the alternative bitmap sizes to take into account the button's border which looks better.

See attached.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Great idea Andy!

Thanks for sharing. As I told you yesterday, this is almost identical to what I planned here.
Have been busy doing bitmaps today. Here I'm making a set of new 24x24 bitmaps. Was a little more work than I had expected, and took me a while to decide what colors to use. found out by the oldest development method in histtory: "trial and error".  ;D

But now I have to put this work aside for a while. My oldest granddaughter and her husband will arrive in less than an hour, and will stay here for the weekend.


Egil
Support Amateur Radio  -  Have a ham  for dinner!

Egil

This has been a rather busy week, but this morning I finally came around to work on this project again.
I found that in order to show a full multicolored bitmap inside a button control, the button controls had to be made five pixels both wider and higher than the bitmaps. Otherwise the animation effect would distort the appearance of the bitmap when pushing the button.

The attached picture show that the far left and far right buttons are the only two controls active when program is running. The rest are only bitmaps faking buttons.
The picture also shows that input channels 2 and 3 are "active" and that the output channel is saving the received data to disk. This means that the users  can see the state of the program with just a short glance, which was the only suggestionall users had in common. Have yet to decide if the shown color scheme will be the final one.

Regards,
Egil.

Support Amateur Radio  -  Have a ham  for dinner!

Andy

December 03, 2016, 04:33:45 AM #17 Last Edit: December 03, 2016, 04:37:02 AM by Andy
Egil,

That's great work.

As I mentioned in my last post, you do have to adjust the size of the bitmaps to take account of the button's border.

I found that on my second example that I had to adjust the bitmap's location as +2 across, +2 down, -2 width, and -2 height - it's just a matter of playing around with the sizes.

But I think you have what you wanted now, and it looks great.

Andy.
:)

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.