贴一段我给动态生成的菜单响应单击事件的代码,希望对你有帮助:<br>声明并定义: <br>procedure MenuItemClick(Sender: TObject);<br>procedure Txtsz.MenuItemClick(Sender: TObject);<br>begin<br> ADOQTFreeEMail.First;<br> ADOQTFreeEMail.MoveBy((Sender as TMenuItem).tag);<br> ShellExecute(Handle, 'open', PChar(ADOQTFreeEMail.FieldByName('URL').AsString), nil, nil, SW_SHOW);<br>end;<br>//生成:<br> ADOQTFreeEMail.Open;<br> SetConfig;<br><br> if ADOQTFreeEMail.RecordCount> 0 then<br> begin<br> PopupMenu1.Items.Clear;<br> for i:=0 to ADOQTFreeEMail.RecordCount-1 do<br> begin<br> Item:=TMenuItem.Create(NIL);<br> Item.Caption:=ADOQTFreeEMail.FieldByName('ServerName').AsString;<br> Item.OnClick:=MenuItemClick;//主要是一这句<br> Item.Tag:=i;<br> PopupMenu1.Items.Add(Item);<br> ADOQTFreeEMail.Next;<br> end;<br> end;