Board index » delphi » button.down:=TRUE doesn't work?

button.down:=TRUE doesn't work?

Apeldoorn, 22 jan 97

I have a weird problem with Delphi 1.0 and I want to know if somebody
else experienced the same problem.
It has to do with speedbuttons.

Depending of the state of my database I want some buttons shown as
down and some shown
as up. I'm using button.down:=TRUE if I want a button to appear down.

But... my first problem was that this doesn't always work, sometimes
the button does not go
down. I solved this by first calling button.down:=FALSE and immediatly
after that button.down:=TRUE.
Seemed to work everywhere, great...little glitch in delphi?

But then something {*word*193} happened. I got an error somewhere that
didn't seem to have anything to do with these buttons. 'cannot perform
post operation on a closed dataset'. After hours and hours of
debugging I ended up in my button.down:=TRUE statement. After I put {

Quote
} around it my errormessage disappeared.

Ofcourse it is possible that I have some kind of memory leak or
invalid pointer operation in my program somewhere, for now it looks
like this button.down:=TRUE statement makes an illegal operation of
some kind....

Anybody experienced something like this? read about it? ..  Please
e-mail me at  s...@pi.net

Thanks,

Nico Vermaas

 

Re:button.down:=TRUE doesn't work?


Quote
Nico Vermaas wrote:
> Depending of the state of my database I want some buttons shown as
> down and some shown
> as up. I'm using button.down:=TRUE if I want a button to appear down.

Did you use TSpeedButton instead of TButton? It is intended to show
the pressed down state. For me everything's alright with this component.

Werner.

Re:button.down:=TRUE doesn't work?


Quote
Nico Vermaas wrote:

> Apeldoorn, 22 jan 97

> I have a weird problem with Delphi 1.0 and I want to know if somebody
> else experienced the same problem.
> It has to do with speedbuttons.

> Depending of the state of my database I want some buttons shown as
> down and some shown
> as up. I'm using button.down:=TRUE if I want a button to appear down.

> But... my first problem was that this doesn't always work, sometimes
> the button does not go
> down. I solved this by first calling button.down:=FALSE and immediatly
> after that button.down:=TRUE.
> Seemed to work everywhere, great...little glitch in delphi?

> But then something {*word*193} happened. I got an error somewhere that
> didn't seem to have anything to do with these buttons. 'cannot perform
> post operation on a closed dataset'. After hours and hours of
> debugging I ended up in my button.down:=TRUE statement. After I put {
> } around it my errormessage disappeared.

> Ofcourse it is possible that I have some kind of memory leak or
> invalid pointer operation in my program somewhere, for now it looks
> like this button.down:=TRUE statement makes an illegal operation of
> some kind....

> Anybody experienced something like this? read about it? ..  Please
> e-mail me at  s...@pi.net

> Thanks,

> Nico Vermaas

Dear Nico Vermaas,

        Sometime back I also experienced the same type of problem, but instead
of wasting my time, I tried "Enabled" property of the TSpeedButton
Component. It worked very well. So whenever I want to make my button
appear down, I will make "SpeedButton1.Enabled := False;", else
"Speedbutton1.Enabled := True;", because the ultimate aim is to make a
button Enabled or Disabled.

        If you go into the depth of "Down" property, you will get the logic of
such strange behaviour of Delphi. As SpeedButtons are only meant for
executing some method, which you attach with "OnClick" event of these
buttons, so as a matter of fact the SpeedButton should remain in down
state for the period you keep left mouse button pressed when the mouse
pointer is on this button, and immediately after that, it should come to
its normal state, which is "Down := False", only after it has executed
the method associated with it. So when you execute "SpeedButton.Down :=
True;", its "Down" property again gets converted to False, and the
action is so fast, that you are unable to distinguish the difference
between the two states, and you think that the Down state of SpeedButton
has at all not been achieved. This should happen, because it is the
logical nature of this component.

        I don't know how you have achieved the result of keeping a SpeedButton
Down, by making Down property first to False (which is by default and it
should remain False) and then making it True (which you want), but one
thing is clear that there is some mistake in some of the methods
attached with these buttons, which make the Down property of
SpeedButtons to True permanently.

        I think, the second problem, which you are receiving (Cannot Post on a
Closed DataSets) is also due to this, because if you have achieved the
permanent Down property to True result, then your program might had been
executing the "OnClick" event of your SpeedButton, and in this method
you might had been trying to Post Transactions on a Closed Database,
thus you are getting this error.

        Borland Delphi, undoubtedly is a great tool, but its Documentation is
the worst possible, and the Delphi Help, instead of Helping, many a
times confuses, which is a weakness of Borland. Had the Documentation
and Help been tested properly, then the  programmers would have not
wasted so much of their time. SpeedButton's Down Property is not the
only example of wrong Documentation, but there are many.

        So try to use the "Enabled" property.

Thanks, with Warm Regards!

Arvind Khanna.

Other Threads