(* Simple encrypt/decrypt example to show: creating windows Code By: Gordy Cowie else-if msg ladder STHxGoRDy@Juno.com getmessage loop custom window classes... ALL without big 'ol FORMS.PAS! questions or comments can be e-mailed to STHxGoRDy@Juno.com *note the incredibly smaller size of the executable file *) program window; uses windows,messages; var wclass:twndclass; inst,handle,hencrypt,hdecrypt,hedit,hpw:hwnd; msg:tmsg; (*------------------------------------------------*) procedure resize;stdcall; //called when window recieves a WM_SIZE var rct:trect; begin getwindowrect(handle,rct); movewindow(hedit,5,34,rct.right-rct.left-20,rct.bottom-rct.top-66,true); end; (*------------------------------------------------*) { no promises on a bug-free encrypt/decrypt system.. its just for example } procedure decrypt;stdcall; //basic simple decryption code var x,i,len,lpw:integer; instr,pw:pchar; begin len:=getwindowtextlength(hedit)+1; lpw:=getwindowtextlength(hpw)+1; getmem(instr,len); getmem(pw,lpw); getwindowtext(hedit,instr,len); getwindowtext(hpw,pw,lpw); x:=0; for i:=0 to len-2 do begin instr[i]:=chr(ord(instr[i]) - ord(pw[x])); inc(x); if x=(lpw-1)then x:=0; end; setwindowtext(hedit,pchar(instr)); freemem(instr,len); freemem(pw,lpw); end; (*------------------------------------------------*) procedure encrypt;stdcall; //basic simple encryption code var x,i,len,lpw:integer; instr,pw:pchar; begin len:=getwindowtextlength(hedit)+1; lpw:=getwindowtextlength(hpw)+1; getmem(instr,len); getmem(pw,lpw); getwindowtext(hedit,instr,len); getwindowtext(hpw,pw,lpw); x:=0; for i:=0 to len-2 do begin instr[i]:=chr(ord(instr[i]) + ord(pw[x])); inc(x); if x=(lpw-1)then x:=0; end; setwindowtext(hedit,pchar(instr)); freemem(instr,len); freemem(pw,lpw); end; (*------------------------------------------------*) function windowproc(hwn,msg,wpr,lpr:longint):longint;stdcall; //our custom windowproc begin result:=defwindowproc(hwn,msg,wpr,lpr); //pass msg to default windows procedure (i.e. drawing frames etc) if msg=wm_size then resize //else-if ladder to decipher messages else if msg=wm_command then begin //catch button clicks if lpr=hencrypt then encrypt else if lpr=hdecrypt then decrypt; end else if msg=wm_destroy then halt; //prevents a total system shit-fuck on termination end; (*-------------** Main Program Code **----------------*) begin inst:=getmodulehandle(nil); //get application instance with wclass do //create class properties begin style:=CS_CLASSDC or CS_PARENTDC; lpfnwndproc:=@windowproc; //this is where our custom window proc goes hinstance:=inst; hbrbackground:=color_btnface+1; lpszclassname:='GoRDy ¦o)'; //aaaannyyything you want it to be hcursor:=loadcursor(0,IDC_ARROW); end; registerclass(wclass); //this class is automatically unregistered on term. //create our main window handle:=createwindowex( {WS_EX_TOPMOST or WS_EX_CLIENTEDGE} 0, //try some of the EX styles (very useful) 'GoRDy ¦o)', //registered class 'Encrypter', WS_VISIBLE or WS_SIZEBOX or WS_CAPTION or WS_SYSMENU, 10,10,400,300,0,0,inst,nil); //measurements & parent hencrypt:=createwindow( 'Button', 'Encrypt', //using WS_VISIBLE is more efficient then calling showwindow.. duh WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT, 5,5,65,24,handle,0,inst,nil); //make sure to include WS_CHILD or it will appear in a seperate window hdecrypt:=createwindow( 'Button', 'Decrypt', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT, 75,5,65,24,handle,0,inst,nil); hedit:=createwindowex( WS_EX_CLIENTEDGE, //this style WAAY more efficient then using CTL3D.DLL! 'Edit', '', WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or ES_WANTRETURN or ES_AUTOVSCROLL or WS_VSCROLL, 5,34,380,234,handle,0,inst,nil); createwindow( 'Static', 'Password:', WS_VISIBLE or WS_CHILD or SS_LEFT, 150,8,70,20,handle,0,inst,nil); hpw:=createwindowex( WS_EX_CLIENTEDGE, 'Edit', 'Password', WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL, 230,5,90,24,handle,0,inst,nil); updatewindow(handle); {draws all the windows at once avoiding that build-up look} //getmessage loop--prevents the application from pre-termination while(getmessage(msg,handle,0,0))do begin translatemessage(msg); dispatchmessage(msg); end; end.