cvi学习录.doc_第1页
cvi学习录.doc_第2页
cvi学习录.doc_第3页
cvi学习录.doc_第4页
cvi学习录.doc_第5页
免费预览已结束,剩余11页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一、LabWindows/CVI 程序剖析 通过例程FirstSample的编制,大家已对LabWindows/CVI编程有了初步的认识。本章是作者从总体上来谈谈自己对LabWindows/CVI程序的理解与认识。 LabWindos/CVI 编程的步骤基本如下: 制定程序设计的基本方案 第一步 根据任务确定程序的基本框架如: 程序界面,程序中所需的函数等。 创建用户图形界面 第二步 根据第一步制定的方案 创建用户图形界面及回 调函数名。 程序源代码的编制第三步 让计算机生成程序代码及回调函数 的基本框架。添加函数代码,完成 源代码的编制工作。 工程项目的完成 第四步 编译,调试程序。把头文件,用户图 形界面文件,源代码文件添加到项目 文件中去,完成整个程序的编制程序框架及文件间的相互关系如下图所示(以FirstSample.prj为例):当我们按下Acquire按扭,计算机会自动产生一个正弦波形并画在图形显示区中;当按下Clear按扭后则清除正弦波形;当按下Quit按扭后退出该程序。 项目工程文件 (FirstSample.prj) 用户图形界面文件 源代码文件 头文件 (FirstSample.uir) (FirstSample.c) (FirstSample.h) panel include “FirstSample.h” 定义了程序中所需的 事件消息 常量以及函数原形。 Acquire按扭 AcquireCallback( ) 事件消息 Wave512 Clear按扭 ClearCallback( ) 事件消息 Quit按扭 QuitCallback( ) ShowWave 上图所画的构成一项目工程文件的各文件之间的关系是非常重要的。如果你能理解上图所示的内容,那么你就基本理解了LabWindos/CVI 程序的运作过程。二、 CVI字体修改 OptionsFont 将前面的勾选上,这时“Edit”会变亮,点击,按修改字体和大小,OK!三、CVI常用函数说明1)strcpy :拷贝源字符串到目标字符串; 解释:Copies a source string including the terminating ASCII NUL byte into a target string. If copying takes place between objects that overlap, the behavior is undefined. 语句:char *strcpy (char Target_String, const char Source_String);2)FileExists :检测指定路径下的文件是否在硬盘中存在;解释:Determines if a file with the specified pathname exists on disk.语句:int FileExists (const char Path, int *File_Size);3)Ini_New:获得ini文件句柄;解释:This function creates an object which can contain an in-memory list of tag/value pairs within sections语句:IniText Ini_New (int Automatic_Sorting);4)Ini_ReadFromFile:读取ini文件;解释:Reads the tag/value pairs in the file identified by pathname into the list identified by handle. 语句:int Ini_ReadFromFile (IniText Handle, const char Pathname);5)Ini_SectionExists:检测ini文件句柄开始的指定字节是否存在;、解释:Determines if the section specified by sectionName exists in the list of tag/value pairs specified by handle. 语句:int Ini_SectionExists (IniText Handle, const char Section_Name);6)Ini_GetInt:得到由sectionName定义的字节中连接到tagName的整数;解释:Obtains the integer value associated with tagName in the section identified by sectionName.; 语句:int Ini_GetInt (IniText Handle, const char Section_Name, const char Tag_Name, int *Integer_Value);7)DBSetDatabase:设置一个默认数据库,这个数据库允许保存不同的表格在不同的数据库;有限数据的数据库支持这种功能;解释:Sets the default database in systems that allow you to store tables in separate databases. A limited number of database systems support this function.; 语句:int DBSetDatabase (int Connection_Handle, char Database_Name);8)InitCVIRTE:初始化LabWindows/CVI运行引擎;为了使能运行引擎,只有通过此函数可以执行外部编译器;否则,此功能无效;解释:Performs initialization of the LabWindows/CVI Run-time Engine. You need InitCVIRTE only in executables or DLLs that you link using an external compilerexternal compiler. Otherwise, the function is harmless.; 语句:int InitCVIRTE (void *HInstance, char *Argv, void *Reserved);9)Ini_Dispose:释放内存中由Handle声明的资源;解释:Disposes of the in-memory list of tag/value pairs identified by Handle.; 语句:void Ini_Dispose (IniText Handle);10)Ini_GetPointerToRawString:得到由sectionName定义的字节中连接到tagName的指针;解释:Obtains a pointer to the string associated with tagName in the section identified by sectionName; 语句:int Ini_GetPointerToRawString (IniText Handle, const char Section_Name, const char Tag_Name, char *Pointer_to_String);11)strcat:建立复制源字符串到目标字符串结束的路径;解释:Appends a copy of a source string to the end of a target string, including the terminating ASCII NUL byte. The initial character of the string to append overwrites the NUL byte at the end of the target string. If copying takes place between objects that overlap, the behavior is undefined.; 语句:char *strcat (char Target_String, const char String_to_Append);12)SetPanelAttribute:设置特殊面板的属性的值;解释:Sets the value of a particular panel attribute.; 语句:int SetPanelAttribute (int Panel_Handle, int Panel_Attribute, .);13)SetTrayIconMenuItemAttr:设置指定系统托盘图标弹出面板的特殊项目的属性;解释:This function sets an attribute of a particular item on the specified System Tray icons popup menu.; 语句:int SetTrayIconMenuItemAttr (int Icon_Handle, int Item_Index, int Popup_Menu_Attribute, int Value);14)sprintf:输出由formatString指定的字符串,一个空操作符将会写在要写的字符串末尾;解释:Writes output to the specified string according to format specifiers in formatString. A null character is written at the end of the characters written.; 语句:int sprintf (char Target_String, const char Format_String, .);15)RunUserInterface:运行用户界面并运行回调函数;解释:Runs the user interface and issues events to callback functions.RunUserInterface does not return until you call QuitUserInterface from within a callback function. RunUserInterface returns the value that you pass to QuitUserInterface.; 语句:int RunUserInterface (void);16)DetachTrayIconMenu:从指定的系统托盘图标中移除弹出菜单;解释:This function removes a popup menu from the specified System Tray icon.语句:int DetachTrayIconMenu (int Icon_Handle);17)RemoveSysTrayIcon:从系统托盘中移除指定的图标并且释放所占有的资源;解释:This function removes the specied icon from the System Tray and frees all resources. The function destroys any menus associated with the icon.语句:int RemoveSysTrayIcon (int Icon_Handle);18)DBImmediateSQL:立刻执行一个SQL声明(创建打开,并关闭);调用DBImmediateSQL函数等效于先调用DBActivateSQL函数,然后再调用DBDeactivateSQL函数。这个函数对于任何SQL声明都有效,不必再进一步的操作如CREATE TABLE, INSERT INTO, and UPDATE.因为这个函数也终止声明执行。对于SELECT声明是无效的。若你使用DBImmediateSQL执行了一个SELECT声明,你不能访问选择的记录,并且有些数据库不会释放在SELECT声明中图标的锁。解释:Executes an SQL statement immediately. Calling DBImmediateSQL is equivalent to calling DBActivateSQL and then DBDeactivateSQL. This function is useful for any SQL statement that does not require further processing such as CREATE TABLE, INSERT INTO, and UPDATE. Because this function also ends statement execution, it is not useful for SELECT statements.If you execute a SELECT statement with DBImmediateSQL, you cannot access the selected records, and some database systems do not release the locks for tables in the SELECT statement.语句:int DBImmediateSQL (int Connection_Handle, char SQL_Statement);19)DBActivateSQL:创建并打开一个SQL声明。调用DBActivateSQL等效于先调用DBNewSQLStatement函数,然后调用DBOpenSQLStatement函数。解释:Activates an SQL statement. Calling DBActivateSQL is equivalent to calling DBNewSQLStatement and then DBOpenSQLStatement.语句:int DBActivateSQL (int Connection_Handle, char SQL_Statement);20)DBGetColInt:从当前的记录中得到一个整数。你可以先取一个记录,然后使用DBGetColInt,替代绑定一个值,然后取一个记录。解释:Gets an integer value from the current record. Instead of binding values and then fetching a record, you can fetch a record and then use DBGetColInt.语句:int DBGetColInt (int Statement_Handle, int Column_Number, int *Value);21)DBDeactivateSQL:关闭一个SQL声明。调用这个函数对于释放系统资源很重要。解释:Deactivates a SQL statement. It is important to call DBDeactivateSQL to free system resources.语句:int DBDeactivateSQL (int Statement_Handle);22)DBFetchNext:从数据库中恢复下一条记录。这个函数放一列数值在你之前指定任意变量中,使用这个功能用于绑定或镜像变量。当DBFetchNext执行到SELECT声明返回的上一条记录时,它会返回一个文件结尾的结果。解释:Retrieves the next record from the database. This function places the column values in any variables that you previously specified using the functions for binding or mapping variables.When DBFetchNext reaches the last record that the SELECT statement returns, it returns an end-of-file result, DB_EOF.语句:int DBFetchNext (int Statement_Handle);22)GetCtrlVal:获得控件的值。当Control_ID时一个目录或是环时,GetCtrlVal返回值是当前选择目录项目值;要得到选择目录项目的指针,请使用GetCtrlIndex.解释:Obtains the current value of a control.When the control ID is for a list box or ring control, GetCtrlVal returns the value of the currently selected list item. To obtain the index of the selected list item, use GetCtrlIndex.语句:int GetCtrlVal (int Panel_Handle, int Control_ID, void *Value);23)DBDisconnect:关闭连接到数据库的连接。在你程序终止之前关闭所有连接,可以释放系统资源。调用DBDisconnect等效于先调用DBCloseConnection函数,然后调用DBDiscardConnection函数。DBDisconnect可以终止激活任意激活镜像或SQL声明的连接。解释:Closes a connection to a database system. Close all connections before your program terminates to free system resources. Calling DBDisconnect is equivalent to calling DBCloseConnection and then DBDiscardConnection. DBDisconnect deactivates any active maps or SQL statements on the connection.语句:int DBDisconnect (int Connection_Handle);24)QuitUserInterface:迫使RunUserInterface返回,同时返回一个特定值,并且终止任何事件进程。调用QuitUserInterface只用于在回调函数在执行RunUserInterface回调;解释:Causes RunUserInterface to return with a specific return code and terminates event processing. Call QuitUserInterface only from within a callback function invoked during execution of RunUserInterface.语句:int QuitUserInterface (int Return_Code);25)InstallSysTrayIcon:功能是安装一个用户定义的图标在Windows 桌面任务栏(系统托盘);这个函数指定回调函数会响应来自图标的鼠标事件。解释:This function installs a userdefined icon in the Status area of the Windows Desktop Taskbar (the System Tray). The function specified in the callbackFunction parameter will receive mouse events from the icon.语句:int InstallSysTrayIcon (const char Icon_Image_File, const char ToolTip_Text, TrayIconCallback Callback_Function, int *Icon_Handle);26)AttachTrayIconMenu:功能是右击指定系统托盘图标弹出一个菜单。解释:This function attaches a rightclick popup menu to the specified System Tray icon. 语句:int AttachTrayIconMenu (int Icon_Handle);27)AttachTrayIconMenu:功能是对于右击弹出菜单增加一个项目。项目是依次增加从最初的项目1,在弹出界面垂直增加。解释:This function adds an item to the specified icons rightclick popup menu. Items are added in order, with the first item being item 1, and grow vertically on the popup menu.语句:int InsertTrayIconMenuItem (int Icon_Handle, const char Item_Name, int *Item_Index);28)AttachTrayIconMenu:功能是对于右击弹出菜单增加一个项目。项目是依次增加从最初的项目1,在弹出界面垂直增加。解释:This function adds an item to the specified icons rightclick popup menu. Items are added in order, with the first item being item 1, and grow vertically on the popup menu.语句:int InsertTrayIconMenuItem (int Icon_Handle, const char Item_Name, int *Item_Index);29)GetDir:在默认的驱动盘得到当前工作路径。解释:Gets the current working directory on the default drive.语句:int GetDir (char Current_Directory);30)strlen:计算指定字符串的长度。解释:Computes the length of the specified string, up to but not including the terminating null character.语句:size_t strlen (const char String);31)CreateMutex:创建一个互斥体(MUTEX)。32)CreateDirectory:创建一个新目录。33)FindWindow:寻找窗口列表中第一个符合指定条件的顶级窗口。34)FindWindow:寻找窗口列表中第一个符合指定条件的顶级窗口。35)sscanf:将输入从指定源字符串反转成指定的格式一系列值。解释:Converts input from the specified source string into a series of values according to the specifiers in formatString. If an input failure occurs before any conversion, the function returns EOF (-1); otherwise, the function returns the number of input items assigned. If copying takes place between objects that overlap, the behavior is undefined. 语句:int sscanf (const char Source_String, const char Format_String, .);36)ReadLine:从一个文件读字节直到遇到换行符,把这些直到最大字节放入缓存器,除了换行符。解释:Reads bytes from a file until it encounters a linefeed (LF) and places up to maximum#Bytes bytes, excluding the LF, into a buffer. If the number of bytes read exceeds a specified maximum, ReadLine discards the excess bytes so that the buffer does not overflow.语句:int ReadLine (int File_Handle, char Line_Buffer, int Maximum_Bytes);37)CloseFile:关闭File_Handle句柄文件。解释:Closes the file associated with fileHandle. Call OpenFile to obtain a file handle.语句:int CloseFile (int File_Handle);38)CopyFile:拷贝一个存在的文件或一组文件到另一个文件或一组文件。解释:Copies the contents of an existing file or group of files to another file or group of files.If the target file is a directory, CopyFile copies the existing file or group of files into the directory.语句:int CopyFile (char Source_File_Name, char Target_File_Name);39)DeleteFile:删除一个存在的文件或一组文件。解释:Deletes an existing file or a group of existing files.语句:int DeleteFile (char File_Name);40)time:确定当前的日程表时间。解释:Determines the current calendar time. The result is stored in the specified output variable and is also returned by the function. The value that is returned is the number of seconds since January 1, 1900 Coordinated Universal Time (UTC), formerly known as Greenwich Mean Time (GMT). You can pass this value to the localtime function to obtain the time for your time zone. You can then pass the structure pointer returned by localtime to either asctime or strftime to obtain an ASCII string representation of the time. time returns -1 if the current calendar time is not available.语句:time_t time (time_t *Current_Calendar_Time);41)localtime:将当前日程表时间分成几部分。解释:Takes a calendar time, breaks it into its component parts, adjusts it to the local time zone, and stores the result in a struct tm. Calendar time can be obtained by calling time. The struct tm contains the following members:*tm_hour indicates the number of hours after midnight. Valid values range from 0 to 23. *tm_isdst indicates the daylight savings time status. The following values are valid: *Daylight savings time is in effect. *0Daylight savings time is not in effect. *Daylight savings time status is unavailable.*tm_mday indicates the day of the month. Valid values range from 1 to 31, where 1 indicates the first day of the month. *tm_min indicates the number of minutes after the hour. Valid values range from 0 to 59. *tm_mon indicates the month. Valid values range from 0 to 11, where 0 is January. *tm_sec indicates the number of seconds after the minute. Valid values range from 0 to 59. *tm_wday indicates the day of the week. Valid values range from 0 to 6, where 0 is Sunday. *tm_yday indicates the day of the year. Valid values range from 0 to 365, where 0 is January 1. *tm_year indicates the number of years since 1900.The function returns a pointer to the structure containing the local date and time. 语句:struct tm *localtime (const time_t *Calendar_Time);42)eof:测试指定托盘文件是否结束。解释:Tests the end-of-file indicator for the specified handle.语句:int eof (int File_Handle);43)GetCtrlIndex:返回当前项目的零点。解释:Returns the zero-based index of the currently selected item in a list box, ring, or tree control.语句:int GetCtrlIndex (int Panel_Handle, int Control_ID, int *Item_Index);44)SetWaitCursor:指定等待光标的状态。解释:Specifies the state of the wait cursor. If you activate the wait cursor, LabWindows/CVI overrides all other cursor styles to display the wait cursor. LabWindows/CVI maintains the state of the wait cursor independently for each thread. Thus, a call to SetWaitCursor in one thread does not cause the wait cursor to appear while a panel from another thread is the active panel.语句:int SetWaitCursor (int Wait_Cursor_State);44)SetCtrlAttribute:设置控件属性的值。解释:Sets the value of a control attribute.语句:int SetCtrlAttribute (int Panel_Handle, int Control_ID, int Control_Attribute, .);45)DeleteTableRows:删除多个指定起始的行。解释:Deletes one or more rows from a table control starting at the specified one-based index.语句:int DeleteTableRows (int Panel_Handle, int Co

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论