
02.10.2009, 19:39
|
Новичок
|
|
Регистрация: 01.06.2009
Сообщения: 80
Репутация: 10
|
|
Код:
program Project1;
uses
Windows,
Messages;
{$R com_ctrl.res}
const
WndClass = 'TWinWnd';
WndCaption = '';
ProgBrID = 1;
PBS_MARQUEE = $08;
PBM_SETMARQUEE = WM_USER+10;
var
Wc: TWndClassEx;
Wnd: HWND;
Msg: TMsg;
ProgBr: hwnd;
function WindowProc( Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM ): LRESULT; stdcall;
begin
case Msg of
WM_DESTROY: begin
PostQuitMessage( 0 );
Result := 0;
Exit;
end;
else
Result := DefWindowProc( Wnd, Msg, wParam, lParam );
end;
end;
begin
with Wc do
begin
cbSize := SizeOf( Wc );
style := CS_HREDRAW or CS_VREDRAW;
lpfnWndProc := @WindowProc;
cbClsExtra := 0;
cbWndExtra := 0;
hInstance := hInstance;
hIcon := LoadIcon( 0, IDI_APPLICATION );
hCursor := LoadCursor( 0, IDC_ARROW );
hbrBackground := COLOR_WINDOW;
lpszMenuName := nil;
lpszClassName := WndClass;
end;
RegisterClassEx( Wc );
Wnd := CreateWindowEx(0, WndClass, WndCaption, WS_OVERLAPPED or WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX,
10, 10, 300, 130, 0, 0, hInstance, nil );
ProgBr := CreateWindowEx( 0, 'msctls_progress32', '', WS_POPUP or WS_VISIBLE, 20, 40, 100, 20, wnd, 0, hinstance, nil );
SetWindowLong (ProgBr, GWL_STYLE, (GetWindowLong (ProgBr, GWL_STYLE) or PBS_MARQUEE));
SendMessage(ProgBr,PBM_SETMARQUEE, 1, 10);
ShowWindow( Wnd, SW_SHOWNORMAL );
while GetMessage( Msg, 0, 0, 0 ) do
begin
TranslateMessage( Msg );
DispatchMessage( Msg );
end;
Halt( Msg.wParam );
end.
И еще один нюанс. Как сделать так, чтобы окно прогресс бара принадлежало главному? А то получается так что окно можно таскать, а прогресс не лежит на нем и стоит на месте.
|