zoukankan      html  css  js  c++  java
  • 【XLL API 函数】xlAbort

    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。实例位于 : SAMPLESGENERICGENERIC.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;
    }
    
  • 相关阅读:
    对象池使用时要注意几点
    Flash3D学习计划(一)——3D渲染的一般管线流程
    714. Best Time to Buy and Sell Stock with Transaction Fee
    712. Minimum ASCII Delete Sum for Two Strings
    647. Palindromic Substrings(马拉车算法)
    413. Arithmetic Slices
    877. Stone Game
    338. Counting Bits
    303. Range Sum Query
    198. House Robber
  • 原文地址:https://www.cnblogs.com/boluoke/p/5945777.html
Copyright © 2011-2022 走看看