Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

TSpeedButton.visible не работает.... [D6, Win95/98]


xn0bys ©   (2003-01-30 14:39:00) 

Есть така промблема:
вот кусок...

type
TSmallDBNavigator = class(TCustomPanel)//class(TCustomPanel)
private
...
protected
{ Protected declarations }
Buttons : Array [0..8] of TSpeedButton;
...
end;

...
//Create
FPanel:=TPanel.Create(self);
...
For i:=8 downto 0 do
begin
Buttons[i]:=TSpeedButton.Create(FPanel);
Buttons[i].Parent:=FPanel;
Buttons[i].Caption:="";
Buttons[i].Flat:=True;
Buttons[i].Tag:=i;
Buttons[i].OnClick:=ButClick;
Buttons[i].Name:=TNames[i];
Buttons[i].Glyph.LoadFromResourceName(HInstance, UpperCase(TNames[i]));
Buttons[i].NumGlyphs:=2;
Buttons[i].Transparent:=False;
Buttons[i].Visible:=False;
end;
...
For k:=8 downto 0 do
begin
If CheckVisible(k) then
begin
Buttons[k].Visible:=True;
Buttons[k].Enabled:=CheckEnabled(k);
Buttons[k].Width:=FBWidth;
Buttons[k].Height:=FBHeight;
Buttons[k].Top:=border;
If Fpanel.BorderStyle=bsSingle
then Buttons[k].Left:=FPanel.Width-m*FBWidth-border-4
else Buttons[k].Left:=FPanel.Width-m*FBWidth-border;
inc(m);
end
else Buttons[k].Visible:=False;
end;
...
function TSmallDBNavigator.CheckEnabled(Value:Integer):Boolean;
begin
Case Value of
0: Result:=(bFirst in FEnabledButtons);
1: Result:=(bPrevious in FEnabledButtons);
2: Result:=(bNext in FEnabledButtons);
3: Result:=(bLast in FEnabledButtons);
4: Result:=(bInsert in FEnabledButtons);
5: Result:=(bDelete in FEnabledButtons);
6: Result:=(bEdit in FEnabledButtons);
7: Result:=(bPost in FEnabledButtons);
8: Result:=(bCancel in FEnabledButtons);
else Result:=False;
end;
end;

function TSmallDBNavigator.CheckVisible(Value:Integer):Boolean;
begin
Case Value of
0: Result:=(bFirst in FVisibleButtons);
1: Result:=(bPrevious in FVisibleButtons);
2: Result:=(bNext in FVisibleButtons);
3: Result:=(bLast in FVisibleButtons);
4: Result:=(bInsert in FVisibleButtons);
5: Result:=(bDelete in FVisibleButtons);
6: Result:=(bEdit in FVisibleButtons);
7: Result:=(bPost in FVisibleButtons);
8: Result:=(bCancel in FVisibleButtons);
else Result:=False;
end;
end;

Проблема вот в чём: В DesignTime почему-то свойство Buttons[i].Visible не действуте, т.е. кнопки всё равно видны, в РунТайме всё нормально.
Что тут может быть?


Романов Р.В.   (2003-01-30 15:01:00) [1]

procedure TControl.CMVisibleChanged(var Message: TMessage);
begin
if not ( csDesigningin ComponentState) or
( csNoDesignVisiblein ControlStyle) then
InvalidateControl(True, FVisible and (csOpaque in ControlStyle));
end;


ZeroDivide   (2003-01-30 14:56:00) [2]

Пока читал и разбирался... уже понаписали :)


ZeroDivide   (2003-01-30 14:55:00) [3]

to [xn0bys]
Ну.. ты кода выкинул.
Интересно зачем это тебе в DesignTime ?
Вообще я такого никогда не пробовал. Но думаю надо у этих буттонов перекрыть Paint так

MyButton.Paint;
begin
if not (csDesignTime in ComponentState) then
inherited;
end;

Мм.. Интересно.. Получится расскажешь :)


xn0bys   (2003-01-30 14:53:00) [4]

jack128

procedure TSmallDBNavigator.SetVisibleButtons(Value : TButtonSet);
begin
If Value<>FVisibleButtons then
begin
FVisibleButtons:=Value;
Invalidate;
//Repaint;
// AutoPosition;
end;
end;

Procedure TSmallDBNavigator.Paint;
begin
Inherited Paint;
AutoPosition;
end;

Кусок

For k:=8 downto 0 do
begin
If CheckVisible(k) then
...

расположен в AutoPosition;


xn0bys   (2003-01-30 14:49:00) [5]


> Романов Р.В. © (30.01.03 14:43)
> Потому что так они сделаны.

Что это значит?


Романов Р.В.   (2003-01-30 14:43:00) [6]

Потому что так они сделаны.


Наверх

Титульная страница Поиск, карта сайта Написать письмо