《开发工具》实验指导书Word格式文档下载.docx
- 文档编号:5745223
- 上传时间:2023-05-05
- 格式:DOCX
- 页数:26
- 大小:1.54MB
《开发工具》实验指导书Word格式文档下载.docx
《《开发工具》实验指导书Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《《开发工具》实验指导书Word格式文档下载.docx(26页珍藏版)》请在冰点文库上搜索。
DialogBox(hInst,(LPCTSTR)IDD_ABOUTBOX,hWnd,(DLGPROC)About);
break;
caseIDM_EXIT:
DestroyWindow(hWnd);
default:
returnDefWindowProc(hWnd,message,wParam,lParam);
}
break;
caseWM_PAINT:
hdc=BeginPaint(hWnd,&
ps);
//TODO:
Addanydrawingcodehere...
RECTrt;
GetClientRect(hWnd,&
rt);
DrawText(hdc,szHello,strlen(szHello),&
rt,DT_CENTER);
EndPaint(hWnd,&
caseWM_DESTROY:
PostQuitMessage(0);
default:
returnDefWindowProc(hWnd,message,wParam,lParam);
}
return0;
}
2.基于VC++MFC的“hello”程序。
使用VC++6.0建立MFCAppwizard(exe)工程,选择对话框类型的代码框架,实现如下功能
(1)程序运行后出现的界面
图1.2.1基于VC++的“hello”程序运行结果
(2)用户点击“Button1”后的界面
图1.2.2基于VC++的“hello”程序运行结果
注意:
文本框与变量的对应;
文本框内数据的更新
附录:
关键代码
voidCVCMFCHELLODlg:
:
DoDataExchange(CDataExchange*pDX)
CDialog:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVCMFCHELLODlg)
DDX_Text(pDX,IDC_EDIT1,m_Edit1);
//}}AFX_DATA_MAP
BEGIN_MESSAGE_MAP(CVCMFCHELLODlg,CDialog)
//{{AFX_MSG_MAP(CVCMFCHELLODlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1,OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
OnButton1()
//TODO:
Addyourcontrolnotificationhandlercodehere
m_Edit1="
HELLO!
"
;
UpdateData(FALSE);
3.基于VB的“hello”程序。
利用VB6建立“标准EXE”工程,实现如下功能
图1.3.1基于VB的“hello”程序运行结果
图1.3.2基于VB的“hello”程序运行结果
PrivateSubCommand1_Click()
Text1.Text="
HELLO"
EndSub
3.基于DELPHI的“hello”程序。
利用DELPHI7建立标准工程,实现如下功能
(1)程序运行后出现的界面
图1.4.1基于DELPHI的“hello”程序运行结果
(2)用户点击“Button1”后的界面
图1.4.2基于DELPHI的“hello”程序运行结果
unitUnit1;
interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,
Dialogs,StdCtrls;
type
TForm1=class(TForm)
Edit1:
TEdit;
Button1:
TButton;
procedureButton1Click(Sender:
TObject);
private
{Privatedeclarations}
public
{Publicdeclarations}
end;
var
Form1:
TForm1;
implementation
{$R*.dfm}
procedureTForm1.Button1Click(Sender:
begin
Edit1.Text:
='
HELLO'
end;
end.
实验2:
图像处理编程技术
掌握DELPHI图形处理方面的基本编程技术
实现对BMP格式图像文件的百叶窗效果实现
1.准备BMP格式素材文件
2。
编程步骤参见本课教材《DELPHI开发技术大全》第323-324页
对实现百叶窗效果算法的理解;
Canvas对象的使用
图2.1百叶窗效果程序运行图
procedureTForm1.BitBtn1Click(Sender:
newbmp:
TBitmap;
i,j,bmpheight,bmpwidth:
integer;
xgroup,xcount:
=TBitmap.Create;
newbmp.Width:
=image1.Width;
newbmp.Height:
=image1.Height;
bmpheight:
bmpwidth:
xgroup:
=25;
xcount:
=bmpheightdivxgroup;
fori:
=0toxcountdo
forj:
=0toxgroupdo
begin
newbmp.Canvas.CopyRect(Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i),
image1.Canvas,Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i));
form1.Canvas.Draw(0,0,newbmp);
Application.ProcessMessages;
newbmp.Free;
实验3:
多媒体编程技术
掌握DELPHI音频视频处理方面的基本编程技术
视频播放器设计
1.准备.MPG格式素材文件
编程步骤参见本课教材《DELPHI开发技术大全》第362-363页
对MediaPlayer控件的使用
程序运行的顺序如图所示
图3.1视频播放器程序运行界面1
图3.2视频播放器程序运行界面2
图3.3视频播放器程序运行界面3
procedureTForm2.playerAVI(Intis:
Integer);
ifIntis=1then
ifform1.OpenDialog1.Executethen
withform2.MediaPlayer1do
Display:
=Panel1;
Filename:
=form1.OpenDialog1.FileName;
Open;
DisPlayrect:
=Rect(1,1,form2.Panel1.Width,form2.Panel1.Height);
Notify:
=true;
form1.SpeedButton2.Enabled:
=True;
form1.SpeedButton6.Enabled:
form1.SpeedButton7.Enabled:
form1.SpeedButton8.Enabled:
form1.SpeedButton9.Enabled:
if(Intis>
1)and(Intis<
9)then
ifIntis=2then
form2.MediaPlayer1.Play;
form1.SpeedButton4.Enabled:
form1.SpeedButton5.Enabled:
ifIntis=3then
form2.MediaPlayer1.Stop;
ifIntis=4then
form2.MediaPlayer1.Pause;
ifIntis=5then
form2.MediaPlayer1.Next;
ifIntis=6then
form2.MediaPlayer1.Previous;
ifIntis=7then
form2.MediaPlayer1.Step;
ifIntis=8then
form2.MediaPlayer1.Back;
实验4:
数据库开发技术—数据的浏览添加修改删除
掌握DELPHI的基于ADO的基本数据库操作技术
数据库记录的浏览添加修改删除
1.建立Access数据库country.mdb
2.编写前台应用程序
以上参见本课教材《DELPHI开发技术大全》第524页实例。
程序运行结果如图。
图4.1数据库数据编辑程序运行界面
利用各ADO控件建立数据链路。
procedureTForm1.FormCreate(Sender:
adoquery1.ConnectionString:
Provider=Microsoft.Jet.OLEDB.4.0;
DataSource=database\country.mdb;
PersistSecurityInfo=False'
withADOQuery1do
close;
SQL.Clear;
sql.Add('
selectnameas国家,capitalas首都,areaas面积,populationas人口fromcountrywherepopulation<
30000000'
);
open;
实验5:
数据库开发技术—数据报表
掌握DELPHI基于RAVE组件的数据报表技术
数据报表设计
1.建立Access数据库database.mdb
以上参见本课教材《DELPHI开发技术大全》第599页实例。
Rave组件的应用参见593-596页。
运行结果如图所示
注意:
数据视图选择“directDataView”方式
图5.1数据报表软件运行界面1
图5.2数据报表软件运行界面1
RvProject1.ProjectFile:
='
.\Project1.rav'
RvProject1.Execute;
实验6:
网络编程技术
掌握DELPHI基于UDP网络编程方面的基本技术
UDP局域网聊天软件设计
参见本课教材《DELPHI开发技术大全》第648-649页
软件运行的结果如图所示。
(本机作为聊天对象)
1.对ADODataSet的使用2.UDP控件属性的设置
3.数据的文件方式存取。
图6.1UDP局域网聊天软件运行界面1
图6.2UDP局域网聊天软件运行界面2
STR:
string;
ZHUName:
=GettoName;
IPName:
=NameTOIP(ZHUName);
ADODataSet2.Filtered:
ADODataSet2.Filter:
=format('
UserIP'
+'
'
%s'
[IPName]);
name:
=ADODataSet2.fieldbyname('
UserName'
).AsString;
IdUDPClient1.Host:
=IP;
ifLength(Memo2.Lines.GetText)>
0then
IdUDPClient1.Send(Memo2.Lines.GetText);
=IdUDPClient1.ReceiveString;
Memo1.Lines.Insert(0,Name+'
:
+STR);
Memo2.Clear;
Memo2.Lines.Clear;
Memo2.SetFocus;
procedureTForm1.IdUDPServer1UDPRead(Sender:
TObject;
AData:
TStream;
ABinding:
TIdSocketHandle);
Str,Names:
Stream:
TStringStream;
Stream:
=TStringStream.Create('
Stream.CopyFrom(AData,AData.Size);
Str:
=Stream.DataString;
ABinding.SendTo(ABinding.PeerIP,ABinding.PeerPort,Str[1],Length(Str));
ifGetName(ABinding.PeerIP,Names)then
Memo1.Lines.Insert(0,Names+'
+STR)//Memo1.Lines.Add(Names+'
+Str
else
Memo1.Lines.Insert(0,ABinding.PeerIP+'
procedureTForm1.Memo1DblClick(Sender:
Memo1.Clear;
procedureTForm1.FormShow(Sender:
IP:
127.0.0.1'
Name:
本机'
FileName:
ADODataSet1.CreateDataSet;
ifFileExists('
.\Data.Dat'
)then
ADODataSet1.LoadFromFile('
StatusBar1.Panels.Items[0].Text:
当前好友姓名为:
+Name;
StatusBar1.Panels.Items[1].Text:
IP地址为:
+IP;
ADDlist;
functionTForm1.GetName(IP:
string;
varName:
String):
Boolean;
IsFind:
Boolean;
IsFind:
=ADODataSet1.Locate('
IP,[]);
ifIsFindthen
=ADODataSet1.FieldByName('
).AsString
Result:
=IsFind;
procedureTForm1.Memo2KeyPress(Sender:
varKey:
Char);
ifKey=#13then
Button1.Click;
Exit;
{Thread}
procedureTForm1.SpeedButton1Click(Sender:
Form2.ADOState:
=1;
Form2.DelTxt;
Form2.ShowModal;
procedureTForm1.SpeedButton2Click(Sender:
=2;
Form2.GetTxt;
procedureTForm1.SpeedButton3Click(Sender:
ifApplication.MessageBox('
是否要删除该记录!
'
明日科技'
MB_OKCANCEL)=IDOKthen
ADODataSet1.Delete;
ADODataSet1.SaveToFile('
form1.ADDlist;
procedureTForm1.ADDlist;
same:
Integer;
IsAdd:
boolean;
ADODataSet2.Close;
ADODataSet2.CreateDataSet;
ADODataSet2.LoadFromFile('
ADODataSet2.Open;
ADODataSet2.First;
ListBox1.Items.Clear;
WhilenotADODataSet2.Eofdo
isadd:
=true;
forsame:
=0toListBox1.Count-1do
ifADODataSet2.Fields[0].asstring=listbox1.Items[same]then
=false;
break;
ifisaddthen
ListBox1.Items.Add(ADODataSet2.Fields[0].asstring);
ADODataSet2.Next;
procedureTForm1.ListBox1Click(Sender:
i:
Fori:
=0toListBox1.Items.Count-1do
if(ListBox1.SelCount<
>
0)then
[ListBox1.Items[ListBox1.ItemIndex]]);
StatusBar1.Panels.Items[0].Text:
向:
+ADODataSet2.FieldByName('
).AsString+'
发送信息'
StatusBar1.Panels.Items[1].Text:
IP地址为:
IP:
=ADODataSet2.FieldByName('
Name:
functionTForm1.GettoName:
String;
Size:
Card
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 开发工具 开发 工具 实验 指导书