紧急两个问题(100分)

  • 主题发起人 主题发起人 a_ping
  • 开始时间 开始时间
A

a_ping

Unregistered / Unconfirmed
GUEST, unregistred user!
1。我用MDI窗口,怎么象有些程序一样可以将打开的窗口显示到menu中,点击它可置最前。
2。我用ADO连数据库,我想写个Dll文件,怎么写呢?
感谢!!!
 
Pre:
for i:=1 to MainForm.ChildFormCount do
begin
Menu.Item.Caption := MainForm.CHildForm[ChildFormCount].Caption;
MainMenu.AddItem(Menu);
end
 
1。設置MIDFROM的WindowMenu為你要在其上顯示的菜單項(如window這項菜單)。
這裡說了一點,不是很詳細http://www.delphibbs.com/delphibbs/dispq.asp?lid=2140149
 
1.
procedure TForm1.AddButtonClick(Sender: TObject);
var
index: Integer;
NewItem: TMenuItem;
begin
for index := 0 to 3 do
begin
NewItem := TMenuItem.Create(PopupMenu1); // create the new item
PopupMenu1.Items.Add(NewItem);// add it to the Popupmenu
NewItem.Caption := 'Menu Item ' + IntToStr(index);
NewItem.Tag := index;
NewItem.OnClick = PopupMenuItemsClick;// assign it an event handler
end;

end;

procedure TForm1.PopupMenuItemsClick(Sender: TObject);
begin
with Sender as TMenuItem do
begin
case Tag of
0: ShowMessage('first item clicked');
1: ShowMessage('second item clicked');
2: ShowMessage('third item clicked');
3: ShowMessage('fourth item clicked');
end;
end;
end;

To edit or destroy an item, grab its pointer via the Items property.

procedure TForm1.EditButtonClick(Sender: TObject);
var
ItemToEdit: TMenuItem;
begin
ItemToEdit := PopupMenu.Items[1];
ItemToEdit.Caption := 'Changed Caption';
}

procedure TForm1.DestroyButtonClick(Sender: TObject);
var
ItemToDelete: TMenuItem;
begin
ItemToDelete := PopupMenu.Items[2];
ItemToDelete.Free;
end;

你自己改一改吧,其实就是Delphi的帮助啦!
 
用ado做动态库,要注意初始化它,要在程序末加上
initialization
Coinitialize(nil);
finalization
CoUninitialize;
然后ado你就象平常一样用就差不多了
 
以下是子窗口的一段化代码
tformchild = Class(tform)
....
private
...
menus: tmenuitem;
procedure menusclick(sneder ; tobject);
public
...
end;

procedure TFormchild.formcreate(sender :Tobject);
begin
menus := Tmenuitem.create(formmidmenu); //formmid是父窗口中的一个菜单
menus.parent ;= formmidmenu;
menus.onclick ;= menusclick;
end;
proceudure Tformchild.menusclick(sender : Tobject);
begin
self.BringToFront ; end;
end.
 
多人接受答案了。
 
后退
顶部