Phi (Member)
Expert
Messaggi: 241
Iscritto: 30/12/2009
|
Questo programma funziona.
Attenzione: l'ho compilato usando Free Pascal e su Turbo Pascal non dovrebbe funzionare.
Codice sorgente - presumibilmente Delphi |
program triplo; {$APPTYPE GUI} uses Windows, graph; var bottone:hwnd; edit1,edit2:hwnd; scritto : boolean; var P :pchar; procedure calcola; var l:longint; s:string; v, ris:real; begin bar(250,250,410,290); l := getwindowtextlength(edit1); if l = 0 then exit; getmem(P,l); getwindowtext(edit1,P,l+1); s := P; val(s,v,l); ris := 3*v; str(v:10:0,s); outtextxy(250,250,concat('3 x ',s)); str(ris:10:0,s); outtextxy(290,265,'='); outtextxy(250,280,s); l := length(s); s[0]:=#32;s[l+1]:=#0; setwindowtext(edit2,@s); scritto := true; end; function command(Window:HWnd; AMessage:UINT; WParam:WPARAM; LParam:LPARAM): LRESULT;stdcall; begin if lParam = Bottone then calcola; command := 0; end; procedure inizio; begin bottone:=CreateWindow ('Button', 'Calcola',WS_VISIBLE or WS_CHILD or BS_PUSHLIKE,270, 160, 100, 30, Graphwindow, 0, hInstance, nil); edit1:=CreateWindow ('Edit', '', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or ES_NUMBER, 80, 80, 140, 20, GraphWindow, 0, hInstance, nil); edit2:=CreateWindow ('Edit', '', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or ES_NUMBER or es_readonly, 420, 80, 140, 20, GraphWindow, 0, hInstance, nil); end; const G1 : smallint = VGA; G2 : smallint = 1; begin windowtitle := 'Triplo'; ongraphwindowcreation := @inizio; commandmessagehandler := @command; initgraph(G1,G2,''); outtextxy(160,5, 'Inserisci il numero da multiplicare per 3'); outtextxy(210,15, 'poi schiacca il tasto "CALCOLA"'); outtextxy(280,85, 'x 3 ='); setfillstyle(0,0); while iswindow(Graphwindow) do begin sleep(100); if scritto then begin sleep(2000); bar(250,250,430,290); scritto := false; end; end; end.
|
|