Icon in Bevelbutton disappears when hoovering mousepointer over it

I have the next problem:
I created a containercontrol with a bevelbutton in it. The purpose is that a small icon will be shown and depending on the event the backcolor changes. When I run the application the buttons with the correct backcolor and the icon are shown. However, when I hoover over the button the backcolor disappears and the icon disappears and I am looking at a grey empty button.

The color and the icon are set in Runtime. If I configure the button in the Inspector and I run the application, the backcolor and the icon are not disappearing from the button when I hoover my mouse over the button. Mousemove handler is not used.

To set the backcolor I use (DisasterButton(DistIndex) is an runtime created array of bevelbuttons):

if val(cell(2))>= 5 and val(cell(2)) <=6 then
DisasterButton(DistIndex).Backcolor = Yellow
Elseif val(cell(2))>=6 and val(cell(2)) <=7 then
DisasterButton(DistIndex).Backcolor = Orange
Elseif val(cell(2))>=7 and val(cell(2)) <=8 then
DisasterButton(DistIndex).Backcolor = Red
Elseif val(cell(2))>=8 then
DisasterButton(DistIndex).Backcolor = Purple
end if

Someone has an idea why in runtime added backcolors and icons disappears from my buttons when I move my mouse over it (without clicking on the button!)?

What do your buttons have in the Paint and the MouseOver events?

Nothing, I did not use any event handler.

[quote=239774:@Rob Valk]if val(cell(2))>= 5 and val(cell(2)) <=6 then
DisasterButton(DistIndex).Backcolor = Yellow
Elseif val(cell(2))>=6 and val(cell(2)) <=7 then
DisasterButton(DistIndex).Backcolor = Orange[/quote]

This code matches a val of 5 and 6 in the first test, and 6 and 7 in the second test. Is that what you intended?

Yes, but this code is not in any event handle, it is just a small part of the code where the force between 5 and 6 makes a yellow background, 6 and 7 makes a orange background, 7 and 8 makes a red background and 8 and higher makes a purple background.

This works very well, the background of the BevelButton changes on these values, but…if you move the mousepointer over the button, the color disappears and the icon too, which is shown in the button. BUT, only when the color and icon are assigned to the button in runtime. When you set the backcolor and the icon in the inspectore pane, they will not disappear when you move the mouse over it.

Is this behavior maybe a result behavior of the container I did put the BevelButton in. Also the BevelButtons are added during runtime and do not disappear. Only the color and the icon.of the BevelButton.

Any idea?

Ok, I found it… it is just a crappy videocard in my development machine at work :frowning:

I loaded the project on my development machine at home, which does have a very good videocard, and the colors stay and my icon stays visible. Need to order a decent videocard at work, coming monday.

Thanks for responding, did not see the behavior before on the machine.

Sorry. A little brain cramp on my part. Was thinking integers.

Actually, you would still have a collision on an integer. What colour would 6 be for example?

Anyways, glad you got the display sorted out.

[quote=239914:@Tanner Lee]Sorry. A little brain cramp on my part. Was thinking integers.

Actually, you would still have a collision on an integer. What colour would 6 be for example?

Anyways, glad you got the display sorted out.[/quote]
All below 6 are ignored and it it working fine now, thanks: -)

And…unfortunately…The problem is not gone. Also at home today on my development machine it whiped out the color and the icon when it was assigned to the button in runtime, after I moved my mousepointer over the BevelButton.
Again, the color and the background properties are not whiped out when set in the Inspector pane. Another phenominum is that the assigned index number to the button is not set in the properties or not ‘remembered’. When I check the indexnumber after all buttons are placed on the desktop, they all have index #2.

Tell me where I go wrong, sitting on this for 2 days (today is the third day) and I do not see it. Might be something small I do not see.

The next code I did write to add a container(there is no code in any event handler:

Dim NEO as integer = NumOfEvents
Dim I,J as Integer
Dim Aevt() as string = gEVT()
Dim Cell() as string
Dim CR as string = Chr(13)+Chr(10)
DIm Raak as Boolean = False
Dim MajDist() as string = MajorDisasters()
Dim DistGroup as new DisasterPointer

For I = 1 to NEO
cell()=split(Aevt(I),",")
Raak = False
if val(cell(2))>= 5 then
for J = 1 to DistIndex
if instr(MajDist(J),cell(0)) = 1 then
Raak = True
end if
next
if Raak = False then
DistIndex = DIstIndex + 1

// coordinate to pixels calc received from Will Shank, Xojo forum
dim centerX As Double = 1798 / 2 //maps center, also half sizes
dim centerY As Double = 900 / 2
dim latScaling As Double = centerY / 90 //scales degree range to half sizes
dim lonScaling As Double = centerX / 180
dim x As Double ’ = centerX + scLon * lonScaling //compute
dim y As Double ’ = centerY - scLat * latScaling

    scLat = val(cell(4))
    scLon = val(cell(3))
    DistGroup = new DisasterPointer
    DistGroup.EmbedWithin (self, 10,10,31,31)
    DistGroup.Left =centerX + scLon * lonScaling
    DistGroup.top =centerY - scLat * latScaling
    MajDist(DistIndex) = Aevt(I)
    DistGroup.NewDisaster(Aevt(I))
  end if
end if

next

The next code I used to add the button and fill the properties (as method in the Container control):

Dim Cell() as string
Dim CR as string = Chr(13)+Chr(10)
Dim I as Integer
Dim disastersToAdd As Integer
Dim DistButton as new DisasterButton

cell()=split(Disaster,",")
scLat = val(cell(4)) //Latitude
scLon = val(cell(3)) //Longitude

DistButton = new DisasterButton
DisasterButton(DistIndex).Index = DistIndex // give the buttun the same index as the event

if instr(Cell(0),“Magnitude”) = 1 then
DisasterButton(DistIndex).HelpTag = Cell(1) + " "+cell(0)
else
DisasterButton(DistIndex).HelpTag = Cell(1) + " Magnitude “+cell(5)+” - " + cell(0)
end if

if cell(5) = “eq” or instr(Uppercase(cell(0)),“NUCLAER”)= 0 then
DisasterButton(DistIndex).Icon = earthquakesmall_wb
else
DisasterButton(DistIndex).Icon = nucluer
end if

// value 0-4.9 does not get processed, when value is met, color the background

if val(cell(2))>= 5 and val(cell(2)) <6 then
DisasterButton(DistIndex).Backcolor = Yellow
Elseif val(cell(2))>=6 and val(cell(2)) <7 then
DisasterButton(DistIndex).Backcolor = Orange
Elseif val(cell(2))>=7 and val(cell(2)) <8 then
DisasterButton(DistIndex).Backcolor = Red
Elseif val(cell(2))>=8 then
DisasterButton(DistIndex).Backcolor = Purple
end if

Give me a project file and I’ll have a look.

Hi Beatrix, thanks for the offer. I wanted to send it to you when I found what I did wrong :s

Will you share your solution with us? :smiley:

Sure, my mistake was that I created a container control containing control array’s. That should not be done, in my case at least. Maybe there is anybody else who could work with this, but this caused with me that, once the containerControl was loaded, all values for the controls were ‘forgotten’, thus moving mouse over the BevelControl it lost the link to the picture.

So, I created a Container control, named DistPointer, containing the bevelbutton and dimentioned the ContainerControl as DistGroup:

Dim Distgroup as new DistPointer (Distpointer is the Container Control)
Dim DistIndex as Integer

Then I loaded the ContainerControl on my page and set the values where the Container should come on the screen:

DistIndex = DistIndex + 1
Distgroup = new DistPointer
DistGroup.EmbedWithin(self,10,10,31,36)
Distgroup.Left = x
Distgroup.Top = y

In the ContainerControl I created a method (NewDist) which does the rest inside the Container control:

Called with:
Distgroup.NewDist(WhateverYouwantValueString)

Inside the Method of the Container Control Distgroup (=DistPointer):

BevelButton.Icon = picture (any name of a picture inside the project)
BevelButton.helpText = “WhateverYouwantValueString”

I used the helptag to display the text I want to show when someone moves the mouse over it and I do not want to disturb the picture with text)

This way I use to put a tiny bevelbutton (31x36 pixels) on a worldmap with the picture of my choice to show the type of event. When people wants to see what is going on, they hoover over the bevelbutton and the helptag will show a short message. When they need to have more info about the event you can do that by sending a CommaSeparatedValueString in the Distgroup.NewDist(CommaSeparatedValueString,DistIndex)

Within the method inside the container control you can make a split:

sub NewDist(CommaSeparatedValueString,DistIndex)

Dim cell() as string

cell()=split(CommaSeparatedValueString,",")

You will get the number of comma’s + 1 number of cells

ie. “This is a test”, “Info is always available”, “Name something”) will give 3 cells:

cell(0) = “This is a test”
cell(1) = “Info is always available”
cell(2) = “Name something”

You can assign the next values to the BevelButton:

BevelButton.Index = DistIndex
BevelButton.Helptag = cell(1)

to show a messagebox with more info when they press on the button:

msgbox(cell(0)+ ". " + "When you need it, " + cell(1) + ". “+” Or if this is not enough: "+cell(2))

Ofcourse the sequence you want to print the cell’s is up to you.

The Index (= DistIndex) you can use to point to an index of a global available array and execute some other method inside the Container Control. You can execute this with the action event of the BevelButton.

This is my solution and it works perfect, each ContainerControl works as a piece on its own, very nice.

I hope that this is what you meant,

Thank you for sharing your findings with us.
I hope it’s ok if i ask you to please mark you last Post as “Answer”?

Thank you in advance :slight_smile:

BTW: Often such detailed information about a solution leading to new ideas from other Forum Members. :slight_smile:

OK, I will post my findings as answer to the question. Well, I hope it does bring out new ideas, that is just a nice thing of a forum, one can adapt such finding into his project and post maybe later new ideas :slight_smile: