[DUG] New User Of Delphi

karlreynolds at xtra.co.nz karlreynolds at xtra.co.nz
Tue Mar 27 10:30:34 NZST 2007


>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;

Is this actual code? If not then I'm not seeing the real picture and you can
pretty much ignore the following. But if so then you have quite a few pieces
to fill in.

Firstly your parameter loop_name needs a value
(PSQLQuery1.ParamByName('loop_name').AsString := ...). But much more
importantly, you aren't translating between database fields and an image -
the Sender, Button, Shift, X, Y parameters are just the parameters that were
passed into your function.

If you're storing an image in a database, I presume you will need to stream
it into a blob (look up TBlobField) in order to save it to the database, and
then extract it back into a TImage before you can pass it to be used. You
need to create a TImage (ie. LImage := TImage.Create) before you have it to
pass to DeviceNotebookMouseUpAlias (as the Sender parameter).

Hope that helps a little but I'm not sure because I haven't entirely
fathomed where you're heading yet.

Cheers,
Carl

-----Original Message-----
From: delphi-bounces at ns3.123.net.nz [mailto:delphi-bounces at ns3.123.net.nz]
On Behalf Of Bob Pawley
Sent: Monday, March 26, 2007 9:51 AM
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] New User Of Delphi

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
> 

_______________________________________________
Delphi mailing list
Delphi at ns3.123.net.nz
http://ns3.123.co.nz/mailman/listinfo/delphi




More information about the Delphi mailing list