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

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
Tullio (Normal User)
Newbie


Messaggi: 15
Iscritto: 21/06/2009

Segnala al moderatore
Postato alle 13:38
Domenica, 28/03/2010
:hail: mi spiegate come fare a inserire un programma in una finestra che non sia come quella del ms-dos?:hail::hail:


PROGRAM triplo;
VAR n:INTEGER;  
begin                                
writeln(' Questo programma calcola il triplo di un numero dato ');
writeln;
writeln('Introduci un numero intero ');
readln(n);
n:=n*n*n;
writeln;
writeln(' Il numero scelto alla terza è ' ,n);
writeln;
writeln(' Premi enter per finire');
readln;
writeln( ' By Tullio Pizzuti');
readln;
end.

by netarrow: fixato il titolo

Ultima modifica effettuata da netarrow il 28/03/2010 alle 14:15
PM Quote
Avatar
djleo (Member)
Pro


Messaggi: 72
Iscritto: 07/03/2010

Segnala al moderatore
Postato alle 13:46
Domenica, 28/03/2010
spiegati meglio???

PM Quote
Avatar
Tullio (Normal User)
Newbie


Messaggi: 15
Iscritto: 21/06/2009

Segnala al moderatore
Postato alle 14:27
Domenica, 28/03/2010
inserirlo in una finestra vuota!!  sai quelle quelle bianche?!!

PM Quote
Avatar
djleo (Member)
Pro


Messaggi: 72
Iscritto: 07/03/2010

Segnala al moderatore
Postato alle 15:01
Domenica, 28/03/2010
prova con questa istruzione

Codice sorgente - presumibilmente Plain Text

  1. textcolor(0)
  2. textbackground(15)




Ultima modifica effettuata da djleo il 28/03/2010 alle 15:02
PM Quote
Avatar
Ocentral (Normal User)
Pro


Messaggi: 86
Iscritto: 25/12/2009

Segnala al moderatore
Postato alle 15:15
Domenica, 28/03/2010
allora se usa windows lei e' fortunato.
Ecco il codice per una semplice applicazione windows:

{$APPTYPE GUI}
{$MODE DELPHI}
program WinHello;

uses
  Strings, Windows;

const
  AppName = 'Triplo di un numero';

//qui si controllano tutti gli eventi della finestra
function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;
                    LParam: LPARAM): LRESULT; stdcall; export;

  var
     dc : hdc;//e'  il device context: nel device context si fanno tutti i nostri disegni
               //riguarda la grafica
     ps : paintstruct;//e' un record per il disegno
     r : rect;

begin
  WindowProc := 0;

  case AMessage of//amsesage e' un numero che ci da gli eventi che accadono
    wm_paint:
      begin
         dc:=BeginPaint(Window,@ps);
         GetClientRect(Window,@r);
         DrawText(dc,'Introduci un numero intero',-1,@r,
           DT_SINGLELINE );
         EndPaint(Window,ps);
         Exit;
      end;
    wm_Destroy:
      begin
         PostQuitMessage(0);
         Exit;
      end;
  end;

  WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
end;

//registrazione delle caratteristiche della finestra
function WinRegister: Boolean;
var
  WindowClass: WndClass;
begin
  WindowClass.Style := cs_hRedraw or cs_vRedraw;
  WindowClass.lpfnWndProc := WndProc(@WindowProc);
  WindowClass.cbClsExtra := 0;
  WindowClass.cbWndExtra := 0;
  WindowClass.hInstance := system.MainInstance;
  WindowClass.hIcon := LoadIcon(0, idi_Application);
  WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  WindowClass.hbrBackground := GetStockObject(WHITE_BRUSH);
  WindowClass.lpszMenuName := nil;
  WindowClass.lpszClassName := AppName;

  Result := RegisterClass(WindowClass) <> 0;
end;

//crea la windows class. questa e' una classe che contiene le caratteristiche della
//nostra finestra
function WinCreate: HWnd;
var
  hWindow: HWnd;
begin
  hWindow := CreateWindow(AppName, 'Questo programma calcola il triplo di un numero dato',
              ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,
              cw_UseDefault, cw_UseDefault, 0, 0, system.MainInstance, nil);

  if hWindow <> 0 then begin
    ShowWindow(hWindow, CmdShow);
    ShowWindow(hWindow, SW_SHOW);
    UpdateWindow(hWindow);
  end;

  Result := hWindow;
end;


var
  AMessage: Msg;
  hWindow: HWnd;

begin
  if not WinRegister then begin
    MessageBox(0, 'Register failed', nil, mb_Ok);
    Exit;
  end;
  hWindow := WinCreate;
  if longint(hWindow) = 0 then begin
    MessageBox(0, 'WinCreate failed', nil, mb_Ok);
    Exit;
  end;

  while GetMessage(@AMessage, 0, 0, 0) do begin
    TranslateMessage(AMessage);
    DispatchMessage(AMessage);
  end;
  Halt(AMessage.wParam);
end.

Per la compilazione sarebbe meglio usare freepascal o devpascal

PM Quote
Avatar
djleo (Member)
Pro


Messaggi: 72
Iscritto: 07/03/2010

Segnala al moderatore
Postato alle 15:26
Domenica, 28/03/2010
scusa ma come inserisco il numero

PM Quote
Avatar
Ocentral (Normal User)
Pro


Messaggi: 86
Iscritto: 25/12/2009

Segnala al moderatore
Postato alle 15:51
Domenica, 28/03/2010
si potrebbe usare wm_char

nella parte dei possibili valori di amssage

PM Quote
Avatar
Ocentral (Normal User)
Pro


Messaggi: 86
Iscritto: 25/12/2009

Segnala al moderatore
Postato alle 16:02
Domenica, 28/03/2010
o anche  WM_KEYDOWN

PM Quote
Avatar
Ocentral (Normal User)
Pro


Messaggi: 86
Iscritto: 25/12/2009

Segnala al moderatore
Postato alle 22:03
Domenica, 28/03/2010
ho trovato{$APPTYPE GUI}
{$MODE DELPHI}
program WinHello;

uses
  Strings, Windows;

const
  AppName = 'Triplo di un numero';

var
  bottone:hwnd;
  edit1,edit2:hwnd;

//qui si controllano tutti gli eventi della finestra
function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;
                    LParam: LPARAM): LRESULT; stdcall; export;

  var
     dc : hdc;//e'  il device context: nel device context si fanno tutti i nostri disegni
               //riguarda la grafica
     ps : paintstruct;//e' un record per il disegno
     r : rect;

begin
  WindowProc := 0;

  case AMessage of//amsesage e' un numero che ci da gli eventi che accadono
    wm_paint:
      begin
         dc:=BeginPaint(Window,@ps);
         GetClientRect(Window,@r);
         DrawText(dc,'Introduci un numero intero',-1,@r,
           DT_SINGLELINE  ;);
         EndPaint(Window,ps);
         Exit;
      end;
    wm_Destroy:
      begin
         PostQuitMessage(0);
         Exit;
      end;
     wm_Command : begin
                    if lParam = Bottone then MessageBeep (mb_OK);
                    if lparam = edit1 then edit;
                  end;
  end;

  WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
end;

//registrazione delle caratteristiche della finestra
function WinRegister: Boolean;
var
  WindowClass: WndClass;
begin
  WindowClass.Style := cs_hRedraw or cs_vRedraw;
  WindowClass.lpfnWndProc := WndProc(@WindowProc);
  WindowClass.cbClsExtra := 0;
  WindowClass.cbWndExtra := 0;
  WindowClass.hInstance := system.MainInstance;
  WindowClass.hIcon := LoadIcon(0, idi_Application);
  WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  WindowClass.hbrBackground := GetStockObject(GRAY_BRUSH);
  WindowClass.lpszMenuName := nil;
  WindowClass.lpszClassName := AppName;

  Result := RegisterClass(WindowClass) <> 0;
end;

//crea la windows class. questa e' una classe che contiene le caratteristiche della
//nostra finestra
function WinCreate: HWnd;
var
  hWindow: HWnd;
begin
  hWindow := CreateWindow(AppName, 'Questo programma calcola il triplo di un numero dato',
              ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,
              cw_UseDefault, cw_UseDefault, 0, 0, system.MainInstance, nil);

  if hWindow <> 0 then begin
    ShowWindow(hWindow, CmdShow);
    ShowWindow(hWindow, SW_SHOW);
    UpdateWindow(hWindow);
  end;

  Result := hWindow;
end;


var
  AMessage: Msg;
  hWindow: HWnd;

begin
  if not WinRegister then begin
    MessageBox(0, 'Register failed', nil, mb_Ok);
    Exit;
  end;
  hWindow := WinCreate;
  bottone:=CreateWindow ('Button', 'Calcola',
    WS_VISIBLE or WS_CHILD or  BS_PUSHLIKE ,
    10, 80, 50, 30, hWindow, 0, hInstance, nil);
  edit1:=CreateWindow ('Edit', '',
    WS_VISIBLE or WS_CHILD or  BS_PUSHLIKE or ES_NUMBER ,
    10, 50, 55, 16, hWindow, 0, hInstance, nil);
  edit2:=CreateWindow ('Edit', '',
    WS_VISIBLE or WS_CHILD or  BS_PUSHLIKE or ES_NUMBER ,
    80, 50, 55, 16, hWindow, 0, hInstance, nil);
  if longint(hWindow) = 0 then begin
    MessageBox(0, 'WinCreate failed', nil, mb_Ok);
    Exit;
  end;

  while GetMessage(@AMessage, 0, 0, 0) do begin
    TranslateMessage(AMessage);
    DispatchMessage(AMessage);
  end;
  Halt(AMessage.wParam);
end.


Ma non so come prendere il valore di edit

PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo