Oppure

Loading
28/03/10 11:38
Tullio
: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 28/03/10 12:15
aaa
28/03/10 11:46
djleo
spiegati meglio???
aaa
28/03/10 12:27
Tullio
inserirlo in una finestra vuota!! sai quelle quelle bianche?!!
aaa
28/03/10 13:01
djleo
prova con questa istruzione

textcolor(0)
textbackground(15)


Ultima modifica effettuata da djleo 28/03/10 13:02
aaa
28/03/10 13:15
Ocentral
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
aaa
28/03/10 13:26
djleo
scusa ma come inserisco il numero
aaa
28/03/10 13:51
Ocentral
si potrebbe usare wm_char

nella parte dei possibili valori di amssage
aaa
28/03/10 14:02
Ocentral
o anche WM_KEYDOWN
aaa