一个application含有多个显示在任务兰的form的问题
来源:互联网 发布:javascript权威指南 7 编辑:程序博客网 时间:2024/06/04 18:33
Blbo字段存取
VAR
filename:string;
//这里是从系统中取得一个临时文件
function gettemporyfilename:string;
const max_path=144;
var
lppathbuffer:pchar;
lpbuffer:pchar;
begin
getmem(lpbuffer,max_path);
getmem(lppathbuffer,max_path);
gettemppath(max_path,lppathbuffer);
gettempfilename(lppathbuffer,'tem',0,lpbuffer);
freemem(lppathbuffer,max_path);
gettempfilename(gettempdrive('c'),'tem',0,lpbuffer);
result:=strpas(lpbuffer);
freemem(lpbuffer,max_path);
end;
//将一个AVI文件写到blob字段中去
procedure tform1,button1click(sender:tobject);
var
filestream:tfilesteam;//to load the avi file
blobstream:tblobstream;//to save to the bolb
begin
application.processmessages;
button1.enabled:=false;
button2.enabled:=false;
filestream:tfilestream.create('ppath',fmopenread);//ppath是这个avi的路径
table1.edit;
//为table1avi字段创建一个blobstream
blobstream:=tblobstream.create(table1avi,bmreadwrite);
//移动到stream的首位
blobstream.seek(0,sofrombeginning);
//清空流数据
blobstream.truncate;
//将filestream的内容拷贝到blobstream
blobstream.copyfrom(filestream,filestream.size);
//释放流
filestream.free;
blobstream.free;
//添加记录
table1.post;
//使buttons可用
button1.enabled:=true;
button2.enabled:=true;
end;
procedure tform1.button2click(sender:tobject);
var
filestream:tfilestream;//a temp file
bolobstream:tblobstream;//the AVI blob
begin
//为AVI字段创建BLOB数据流
bolobstream:=tblobstream.create(table1avi,bmread);
if blobstream.size=0 then
begin
blobstream.free;
exit;
end;
//关闭media player
mediaplayer1.close;
//重值文件名
mediaplayer1.filename:='';
//刷新显示窗口
mediaplayer1.display:=panel1;
panel1.refresh;
//创建前删除同名的临时文件
if filename<>'' then
deletefile(filename);
//设置临时文件名
filename:=gettemporaryfilename;
//为临时文件创建文件流
filestream:=tfilestream.create(filename,fmcreate or fmopenwrite);
//拷贝blob到临时文件中
filestream.copyfrom(blobstream,blobstream.size);
//释放流
filestream.free;
blobstream.free;
//设置media player播放AVI文件
mediaplayer1.filename:=filename;
mediaplayer1.devicetype:=dtavivideo;
mediaplayer1.open;
mediaplayer1.play;
end;
procedure tform1.formdestroy(sender:tobject);
begin
//取消临时文件和media player的关联
mediaplayer1.close;
mediaplayer1.filename:='';
//删除临时文件
if filename<>'' then
deletefile(filename);
end;
多任务栏
procedure TCustomForm.WMSysCommand(var Message: TWMSysCommand);
begin
with Message do
begin
if (CmdType and $FFF0 = SC_MINIMIZE) and (Application.MainForm = Self) then
Application.WndProc(TMessage(Message))
else if (CmdType and $FFF0 <> SC_MOVE) or (csDesigning in ComponentState) or
(Align = alNone) or (WindowState = wsMinimized) then
inherited;
if ((CmdType and $FFF0 = SC_MINIMIZE) or (CmdType and $FFF0 = SC_RESTORE)) and
not (csDesigning in ComponentState) and (Align <> alNone) then
RequestAlign;
end;
end;
可以得知,MainForm的一些事件被传给了应用程序对象Application,我们要做的就是截取这
些消息,干我们自己想干的.
1.在主窗体unit中
声明
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
procedure CreateParams(var Params:TCreateParams); override;
实现
procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
begin
case message.CmdType of
SC_MAXIMIZE,SC_MINIMIZE,SC_RESTORE: //这几个消息自己处理
DefWindowProc(Self.Handle,message.Msg,message.CmdType,0)
else
inherited; //交给DELPHI
end;
end;
procedure TForm1.CreateParams(var Params:TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW ;//让主窗体出现在任务栏上
end;
好了,这样主窗体就会出现在任务栏上,而且最小化也不会消失,现在要做的就是
让Application在任务栏上的按钮消失,用以下代码
procedure TForm1.FormShow(Sender: TObject);
begin
showwindow(Application.Handle ,sw_hide);
end;
其它的窗体想出现在任务栏,只要像主窗体一样重载CreateParams方法,并用相同的代码,
这样就实现了一个应用程序有多个任务栏按钮,而且不会相互影响.
- 一个application含有多个显示在任务兰的form的问题
- 如何让一个Form显示在另外一个Form上的一个控件上
- 一个form多个submit的处理
- 一个application的问题
- 在一个panel中显示新的form
- 【面试题】在一个含有n个元素的集合中随机取一个数
- MessageBox(...), 只能让它显示在屏幕的中央, 能不能显示在一个Form的中央???
- 关于在一个form表单里同时上传多个文件和文本信息的解决方案。。。
- 多个form表单之间的数据在一个方法中实现,利用入口思想
- 一个页面上显示ViewPager的多个item问题
- 创建一个居右只显示在任务区的窗体
- 在Form中使用临时表时的一个问题
- 一个含有STL的struct问题
- struts2 一个form,多个submit 问题
- 查找在一个字符串中含有多少个相同的子字符串
- 在类文件cls中定义一个含有3个参数的命令 (LaTeX)
- 解决含有 TabbarVC的 UIViewController 在 NavigationViewController显示时变换的问题
- 关于在Form表单中出现多个Button但是Button失效的问题
- J2EE
- J2EE(2)
- ASP.NET与JavaScript联合操作之一 选择DataGrid中的CheckBox控件后该行背景变色
- 05_0824_编写String的问题(C++)
- 审计算法
- 一个application含有多个显示在任务兰的form的问题
- 知名专家学者云集上海,C++社区历史性盛会
- 软件设计方案
- 在线跪求解答
- Tomcat中JDBCRealm的配置
- www
- log4j 学习系列
- 35岁前成功的12条黄金法则
- log4j的第一步使用