Board index » delphi » Questions, questions ...

Questions, questions ...

Hi,

Can anyone answer any of the following:-

1. If I '.Show' a component, such as a TGroupBox or a TPanel, containing
components like TEdits and TComboBoxes, is there any way of coding a
*generic* .SetFocus to the first control in the tab order, whatever it may
be, without looping along the .Controls array?

2. Menus:-
a. Is it correct that I can't set a MainMenu or a PopupMenu as a form's
.ActiveControl?
b. Is it possible to display a MainMenu already dropped down?
c. The MenuItem hints I've written aren't displaying - what should I check?

3. I've set up a TPanel in each form to display LongHints in the
TPanel.Caption property - where do I write the Application.OnHint procedure?

4. I've a 'calculated' field - actually a Description set from a Code in the
database table row by the OnCalcFields event. Can/If I hitch the data-aware
ComboBox to it, what should I be doing to change the underlying Code if the
user changes the Description?

5. When I use TDataSet.Delete, why do data-aware controls continue to
display the data of the deleted record? Can/How do I get the data-aware
controls to clear, as happens when I use TDataSet.Insert?

6. Can/How do I set up a simple field type with its size equivalent to the
size of a field in the database?
For instance, the field 'Account Number' is used in a number of tables; it's
always a TStringField and the .Size property is always '8'.
For where a field value is passed to/from a procedure or function, I've set
up the field type 'TAcNumber = String[8]'.
However, so that any change to the database field size is propagated
automatically, I would prefer something like:-
'TAcNumber = String[Table1.AcNumber.Size]'
but this construction gives a syntax error.

Thanks in advance for any help.

Regards,

Stuart :)

P.S. If you want to e-mail me, the 'Reply-To' address is anti-spammed, but
should be decipherable.

 

Re:Questions, questions ...


Well I'll do no 1 anyway
Cant see how you could skip looping with random controls.

procedure TForm1.FormShow(Sender: TObject);
Var
   A:Integer;
begin
   For A:=0 to Panel1.ControlCount-1 Do
      If Panel1.Controls[A] Is TwinControl then
         Begin
            (Panel1.Controls[A] as TwinControl).SetFocus;
            Break;
         End;

end;

No 5 is probably to do with CachedUpdates or try calling dbgrid1.Update

Not sure I understand what you want in the rest. So I'll have a
rest<ggg>
Nick

Quote
Stuart wrote:

> Hi,

> Can anyone answer any of the following:-

> 1. If I '.Show' a component, such as a TGroupBox or a TPanel, containing
> components like TEdits and TComboBoxes, is there any way of coding a
> *generic* .SetFocus to the first control in the tab order, whatever it may
> be, without looping along the .Controls array?

> 2. Menus:-
> a. Is it correct that I can't set a MainMenu or a PopupMenu as a form's
> .ActiveControl?
> b. Is it possible to display a MainMenu already dropped down?
> c. The MenuItem hints I've written aren't displaying - what should I check?

> 3. I've set up a TPanel in each form to display LongHints in the
> TPanel.Caption property - where do I write the Application.OnHint procedure?

> 4. I've a 'calculated' field - actually a Description set from a Code in the
> database table row by the OnCalcFields event. Can/If I hitch the data-aware
> ComboBox to it, what should I be doing to change the underlying Code if the
> user changes the Description?

> 5. When I use TDataSet.Delete, why do data-aware controls continue to
> display the data of the deleted record? Can/How do I get the data-aware
> controls to clear, as happens when I use TDataSet.Insert?

> 6. Can/How do I set up a simple field type with its size equivalent to the
> size of a field in the database?
> For instance, the field 'Account Number' is used in a number of tables; it's
> always a TStringField and the .Size property is always '8'.
> For where a field value is passed to/from a procedure or function, I've set
> up the field type 'TAcNumber = String[8]'.
> However, so that any change to the database field size is propagated
> automatically, I would prefer something like:-
> 'TAcNumber = String[Table1.AcNumber.Size]'
> but this construction gives a syntax error.

> Thanks in advance for any help.

> Regards,

> Stuart :)

> P.S. If you want to e-mail me, the 'Reply-To' address is anti-spammed, but
> should be decipherable.

Re:Questions, questions ...


In article <79pvn6$lq...@nclient1-gui.server.{*word*269}.net>, "Stuart"

Quote
<stuart....@{*word*269}.net> writes:
>Can anyone answer any of the following:-

1 No because the TabOrder can be different from any other order of the
components
var
  i : integer;
begin
  for i := 0 to ControlCount - 1 do
    if Controls[i].TabOrder := 0 then begin
      Controls[i].SetFocus;
      break;
  end;  
end;

2 a) No, only TWinControls can have focus and menuitems are not TWinControls.

4 Cross refer back to the description code and set the database code field to
that value. If your codes are the same as the ComboBox.ItemIndex it would all
work easily, otherwise you have to translate form CB.II to your code.

5 Call TTable.Refresh, the data displayed will then be the next record's data
(or the previous if at EOF). If you don't want this displayed, then you have to
code what you want - just blank the fields, go to Insert mode, go to QBE
display etc.

6
procedure TForm1.SetDBEditSize(DBE : TDBEdit);
var
  Fld : TField;
begin
  Fld := DBE.DataSource.DataSet.FieldByName(DBE.DataField);
  DBE.MaxLength := Fld.Size;
  DBE.Width :=Self.Canvas.TextWidth('X') * Fld.Size;
end;

This assumes the font size in the DBEdit is the same as in the form

Alan Lloyd
alangll...@aol.com.

Re:Questions, questions ...


Quote
Stuart <stuart....@{*word*269}.net> wrote:

: 2. Menus:-
: c. The MenuItem hints I've written aren't displaying - what should I check?
:
: 3. I've set up a TPanel in each form to display LongHints in the
: TPanel.Caption property - where do I write the Application.OnHint procedure?

For 2.c., make sure the Application.ShowHint property is set to true.  Set
this property at run-time.

For 2.c. AND 3., see the on-line help for the application's OnHint event.
In Delphi 2.0 at least, there's an example that will tell you everything
you want to know.  I would post it here, but it's a bit lengthy.

Hope that helps.

- Mike

--
+------------------------+----------------------------------------+
| Michael J. Sussman     |    Looking for a fun game to play?     |
| Green Diamond Software |      Try DynaMine for free today!      |
| g...@primenet.com       | Check out http://www.primenet.com/~gds |
+------------------------+----------------------------------------+

Other Threads