请问不用Form,如何建一个程序?
这个程序运行时也没有form,应该如何建立?  能否给个具体的例子?
谢谢!

解决方案 »

  1.   

    program project;useswindows,Messages;{$R *.RES}constappname='abc';varaMessage:tmsg;hwindow,button1,button2:hwnd;function WindowProc(window:hwnd;amessage,wparam,lparam:longint):longint;stdcall;export;beginwindowproc:=0;case amessage ofWM_DESTROY:begindestroywindow(button1);destroywindow(button2);PostQuitMessage(0);exit;end;wm_command:if lparam=button1 thenbeginMessageBox(hwindow,'fksd','kfdsl',MB_OK+MB_ICONINFORMATION);end;end;windowproc:=defwindowproc(window,aMessage,wParam,lParam);end;function WinRegister:boolean;varWindowClass:TWndClass;beginWindowClass.style:=cs_hredraw or cs_vredraw ;windowclass.lpfnWndProc:=@windowProc;windowClass.cbClsExtra:=0;windowClass.cbWndExtra:=0;windowclass.hInstance:=hinstance;windowclass.hIcon:=LoadIcon(0,IDI_APPLICATION);windowclass.hCursor:=LoadCursor(0,IDC_ARROW);windowclass.hbrBackground:=COLOR_BTNSHADOW;windowclass.lpszMenuName:=nil;windowclass.lpszClassName:=appname;result:=Registerclass(windowClass)<>0;end;function WinCreate:hwnd;varhWindow:hwnd;pchartemp:pchar;param:tagCREATESTRUCT;beginhwindow:=CreateWindowEx(WS_EX_RTLREADING or WS_EX_APPWINDOW,appname,'文件分解与合并演示程序',WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,hinstance,nil);if hwindow<>0 thenbeginparam.cx:=20;param.cy:=20;param.dwExStyle:=WS_CHILD+BS_PUSHBUTTON;param.hInstance:=hinstance;param.hMenu:=0;param.hwndParent:=hwindow;param.lpszClass:='button';param.x:=20;param.y:=20;pchartemp:='Kingron TEMP';button1:=createwindow('button','合并文件',param.dwExStyle,param.y,param.y,60,30,hwindow,0,hinstance,@param);param.x:=40;param.y:=60;button2:=createwindow('button','分解文件',param.dwExStyle,param.y,param.y,60,30,hwindow,0,hinstance,@param);showwindow(hwindow,cmdshow);showwindow(button2,cmdshow);showwindow(button1,cmdshow);updatewindow(hwindow);end;result:=hwindow;end;beginif not winregister thenbeginMessageBox(0,'窗口注册失败','错误',MB_OK+MB_ICONINFORMATION);exit;end;hwindow:=wincreate;while GetMessage(aMessage,0,0,0) dobeginTranslateMessage(amessage);DispatchMessage(aMessage);end;halt(amessage.wParam);end.
      

  2.   

    典型的控制台程序,就是没有窗体的程序!
    给你简单的:
    方法新建工程后,在工程中把Form1去掉;
    Project ->view source
    按下面的改就行了!program Project1;uses
      Forms;{$R *.res}begin
    //  Application.Initialize;
    //  Application.Run;
      Application.MessageBox('323','353');
    end.