Форум: "WinAPI";
Текущий архив: 2004.08.29;
Скачать: [xml.tar.bz2];
Внизнажатие на TMenuItem Найти похожие ветки
← →
Константин © (2004-07-14 08:29) [0]Здравствуйте уважаемые. У меня вопрос: я динамически создал MainMenu. Установил обработчик события onClick. Так вот когда юзер кликнет на каком-либо элементе типа TMenuItem мне нужно узнать его имя (не юзера :-)
var
year: array [2004..2100] of TMenuItem;
month: array [1..12] of TMenuItem;
day: array [1..31] of TMenuItem;
i, j, o: integer;
begin
if prov1 = false then
begin
for i := 2004 to 2100 do
begin
year[i] := TMenuItem.Create(Self);
year[i].Caption := IntToStr(i);
year[i].Name := "y" + IntToStr(i);
MainMenu1.Items[1].Add(year[i]);
year[i].OnClick := click_year;
for j := 1 to 12 do
begin
month[j] := TMenuItem.Create(Self);
month[j].Name := "m" + inttostr(j)+ "y" + inttostr(i);
case j of
1: month[j].Caption := "Январь";
2: month[j].Caption := "Февраль";
3: month[j].Caption := "Март";
4: month[j].Caption := "Апрель";
5: month[j].Caption := "Май";
6: month[j].Caption := "Июнь";
7: month[j].Caption := "Июль";
8: month[j].Caption := "Август";
9: month[j].Caption := "Сентябрь";
10: month[j].Caption := "Октябрь";
11: month[j].Caption := "Ноябрь";
12: month[j].Caption := "Декабрь";
end;
MainMenu1.Items[1].Items[i-2004].add(month[j]);
end;
Query1.Active := false;
Query1.SQL.Text := "SELECT *FROM chanel.db WHERE ODate BETWEEN " + """" + "01/01/" + inttostr(i) + """" + " AND " + """" + "12/31/" + inttostr(i) + """";
Query1.Active := true;
if Query1.RecordCount = 0 then year[i].Visible := false else year[i].visible := true;
end;
← →
Reindeer Moss Eater © (2004-07-14 09:13) [1]year[i] := TMenuItem.Create(Self);
year[i].Tag := 2004;
procedure TSomeForm.year_click(Sender : TObject);
begin
ShowMessage(IntToStr(TComponent(Sender).Tag));
end;
← →
Константин © (2004-07-14 09:17) [2]Спасибо. Все работает.
Страницы: 1 вся ветка
Форум: "WinAPI";
Текущий архив: 2004.08.29;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.033 c