三、mdi-child在dll中载入并使用
如果是mdi-child又如何在dll中载入并使用呢,下面就这个问题说说使用dll文件中封装的窗口。
新建一个dll工程,保存为mdidll,再新建一个窗体,formstyle设为fsmdichild,如下:
object form1: tform1
left = 192
top = 133
width = 344
height = 234
caption = 'mdi'
color = clbtnface
font.charset = default_charset
font.color = clwindowtext
font.height = -11
font.name = 'ms sans serif'
font.style = []
formstyle = fsmdichild
oldcreateorder = false
position = podefault
visible = true
onclose = formclose
pixelsperinch = 96
textheight = 13
end
代码如下:
|
unit mdi_unit; interface uses type var {$r *.dfm} procedure tform1.formclose(sender: tobject; var action: tcloseaction); end. |
|
library mdidll; uses procedure loadchild(parentapplication: tapplication; parentform: tform); export; stdcall; begin procedure dllunloadproc(reason: integer); register; {$r *.res} |
编译后生成mdidll.dll文件。
使用dll中的mdi-child窗口如下:
新建一个工程,主窗口设置如下formstyle设为fsmdiform:
object form1: tform1
left = 192
top = 133
width = 544
height = 375
caption = 'form1'
color = clbtnface
font.charset = default_charset
font.color = clwindowtext
font.height = -11
font.name = 'ms sans serif'
font.style = []
formstyle = fsmdiform
menu = mainmenu1
oldcreateorder = false
pixelsperinch = 96
textheight = 13
object mainmenu1: tmainmenu
left = 72
top = 136
object n1: tmenuitem
caption = #26032#24314'(&n)'
onclick = n1click
end
end
end
代码:
|
unit usemdi_unit; interface uses type implementation {$r *.dfm} procedure tform1.n1click(sender: tobject); end. |