Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Pascal - gui
Forum - Pascal - gui - Pagina 2

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
Phi (Member)
Expert


Messaggi: 241
Iscritto: 30/12/2009

Segnala al moderatore
Postato alle 12:46
Mercoledė, 31/03/2010
Questo programma funziona.
Attenzione: l'ho compilato usando Free Pascal e su Turbo Pascal non dovrebbe funzionare.


Codice sorgente - presumibilmente Delphi

  1. program triplo;
  2. {$APPTYPE GUI}
  3.  
  4. uses Windows, graph;
  5.  
  6. var
  7. bottone:hwnd;
  8. edit1,edit2:hwnd;
  9. scritto : boolean;
  10.  
  11. var P :pchar;
  12. procedure calcola;
  13. var l:longint;
  14.     s:string;
  15.     v, ris:real;
  16. begin
  17. bar(250,250,410,290);
  18. l := getwindowtextlength(edit1);
  19. if l = 0 then exit;
  20. getmem(P,l);
  21. getwindowtext(edit1,P,l+1);
  22. s := P;
  23. val(s,v,l);
  24. ris := 3*v;
  25. str(v:10:0,s);
  26. outtextxy(250,250,concat('3 x ',s));
  27. str(ris:10:0,s);
  28. outtextxy(290,265,'=');
  29. outtextxy(250,280,s);
  30. l := length(s);
  31. s[0]:=#32;s[l+1]:=#0;
  32. setwindowtext(edit2,@s);
  33. scritto := true;
  34. end;
  35.  
  36.  
  37. function command(Window:HWnd; AMessage:UINT; WParam:WPARAM; LParam:LPARAM): LRESULT;stdcall;
  38. begin
  39. if lParam = Bottone then calcola;
  40. command := 0;
  41. end;
  42.  
  43. procedure inizio;
  44. begin
  45. bottone:=CreateWindow ('Button', 'Calcola',WS_VISIBLE or WS_CHILD or BS_PUSHLIKE,270, 160, 100, 30, Graphwindow, 0, hInstance, nil);
  46. edit1:=CreateWindow ('Edit', '', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or ES_NUMBER, 80, 80, 140, 20, GraphWindow, 0, hInstance, nil);
  47. 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);
  48. end;
  49.  
  50. const
  51. G1 : smallint = VGA;
  52. G2 : smallint = 1;
  53.  
  54. begin
  55. windowtitle := 'Triplo';
  56. ongraphwindowcreation := @inizio;
  57. commandmessagehandler := @command;
  58. initgraph(G1,G2,'');
  59. outtextxy(160,5,  'Inserisci il numero da multiplicare per 3');
  60. outtextxy(210,15, 'poi schiacca il tasto "CALCOLA"');
  61. outtextxy(280,85, 'x 3   =');
  62. setfillstyle(0,0);
  63. while iswindow(Graphwindow) do begin
  64.  sleep(100);
  65.  if scritto then begin
  66.   sleep(2000);
  67.   bar(250,250,430,290);
  68.   scritto := false;
  69.  end;
  70. end;
  71. end.




PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo