[fpc-pascal] Windows programming tutorials for FPC

Luca Olivetti luca at ventoso.org
Sat Nov 3 21:47:05 CET 2018


El 3/11/18 a les 21:20, James ha escrit:

> 
> I’ve been tinkering with Lazarus, and I managed to get a form with some 
> buttons based on the examples, and I did make one button open the 
> save-as box… but I’m clueless on how to make the save-as box only come 
> up when needed and by a programming command, not because someone pushed 
> a button.  I still can’t figure out how to write my writeln’s into a 
> text box of some sort.    I get the idea… instead of a sequential 
> program the executes from beginning to end,  everything kind of all 
> happens at the same time


Try this:

-put a memo on the form (say, memo1) and a save dialog.
-in the object inspector double click on the OnCreate event of the form.
-this will create a FormCreate method. Put your code there (including 
the opening of the save dialog if needed).
-in your code show diagnostics messages in the memo 
(mem1.lines.add('whatever'))
-at the end of your code, if everything is OK, add

     Application.ShowMainForm:=false;
     Application.Terminate;


This way, if there are no errors the form won't show, otherwise it will 
show whatever you put in the memo.

Tip: if your code will take a significant amount of time put at the 
beginning

Screen.Cursor:=crHourGlass;

and at the end

Screen.Cursor:=crDefault;


Bye
-- 
Luca



More information about the fpc-pascal mailing list