📄 bcjq091.txt
字号:
C++ Builder开发者:程序员之家
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
首页
| 控件天堂 | 控件使用
| 编程技巧
| 源代码 | 编程工具 |
系统补丁 | 电子书籍 | 技术论坛
| 相关链接
if (ad==1) {document.write(''+'');}
if (ad==2) {document.write(''+'');}
if (ad==3) {document.write(''+'');}
var marqueecontents=''+scroll_text+''
if (document.all)
document.write(''+marqueecontents+'')
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
setTimeout("window.onresize=regenerate",450)
intializemarquee()
}
}
function intializemarquee(){
document.cmarquee01.document.cmarquee02.document.write(marqueecontents)
document.cmarquee01.document.cmarquee02.document.close()
thelength=document.cmarquee01.document.cmarquee02.document.height
scrollit()
}
function scrollit(){
if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){
document.cmarquee01.document.cmarquee02.top-=speed
setTimeout("scrollit()",100)
}
else{
document.cmarquee01.document.cmarquee02.top=marqueeheight
scrollit()
}
}
window.onload=regenerate2
当前位置
:
编程技巧
如何在c++ builder中调用windows应用程序
一般,windows程序员在编写windows程序时,为了降低编程的难度和缩短编程的时间,经常会调用各种windows资源,如画笔,写字板等资源。对于其他的程序设计语言,我们一般使用
api函数来实现着一功能,那么在borland c++ builder
上我们又如何实现呢?最近笔者在编写电子屏显示软件时,用api函数实现了该功能。
现以使用api函数调用windows画笔为列,把该方法介绍如下:
1、启动 c++ builder 进入菜单file|new application创建一个新项目,将该项目存盘,得到含有一个主窗口的项目。在主窗口上添加一个打开图片对话框控件OpenPictureDialog1和按扭控件Button1。
2、在主文件的文件头添加#include <ShellApi.h>
3、在头文件的private 处添加 char BmpExec[100];
4、在Button1的OndbClick事件处添加如下代码:
void __fastcall TMainForm1::Button1Click(TObject *Sender)
{
AnsiString TempName;
FileClose(FileCreate("testest.bmp"));
FindExecutable("testest.bmp",NULL,BmpExec);//返回可执行文件名的句柄//
DeleteFile("testest.bmp");//删除文件//
OpenPictureDialog1->DefaultExt = String("BMP");
OpenPictureDialog1->Filter ="图片文件(*.bmp)|*.bmp";
OpenPictureDialog1->FileName="*.bmp";
if (OpenPictureDialog1->Execute())
{
if (OpenPictureDialog1->FileName.AnsiPos(".")<1)
OpenPictureDialog1->FileName=OpenPictureDialog1->FileName+".BMP";
//给没有扩展名的文件加上扩展名,此时FileName为文名的全名//
CloseHandle(CreateFile(OpenPictureDialog1->FileName.c_str(),//参数1
为文件名//
GENERIC_WRITE, //参数2
文件的访问模式:设置为文件可写并且文件指针//
FILE_SHARE_WRITE, //参数3
文件的共享模式:如果写访问允许文件可被修改//
NULL, //参数4 安全属性:
用缺省的操作符//
OPEN_ALWAYS, //参数5
如果文件不存在,如何创造文件:设置为存在则打开,如不存在则新建//
FILE_ATTRIBUTE_NORMAL, //参数6,文件的属性和标志,文件没有其他的属性//
));//关闭打开的事物句柄//
//以上的代码使文件设置为共享,从而使下面的代码顺利执行//
TempName=AnsiString(BmpExec); //把char 转换成AnsiString//
TempName=TempName+" "+OpenPictureDialog1->FileName;//应用程序名+相应的被处理文件//
WinExec(TempName.c_str(),SW_SHOWNORMAL);//执行应用程序//
}
}
5、编译执行。当双激按扭Button1时,程序出现打开图片文件的对话框,选则要打开的bmp文件,便可以调用windows的画笔打开自己选定的bmp文件了。
在每一条语句的后面,笔者都加了注释,有兴趣的朋友可以一试。
if (ad==1) {document.write(''+'');}
if (ad==2) {document.write(''+'');}
if (ad==3) {document.write(''+'');}
C++ Builder开发者®
2000年06月01日 站长:唐朝