[Lazarus] Newbie questions

Bill de Carle ve2iq at magma.ca
Tue May 6 15:03:45 CEST 2008


At 09:39 PM 5/5/2008, Paul Ishenin wrote:
>1. since fos is a pointer to a record you should aceess its member with
>^. in objfpc mode. So just write it so:
>fos^.pFunc := FO_COPY;
>
>And I see another problem in your code. Since fos is a pointer you need
>to allocate it with GetMem, and deallocated later with FreeMem.

Thank you Paul.  I made the necessary changes, recompiled and voila! 
it worked first time.
Just out of curiosity, how did you know fos was a pointer?  I have 
not been able to find where LPSHFileopstructa is defined either.  Is 
this documented somewhere or does the type identifier give us the 
clue?  Not knowing otherwise, do all Windows API calls work that way?

>Another problem is that you are using windows API - this is not cross
>platform way - you will not be able to compile the same code on linux or
>mac. If you want to copy one file from path_a to path_b then I can
>suggest you to use streams.

Fortunately I don't need to compile on linux or mac.  I wanted to 
transfer a group of files as in: COPY Z:\VA3NRR*.txt C:\BACKUP and 
this shfileoperation seemed to be the most straightforward way to do 
it.  I'll look into using Stream.

> > Question 2:
> > In my lazarus-generated data input window the user can hit the tab
> > key to move to the
> > next edit window or combobox while filling out the form.  That works
> > fine.  How can I
> > make it move the cursor from one box to the next by hitting the space
> > bar instead of
> > the tab key, and how can I "place" the cursor in the appropriate box
> > to start the next
> > data entry from within the Lazarus unit1 module so the user doesn't
> > have to use the
> > mouse?
>
>You can turn KeyPreview of your Form to True and add OnKeyPress handler.
>In your OnKeyPress handler make a check for space key and focus control
>you like.
>
>For example:
>
>TForm1.Form1KeyPress(Sender: TObject; var Key: Char);
>begin
>    if Key = 32 then
>      PerformTab(True);
>end;

Thanks again.  I had to use: if Key=' ' (suppose if key=chr(32) would 
work also).   Where did you learn about the PerformTab(True)?  Is 
there a list of all those things available somewhere?

> >
> > Question 3:
> > After the last box is filled in, it would be convenient to just hit
> > the ENTER key instead
> > of using the mouse to click the "Submit" button.  I have no idea at
> > all how to ask Lazarus
> > to do this.
>
>Turn on "Default" property of your "Submit" button. It will catch ENTER
>itself.

Works exactly the way I wanted.  Where does one find out these 
things?  It's like I'm still groping around in a dark 
room.  Eventually I'll figure it all out.  Thanks a million,
Bill




More information about the Lazarus mailing list