[DUG] New User Of Delphi

Bob Pawley rjpawley at shaw.ca
Mon Mar 26 09:50:49 NZST 2007


I think I need more specific help as I am new to Pascal - although I have 
some experiance in HTML and SQL.

Let me explain what I have -

The following is the existing sender and receiver (handler?) -
-------
Sender

procedure TLoopBuilderForm.DeviceNotebookMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  {request a device build}

  DeviceNotebookMouseUpAlias(Sender, Button, Shift, X, Y);

end;
---------
Handler

procedure   DeviceNotebookMouseUpAlias(Sender: TObject;
        Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
   indx : integer;
   RegisteredClass  : TdsDeviceClass;
   PermissionGranted : Boolean ;

   begin

   if Sender is TImage then

   begin
      {check if this is a device request}
      try
         PermissionGranted := FALSE;

        indx := StreamClassRegistry.indexOf(TImage(Sender).name);
        RegisteredClass := StreamClassRegistry.OBJECTS[indx] AS 
TdsDeviceClass;
        CurrDeviceReq :=  RegisteredClass.TheClass;      {create the 
registered object}
         {first check if any device spawning is required....}
         DigDeviceContactSelectionForm.RequestContactSelectionUpdate
                            (TBaseDevice(CurrDeviceReq), PermissionGranted);


         {end test.}

        if PermissionGranted then
        begin
----------
>From here the code goes on to develop the rest of the sequence, dependent 
upon the flavour of the image just received.


Following is the code that I have developed to take the database to the 
handler. This compiles but  nothing happens when I click on NewLoopButton.

One of the things that I don't understand is - Does the reciever (handler) 
rely on the name of the image as sent from the database to determine if it 
is a TImage or does it rely on the TImage component to determine if the 
Sender is a TImage?

---------
procedure TAutoLoopBldrForm.NewLoopButtonMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

  begin

        PSQLQuery1.Close;{close the query}
      //assign new SQL expression
      PSQLQuery1.SQL.Clear;
      PSQLQuery1.SQL.Add ('Select Monitor_Item_ID');
      PSQLQuery1.SQL.Add ('FROM P_ID.Loops');
      PSQLQuery1.SQL.Add ('WHERE Loop_name = :Loop_Name');
      PSQLQuery1.Open ;
      DeviceNotebookMouseUpAlias(Sender, Button, Shift, X, Y);
end;
------------

Bob



----- Original Message ----- 
From: "Dennis Chuah" <dennis_cs_chuah at hotmail.com>
To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.net.nz>
Sent: Sunday, March 25, 2007 1:29 PM
Subject: Re: [DUG] New User Of Delphi


>
> Bob,
>
> Hi.  It would depend on your skill level, eg. whether you are new to 
> Delphi, or new to Programming altogether.  So to start with, this is going 
> to be pretty general, and you can ask questions about the specifics.  Bear 
> also in mind, there are many ways to do the same thing.
>
> 1.  Read the list of TImage names into a TStringList.
> 2.  Handle the OnClick event of the TImage - you can probably use the same 
> handler for all the TImage components.
> 3.  In the handler, check TComponent (Sender).Name against the 
> TStringList. You probably need to have a form level counter that is 
> initialised to 0 - to represent the first item on the TStringList.
> 4.  Increment this counter as the user clicks on the TImage in the correct 
> sequence.  An out of sequence click could set the counter back to 0.
>
> Example code:
>
> // Form variables
> FImageNames: TStringList;
> FClickIndex: Integer; // Counter
>
> // In the OnClick
> if TComponent (Sender).Name = FImageNames[FClickIndex] then
>  Inc (FClickIndex)
> else
>  FClickINdex := 0;
>
> Remember to create the TStringList in the FormCreate and free it in the 
> FormDestroy.
>
> HTH.
>
> Regards,
> Dennis.
>
> ----- Original Message ----- 
> From: "Bob Pawley" <rjpawley at shaw.ca>
> To: <delphi at ns3.123.net.nz>
> Sent: Monday, March 26, 2007 6:27 AM
> Subject: [DUG] New User Of Delphi
>
>
> Hi
>
> I've just joined your list and am seeking help.
>
> I have an existing application that performs a particular sequence of 
> events when the user clicks a series of TImages.
>
> I also have a newly developed PostgreSQL database that generates a column 
> that lists the names of the required TImages.
>
> I want to trigger the image sequence in Delphi from the list developed in 
> PostgreSql.
>
> What do you need to know from me to provide help??
>
> Bob Pawley
>
>
> --------------------------------------------------------------------------------
>
>
>> _______________________________________________
>> Delphi mailing list
>> Delphi at ns3.123.net.nz
>> http://ns3.123.co.nz/mailman/listinfo/delphi
>>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.net.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
> 



More information about the Delphi mailing list