关于创建Window的一个小问题(Win32API高手请进) (50分)

  • 主题发起人 笑傲江湖1976
  • 开始时间

笑傲江湖1976

Unregistered / Unconfirmed
GUEST, unregistred user!
{下面的代码生成了一个Window窗口,选自Hubdog的宝典.有个问题,我现在设置dwStyle
为WS_DLGFRAME,应该生成一个没有Title的窗口,但是这段代码生成的窗口还有Title,
不知道是为什么?
}

program MyApp;

uses Windows, Messages;

// 回调函数
function AppWindowProc(
hWnd:HWND; uMsg:UINT;
wParam:WPARAM; lParam:LPARAM):LRESULT; stdcall;
begin
Result := 0;
case uMsg of
WM_DESTROY:begin
PostQuitMessage(0);
Exit;
end;
end;
Result :=
DefWindowProc(hWnd, uMsg, wParam, lParam);
end;

var
wc: TWndClass;
hWnd: Integer;
MSG: TMsg;
begin
// 程序从这里开始执行
wc.style := CS_VREDRAW or CS_HREDRAW;
wc.lpfnWndProc := @AppWindowProc;
wc.cbClsExtra := 0;

wc.cbWndExtra := 0;
wc.hInstance := HInstance;
wc.hIcon := LoadIcon(0, IDI_APPLICATION);
wc.hCursor := LoadCursor(0, IDC_ARROW);
wc.hbrBackground := (COLOR_BTNFACE+1);
wc.lpszMenuName := nil;
wc.lpszClassName := 'My App';
if RegisterClass(wc)=0 then Exit;
hWnd := CreateWindow(
wc.lpszClassName, 'TEST',
WS_DLGFRAME,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, HInstance, nil);
if hWnd=0 then Exit;
ShowWindow(hWnd, SW_SHOWDefault);
while GetMessage(MSG, 0, 0, 0) do begin
TranslateMessage(MSG);
DispatchMessage(MSG);
end;
Halt(MSG.wParam);
end.
 
再加上一个WS_POPUP
 
hWnd := CreateWindow(
wc.lpszClassName, '[red]TEST[/red]',//改为 [blue]nil[/blue]试试
WS_DLGFRAME,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, HInstance, nil);
 
接受答案了.
 
顶部