Minor Delphi/Pascal/Database glitch 
Author Message
 Minor Delphi/Pascal/Database glitch

Another newbie question from a refugee from Clipperland.

I am writing a fairly standard routine for data entry of stock for a retail
store. It does the following:

1. Displays the data entry fields (TDBEdits) mostly
2. Displays a panel containing a TEdit field for keyboard entry of the Stock
Code
3. On Key Press of <Enter>,
            Hides the Stock Code Entry panel
            Locates the appropriate record, and
            cycles through the rest of the data entry fields
4. On Key Down of <F10> in any field, calls Procedure ExitStockEntry (see
below) which
            Posts entered data
            Shows the Stock Code Entry panel again and
            Makes the Stock Code Entry field the Active Control ready to
search for the next record

Problem is, after Procedure ExitStockEntry, although the Stock Code Entry
panel and Edit window are visible and the cursor is positioned in the Edit
window, the cursor is not blinking and a keypress or mouse click is needed
before the cursor blinks and is ready to accept keyboard input.

I can't find any properties of StockCodeEntry which are not set properly at
the time (eg. Enabled, etc.). One thing, though: While StockCodeEntry is in
this state of suspended animation, the first item on the Menu Bar at the top
of the Form is displayed as depressed. Passing the mouse cursor over it
un-presses it but does not fix the StockCodeEntry situation. (F10 does not
call the Menu Bar, by the way.)

So...   any ideas - anything obvious come to mind? See below for the
procedure which leaves StockCodeEntry in this state.

------------------------------------------

procedure TForm1.ExitStockEntry(Sender: TObject);
begin
  DataModule2.Stock.Edit;
  DataModule2.Stock.Post;
  Form1.Panel4.Visible := True;
  Form1.StockCodeEntry.Visible := True;
  Form1.StockCodeEntry.Text := '';
  Form1.ActiveControl := Form1.StockCodeEntry;
end;

--------------------------------------------

By the way, when I first tried to compile the app with this procedure call
in it, I got the error message "Not enough real parameters". I hadn't
intended the procedure to have parameters, but evidently delphi thinks it
does. As an experiment I passed it the name of the Active Control from whose
Event Handler the procedure was called, eg. Procedure
TForm1.ExitStockEntry(EditDepartment) or Procedure
TForm1.ExitStockEntry(EditItemCode). That satisfied the compiler but left me
with the runtime hangup I have described.

Thanks for kind help in weeks past, and in advance for this one

Sincerely

Peter Lawrance
POSability Software

PO Box 3353 Mount Gambier SA 5290
Australia

Bite off more than you can chew - then chew like hell!



Wed, 18 Jun 1902 08:00:00 GMT  
 Minor Delphi/Pascal/Database glitch
Hi Peter,
    Greetings from up sunny Brisbane !   A couple
of things to note. The "parameter" Delphi's referring
to is usually the parent or "Sender" parameter which
can (as you've discovered) be just about anything
since almost everything is derived from TObject.
The problem is that if the reference is not sensible
then you can get a problem. Personally, unless
I specifically want to reference an object, I set it
to "Sender" to effect a chain-on, but you can set
it to "Self" to have the current object become the
parent (which may make more sense). Change
the reference to either of these and you shouldn't
have the "hang" problem any more (assuming no
other problems.)

As for the cursor, you have to ensure that the control
you want to use has the focus so that the cursor/caret
appears where you want it. The easiest way is by
setting it's "tab order" in the form design properties.
Alternatively, *after* the form is up you can use the
SetFocus method like;

Edit1.SetFocus;

HTH

-------------------------------------------------------------------
"If you think you know the answer,
then you don't understand the question !"
-------------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Minor Delphi/Pascal/Database glitch

Quote:
>> procedure TForm1.ExitStockEntry(Sender: TObject);

You don't need the param at all.

procedure TForm1.ExitStockEntry;

will do.

Apparently the control that Windows thinks is the next one that has focus is
the one you're hiding.  Change the tab order or use SetFocus.

And BTW, F10 is the standard Windows hot key for accessing  the menu bar.

Paul / ColumbuSoft


Quote:
> Another newbie question from a refugee from Clipperland.

> I am writing a fairly standard routine for data entry of stock for a
retail
> store. It does the following:

> 1. Displays the data entry fields (TDBEdits) mostly
> 2. Displays a panel containing a TEdit field for keyboard entry of the
Stock
> Code
> 3. On Key Press of <Enter>,
>             Hides the Stock Code Entry panel
>             Locates the appropriate record, and
>             cycles through the rest of the data entry fields
> 4. On Key Down of <F10> in any field, calls Procedure ExitStockEntry (see
> below) which
>             Posts entered data
>             Shows the Stock Code Entry panel again and
>             Makes the Stock Code Entry field the Active Control ready to
> search for the next record

> Problem is, after Procedure ExitStockEntry, although the Stock Code Entry
> panel and Edit window are visible and the cursor is positioned in the Edit
> window, the cursor is not blinking and a keypress or mouse click is needed
> before the cursor blinks and is ready to accept keyboard input.

> I can't find any properties of StockCodeEntry which are not set properly
at
> the time (eg. Enabled, etc.). One thing, though: While StockCodeEntry is
in
> this state of suspended animation, the first item on the Menu Bar at the
top
> of the Form is displayed as depressed. Passing the mouse cursor over it
> un-presses it but does not fix the StockCodeEntry situation. (F10 does not
> call the Menu Bar, by the way.)

> So...   any ideas - anything obvious come to mind? See below for the
> procedure which leaves StockCodeEntry in this state.

> ------------------------------------------

> procedure TForm1.ExitStockEntry(Sender: TObject);
> begin
>   DataModule2.Stock.Edit;
>   DataModule2.Stock.Post;
>   Form1.Panel4.Visible := True;
>   Form1.StockCodeEntry.Visible := True;
>   Form1.StockCodeEntry.Text := '';
>   Form1.ActiveControl := Form1.StockCodeEntry;
> end;

> --------------------------------------------

> By the way, when I first tried to compile the app with this procedure call
> in it, I got the error message "Not enough real parameters". I hadn't
> intended the procedure to have parameters, but evidently Delphi thinks it
> does. As an experiment I passed it the name of the Active Control from
whose
> Event Handler the procedure was called, eg. Procedure
> TForm1.ExitStockEntry(EditDepartment) or Procedure
> TForm1.ExitStockEntry(EditItemCode). That satisfied the compiler but left
me
> with the runtime hangup I have described.

> Thanks for kind help in weeks past, and in advance for this one

> Sincerely

> Peter Lawrance
> POSability Software

> PO Box 3353 Mount Gambier SA 5290
> Australia

> Bite off more than you can chew - then chew like hell!



Wed, 18 Jun 1902 08:00:00 GMT  
 Minor Delphi/Pascal/Database glitch
Thanks mate

Peter

----------------------------------------------------------------------

Quote:

>Personally, unless
>I specifically want to reference an object, I set it
>to "Sender" to effect a chain-on, but you can set
>it to "Self" to have the current object become the
>parent (which may make more sense).

>As for the cursor, you have to ensure that the control
>you want to use has the focus so that the cursor/caret
>appears where you want it. The easiest way is by
>setting it's "tab order" in the form design properties.
>Alternatively, *after* the form is up you can use the
>SetFocus method like;

>Edit1.SetFocus;



Wed, 18 Jun 1902 08:00:00 GMT  
 Minor Delphi/Pascal/Database glitch

Quote:

>>> procedure TForm1.ExitStockEntry(Sender: TObject);

>You don't need the param at all.

>procedure TForm1.ExitStockEntry;

>will do.

------------------------------------------
Great, thanks.
------------------------------------------
Quote:

>Apparently the control that Windows thinks is the next one that has focus
is
>the one you're hiding.  Change the tab order or use SetFocus.

-------------------------------------------
Yep, got that....
-------------------------------------------
Quote:
>And BTW, F10 is the standard Windows hot key for accessing  the menu bar.

--------------------------------------------
*blush* er, I knew that....
--------------------------------------------

Thanks,

Peter Lawrance.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. minor project blues

2. Possible SQL Select glitch!!!

3. BP7 compiler glitch???

4. ODBC 2.0 Configuration Glitch

5. Accessing a delphi database from a pascal code unit

6. DELPHI: TOpenDialog. Minor gripes- but it would be so easy to get right...

7. Delphi and database choices for network installed database

8. Delphi 3: Database Desktop / Database Explorer

9. HELP: sharing database connection (like Delphi and Database Explorer)

10. editer of database on delphi without delphi

11. Fwd: database dll ( delphi ) for non delphi aps

12. MW Object Pascal vs Delphi's Pascal

 

 
Powered by phpBB® Forum Software