Форум: "WinAPI";
Текущий архив: 2002.01.08;
Скачать: [xml.tar.bz2];
ВнизКак создавать формы с разными контролами на чистом API? Найти похожие ветки
← →
Jochua (2001-10-25 08:03) [6]Вот посмотри, я как то делал пример по такой же просьбе:
program listbox;
uses
windows, messages;
var
wc : TWndClassEx;
Wnd : HWND;
Msg : TMsg;
function WindowProc(wnd : HWND; Msg : Integer; WParam : WParam; LParam : Longint): Longint; stdcall;
const
BUFFER = MAX_PATH;
var
I : Integer;
CurDir : array[0..BUFFER-1] of Char;
Begin
Result := 0;
case msg of
wm_destroy :
Begin
postquitmessage(0);
exit;
Result:=0;
End;
wm_command :
Begin
case loword(wParam) of
200 :
case hiWord(wParam) of
lbn_selchange :
begin
I := SendMessage(lParam, LB_GETCURSEL, 0, 0);
SendMessage(lParam, LB_GETTEXT, I, Integer(@CurDir));
SetWindowText(GetDlgItem(Wnd, 222), CurDir);
end;
lbn_dblclk :
begin
I := SendMessage(lParam, LB_GETCURSEL, 0, 0);
SendMessage(lParam, LB_GETTEXT, I, Integer(@CurDir));
SetWindowText(GetDlgItem(Wnd, 221), CurDir);
end;
end;
100 :
begin
GetCurrentDirectory(SizeOf(CurDir), CurDir);
DlgDirList(Wnd, CurDir, 200, 0, DDL_DIRECTORY);
end;
end;
End;
else
Result := DefWindowProc(wnd, msg, wparam, lparam);
end;
End;
begin
wc.cbSize := sizeof(wc);
wc.style := cs_hredraw or cs_vredraw;
wc.lpfnWndProc := @WindowProc;
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 := "listbox example";
RegisterClassEx(wc);
Wnd := CreateWindowEx(0, "listbox example", "ListBoxes Demo",
ws_overlapped or ws_sysmenu,
100, 150, 360, 200,
0, 0,
Hinstance, nil);
CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", NIL, WS_BORDER or LBS_NOTIFY or WS_CHILD or WS_VISIBLE or LBS_MULTICOLUMN or LBS_SORT or LBS_EXTENDEDSEL, 10, 70, 200, 100, Wnd, 200, hInstance, NIL);
CreateWindowEx(0, "STATIC", "dbl_click:", WS_VISIBLE or WS_CHILD, 10, 10, 60, 20, Wnd, 0, hInstance, NIL);
CreateWindowEx(0, "STATIC", NIL, WS_VISIBLE or WS_CHILD, 75, 10, 300, 20, Wnd, 221, hInstance, NIL);
CreateWindowEx(0, "STATIC", "Select:", WS_VISIBLE or WS_CHILD, 10, 40, 60, 20, Wnd, 0, hInstance, NIL);
CreateWindowEx(0, "STATIC", NIL, WS_VISIBLE or WS_CHILD, 75, 40, 300, 20, Wnd, 222, hInstance, NIL);
CreateWindowEx(0, "BUTTON", "Scan Directory", BS_PUSHBUTTON or WS_CHILD or WS_VISIBLE, 220, 130, 120, 25, Wnd, 100, hInstance, NIL);
ShowWindow(Wnd, CmdShow);
While GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.
Страницы: 1 вся ветка
Форум: "WinAPI";
Текущий архив: 2002.01.08;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.01 c