可不可在"控制台应用程序"下创建一个form(10分)

  • 主题发起人 主题发起人 glantvoo
  • 开始时间 开始时间
G

glantvoo

Unregistered / Unconfirmed
GUEST, unregistred user!
1.可不可发在"控制台应用程序"下创建一个form如果可的话要如何实现?
怎样把它显示出来,动态创建窗体的方法是怎样的,怎样初始化它?

2.在implementation 之上或之下都可以使用VAR 和TYPE是吗? 有什么区别呀!简直是被
搞糊涂了.

3.请问哪里有Windows API 函数的电子图书下载?

谢谢大家的指教,刚刚开始学Delphi,问题一大堆,拜托大家帮助,不甚感激!!!
 
program Modal;

uses
Windows, Messages;

var
Hwnd: Thandle; {主窗口句柄}

{$R *.RES}

{处理消息}
function WndProc(hWnd:Thandle;Msg:Integer;wParam:WPARAM;
lParam:LPARAM):HRESULT;stdcall;
begin
Result:=HRESULT(0); {清除警告信息}
case Msg of
WM_CLOSE: Begin
PostMessage(hWnd,WM_QUIT,wParam,lParam); Exit; end;
end;

Result:= DefWindowProc(Hwnd,Msg,wParam,lParam);
end;

function InitApplication:Boolean;
var
WndCls: TWndClass; {窗口类声明}
begin
wndcls.style := CS_DBLCLKS;
wndcls.lpfnWndProc := @WndProc;
wndcls.cbClsExtra := 0;
wndcls.cbWndExtra := 0;
wndcls.hInstance := hInstance;
wndcls.hIcon := 0;
wndcls.hCursor := LoadCursor(hInstance, 'IDC_ARROW');
wndcls.hbrBackground := COLOR_BACKGROUND;
wndcls.lpszMenuName := nil;
wndcls.lpszClassName := 'WCTemplate';
if RegisterClass(wndcls) = 0 then begin
Result:=False;
Exit;
end;
Result:=True;
end;

function InitInstance(Title: String = 'Win32Modal'):Boolean;
begin
hWnd := CreateWindow(
'WCTemplate',PChar(Title),
WS_OverLappedWindow,
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
0,0,hInstance,nil);
if hWnd = 0 then begin
Result:=False;
Exit;
end;
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
Result:=True;
end;

{程序入口}
function WinMain(hInst:HINST;hPrevInst:HINST;lpCmdLine:PChar;
nCmdShow:Integer):Integer;stdcall;
var
msg: TMsg;
begin
if not InitApplication then begin
Result:=0;
Exit;
end;
if not InitInstance then begin
Result:=0;
Exit;
end;

While GetMessage(msg,Hwnd,0,0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;

Result:=Msg.wParam;
end;

begin
WinMain(hInstance,0,pChar(''),0);
end.

2、之上是全局的对象或变量,之下是局部的对象或变量
3、www.playicq.com,www.51delphi.com

 
多人接受答案了。
 
后退
顶部