如何在MDI的主窗口中建立类似于windows桌面的图形界面,(50分)

L

linin

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在使用MDI的同时,在MDI的主窗口中使用类似于windows桌面的图形界面,也就是
使用多个Image,使单击不同Image激发不同事件。
但在MDI的主窗口中,只能看见背景色,插入的图象不可见。我用wzs的方法:
在Form中添加Image控件 ,设BMP图象 ,name为 IMG_BK ,在Form的Create事件中写入
Self.brush.bitmap:=img_bk.picture.bitmap;
出现的问题是它要求定义 img_bk 的数据类型(我不知道是什么类型啊,那个不是文
件名吗?),并且,这种方法似乎不支持多个Image。
有没有办法实现呢?
对不起,小妹是只菜鸟,可否请各位大虾答的详细些;刚刚光临此地,分数也不多,
各位多多担待了。
 

陈建辉

Unregistered / Unconfirmed
GUEST, unregistred user!
L

linin

Unregistered / Unconfirmed
GUEST, unregistred user!
OK,我现在清楚img_bk 是Image的名字,而这一句程序将Image的图片平铺整个MDI主
窗口。
不能将图片只在特定的位置显示吗?
 
S

sonie

Unregistered / Unconfirmed
GUEST, unregistred user!
mdi背景中要放多个图片,等一下去试了再来作答.
 
R

redhat2000

Unregistered / Unconfirmed
GUEST, unregistred user!
Here are the necessary steps to add wallpaper to a MDI parent
form:

Create a new project
Set the form's FormStyle to fsMDIForm
Drop an image on the form and select a bitmap into it.
Find the { Private Declarations } comment in the form's
definition and add these lines right after it:
FClientInstance : TFarProc;
FPrevClientProc : TFarProc;
procedure ClientWndProc(var Message: TMessage);
Find the "implementation" line and the {$R *.DFM} line that
follows it. After that line, enter this code:
procedure TMainForm.ClientWndProc(var Message: TMessage);
var
Dc : hDC;
Row : Integer;
Col : Integer;
begin
with Messagedo
case Msg of
WM_ERASEBKGND:
begin
Dc := TWMEraseBkGnd(Message).Dc;
for Row := 0 to ClientHeight div Image1.Picture.Heightdo
for Col := 0 to ClientWidth div Image1.Picture.Widthdo
BitBlt(Dc,
Col * Image1.Picture.Width,
Row * Image1.Picture.Height,
Image1.Picture.Width,
Image1.Picture.Height,
Image1.Picture.Bitmap.Canvas.Handle,
0,
0,
SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc,
ClientHandle,
Msg,
wParam,
lParam);
end;
end;

In the OnCreate method for the form, type the following lines
of code:
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(ClientHandle,
GWL_WNDPROC));
SetWindowLong(ClientHandle,
GWL_WNDPROC, LongInt(FClientInstance));
Add a new form to your project and set its FormStyle property to
fsMDIChild.
Now you have a working MDI project with "wallpaper" where the image
bitmap is tiled to cover the MDI form's client area.
enjoy it, linin :)
 
R

redhat2000

Unregistered / Unconfirmed
GUEST, unregistred user!
if you want to add different image to background of Main form, and want to
generate different event according to each image, you can use my code above to
seperate them by ClientWidth and ClientHieght, then
write Tform.Onmousedown event
to ensure which picture is being clicked by mouse position.
for Row := 0 to ClientHeight div Image1.Picture.Heightdo
for Col := 0 to ClientWidth div Image1.Picture.Widthdo
BitBlt(Dc,
Col * Image1.Picture.Width,
Row * Image1.Picture.Height,
Image1.Picture.Width,
Image1.Picture.Height,
Image1.Picture.Bitmap.Canvas.Handle,
0,
0,
SRCCOPY);
Result := 1;

:)
 
C

chinaplate

Unregistered / Unconfirmed
GUEST, unregistred user!
mdi主窗体上加图片好加,正如上面的朋友们所述
但你想在上面加上可以触发事件的图标,可就麻烦点儿了.
建议你还是,做一个mdi子窗口,(姑且叫它为控制台),然后将各功能的操作放在它上面吧.
国强,金蝶,管家婆等软件都是这样的.
对了,你可以借鉴一下安易财务系统的桌面,很不错的.
 
L

linin

Unregistered / Unconfirmed
GUEST, unregistred user!
我用了个苯方法,在coolbar上放image,并将coolbar放在form左边,右边位子窗
口区……反正还是图形界面 :P
多谢各位了!
 
L

linin

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 

Similar threads

D
回复
0
查看
780
DelphiTeacher的专栏
D
D
回复
0
查看
809
DelphiTeacher的专栏
D
D
回复
0
查看
857
DelphiTeacher的专栏
D
顶部