C API 中有 15个 Excel 回调函数只能使用 Excel4、Excel4v、Excel12、Excel12v 函数调用(或间接的使用框架函数 Excel 或 Excel12f 调用)。也就是说,这15个函数只能从 DLL 或 XLL 调用。它们包括:

  • xlAbort
  • xlCoerce
  • xlDefineBinaryName
  • xlDisableXLMsgs
  • xlEnableXLMsgs
  • xlFree
  • xlGetBinaryName
  • xlGetHwnd
  • xlGetInst
  • xlGetName
  • xlSet
  • xlSheetId
  • xlSheetNm
  • xlStack
  • xlUDF

xlAbort 函数

驱使处理器处理系统中的其它任务,检查用户是否按下了 ESC 键想要退出了宏。如果用户在计算期间按下了 ESC,工作表函数中调用此函数就可以检测到。

函数原型

Excel12(xlAbort, LPXLOPER12 pxRes, 1, LPXLOPER12 pxRetain);

参数

pxRetain (xltypeBool)

可选,如果是 FALSE, 函数就会检查中断条件,并清除所有挂起的中断。这可以让用户继续执行操作。如果忽略了这个函数或将参数设置为 TRUE,函数就会检查用户未清除的中止操作。

属性和返回值

如果用户按下了 ESC ,返回 TRUE(xltypeBool)。

备注

需要频繁调用

如果函数和命令将会花费大量时间,就应该频繁通过调用此函数使CPU 可以切换到其它的任务中去。

避免使用一些不好的语句

避免在你的用户接口中使用 “Abort"。应该考虑使用 ”Cancel"、"Halt"、"Break"、"Stop"。

实例

下面的代码,会反复的激活工作表中的单元格,直到 1分钟 过去或按下了 ESC。实例位于 : \SAMPLES\GENERIC\GENERIC.C

int WINAPI fDance(void)
{
DWORD dtickStart;
XLOPER12 xAbort, xConfirm;
int boolSheet;
int col=0;
XCHAR rgch[32]; //
// Check what kind of sheet is active. If it is a worksheet or macro
// sheet, this function will move the selection in a loop to show
// activity. In any case, it will update the status bar with a countdown.
//
// Call xlSheetId; if that fails the current sheet is not a macro sheet or
// worksheet. Next, get the time at which to start. Then start a while
// loop that will run for one minute. During the while loop, check if the
// user has pressed ESC. If true, confirm the abort. If the abort is
// confirmed, clear the message bar and return; if the abort is not
// confirmed, clear the abort state and continue. After checking for an
// abort, move the active cell if on a worksheet or macro. Then
// update the status bar with the time remaining.
//
// This block uses TempActiveCell12(), which creates a temporary XLOPER12.
// The XLOPER12 contains a reference to a single cell on the active sheet.
// This function is part of the framework library.
// boolSheet = (Excel12f(xlSheetId, 0, 0) == xlretSuccess); dtickStart = GetTickCount(); while (GetTickCount() < dtickStart + 60000L)
{
Excel12f(xlAbort, &xAbort, 0);
if (xAbort.val.xbool)
{
Excel12f(xlcAlert, &xConfirm, 2,
TempStr12(L"Are you sure you want to cancel this operation?"),
TempNum12(1));
if (xConfirm.val.xbool)
{
Excel12f(xlcMessage, 0, 1, TempBool12(0));
return 1;
}
else
{
Excel12f(xlAbort, 0, 1, TempBool12(0));
}
} if (boolSheet)
{
Excel12f(xlcSelect, 0, 1,
TempActiveCell12(0,(BYTE)col));
col = (col + 1) & 3;
} wsprintfW(rgch,L"0:%lu",
(60000 + dtickStart - GetTickCount()) / 1000L); Excel12f(xlcMessage, 0, 2, TempBool12(1), TempStr12(rgch));
} Excel12f(xlcMessage, 0, 1, TempBool12(0));
return 1;
}

【XLL API 函数】xlAbort的更多相关文章

  1. 【XLL API 函数】xlGetHwnd

    返回顶层的 Excel 窗口句柄. Excel4(xlGetHwnd, LPXLOPER pxRes, 0); /* returns low part only */ Excel12(xlGetHwn ...

  2. 【XLL API 函数】xlfUnregister (Form 2)

    此函数可以被 Excel 已经载入的 XLL 或 DLL 调用.它等效于宏表函数 UNREGISTER. xlfUnregister 有两种调用形式: 形式1:Unregister 单独的命令或函数 ...

  3. 【XLL API 函数】xlfUnregister (Form 1)

    此函数可以被 Excel 已经载入的 XLL 或 DLL 调用.它等效于宏表函数 UNREGISTER. xlfUnregister 有两种调用形式: 形式1:Unregister 单独的命令或函数 ...

  4. 【XLL API 函数】xlUDF

    调用用户定义函数,这个函数允许DLL 调用 VBA 中的用户定义函数,XLM 宏语言函数,以及在其它 add-ins 中注册的函数. 原型 Excel12(xlUDF, LPXLOPER12 pxRe ...

  5. 【XLL API 函数】xlStack

    查看堆栈区还剩余多少空间 原型 Excel12(xlStack, LPXLOPER12 pxRes, 0); 参数 此函数没有带任何参数 属性值/返回值 返回堆栈区还剩余的字节数 备注 返回最新版本的 ...

  6. 【XLL API 函数】xlSheetNm

    从外部引用包含的工作表ID返回工作表或宏表名称,或是当前表名称. 原型 Excel12(xlSheetNm, LPXLOPER12 pxRes, 1, LPXLOPER12 pxExtref); 参数 ...

  7. 【XLL API 函数】xlSheetId

    查找命名的工作表ID,用于外部引用. 原型 Excel12(xlSheetId, LPXLOPER12 pxRes, 1, LPXLOPER12 pxSheetName); 参数 pxSheetNam ...

  8. 【XLL API 函数】xlGetName

    以字符串格式返回 DLL 文件的长文件名. 原型 Excel12(xlGetName, LPXLOPER12 pxRes, 0); 参数 这个函数没有参数 属性值和返回值 返回文件名和路径 实例 \S ...

  9. 【XLL API 函数】 xlGetInst

    返回正在调用 DLL 的 Excel 实例的实例句柄. 原型 Excel4(xlGetInst, LPXLOPER pxRes, 0); /* returns low part only */ Exc ...

随机推荐

  1. Swift3.0P1 语法指南——基本操作符

    原档:https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programmi ...

  2. ubutu安装搜狗

    1.下载deb文件 下载32位 wget "http://pinyin.sogou.com/linux/download.php?f=linux&bit=32" -O &q ...

  3. Web服务精讲–搭个 Web 服务器(二)

    导读 曾几何时,你所选择的 Python Web 框架会限制你所可选择的 Web 服务器,反之亦然.如果某个框架及服务器设计用来协同工作的,那么一切正常. 在第一部分中,我提出了一个问题:“如何在你刚 ...

  4. iOS9 beta 请求出现App Transport Security has blocked a cleartext HTTP (http://)

    iOS9 beta 请求出现App Transport Security has blocked a cleartext HTTP (http://) http://www.bubuko.com/in ...

  5. leetcode 142. Linked List Cycle II

    Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...

  6. [转载]JavaEE学习篇之——Session&&Cookie

    原文链接: http://blog.csdn.net/jiangwei0910410003/article/details/23337043 今天继续来看看JavaWeb的相关知识,这篇文章主要来讲一 ...

  7. 小白死去活来的安装ros_qtc_plugin

    在距离写上一篇有关ROS的文章已经过去了很久了.在这段时间内一直在积累,盼望着能够厚积薄发,但还是被无情的社会折磨的死去活来,深深的体会到了一般学校和重点学校找工作的差别,以及用人单位的区别对待.说到 ...

  8. jQuery lazyload插件详解和问题解答

    lazyload插件用于图片延迟加载,节省服务器带宽,减少服务器请求次数,提高网站的页面加载速度,用于网站性能优化,只有当图片在窗口可视范围内时才向服务器请求: 参数: threshold:设置距离窗 ...

  9. 使用shell脚本自动化对硬盘进行分区

    在Linux系统中,可以使用fdisk 对硬盘进行分区,但是要手动执行很多命令,这样使用有很麻烦,现在记一个用fdisk 的脚本自动执行. #make partition dd count= fdis ...

  10. Kali Linux渗透基础知识整理(二)漏洞扫描

    Kali Linux渗透基础知识整理系列文章回顾 漏洞扫描 网络流量 Nmap Hping3 Nessus whatweb DirBuster joomscan WPScan 网络流量 网络流量就是网 ...