Announcement

Collapse
No announcement yet.

Capture ESC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Capture ESC

    In ShowFrmListProc I can elect to click the button with an ID of %IDC_CREATEMergeDataFILE
    ShowWaiting dialog opens with a progress bar
    CreateMergeDataFile then runs my routine and updates the progress bar
    How can I stop this routine prematurely when pressing the ESC key?
    You may have a few suggestions for the MODELESS ShowWating dialog!!
    Which is a global long variable to say which database to used.

    Thanks
    Ian

    FUNCTION CreateMergeDataFile(hDlg AS LONG) AS LONG
    LOCAL a AS LONG
    LOCAL n AS LONG
    LOCAL hList1 AS LONG
    LOCAL items AS LONG
    LOCAL szBuf1 AS ASCIIZ * %BUF_SIZE
    LOCAL txt AS STRING

    OPEN netdir+"MergeData.txt" FOR OUTPUT AS #2
    txt="Title"+$TAB+"First Name"+$TAB+"Last Name"+$TAB+"Job"+$TAB+"Company"+$TAB+"Street1"+ _
    $TAB+"Street2"+$TAB+"Street3"+$TAB+"City"+$TAB+"State"+$TAB+"Post Code"+ _
    $TAB+"Country"+$TAB+"Telephone"+$TAB+"Fax"+$TAB+"E-Mail"+$TAB+"Telephone2"+ _
    $TAB+"Notes1"+$TAB+"Notes2"+$TAB+"Notes3"+$TAB+"ContactID"
    PRINT #2, txt

    SELECT CASE which
    CONTROL HANDLE hDlg, %LVW_SYSLISTVIEW32 TO hList1
    Items=ListView_GetItemCount(hList1)
    CONTROL SEND hPleaseWait, %IDC_MSCTLS_PROGRESS32_2, %PBM_SETRANGE, 0, MAKDWD(0, Items)
    CASE %MRMAccount TO %MRMMemoPopup
    FOR a=0 TO items-1
    CONTROL SEND hPleaseWait, %IDC_MSCTLS_PROGRESS32_2, %PBM_SETPOS, a, 0
    ListView_GetItemText hList1, a, 5, szBuf1, SIZEOF(szBuf1)
    PRINT #2, MRMSQLGetRecord(BYCOPY szBuf1)
    NEXT a
    CLOSE
    MSGBOX "MRM database"+$CRLF+"New MergeData File Created - "+_
    netdir+"MergeData.txt", %mb_taskmodal, $ApplName
    CASE ELSE
    OPEN netdir+FileName FOR RANDOM AS #1 LEN = LEN(AddressDet)
    FOR a=0 TO items-1
    CONTROL SEND hPleaseWait, %IDC_MSCTLS_PROGRESS32_2, %PBM_SETPOS, a, 0
    ListView_GetItemText hList1, a, 5, szBuf1, SIZEOF(szBuf1)
    GET #1, VAL(szBuf1), AddressDet
    PRINT #2, AddressLineDetails
    NEXT a
    CLOSE
    MSGBOX "None MRM database"+$CRLF+"New MergeData File Created - "+_
    netdir+"MergeData.txt", %mb_taskmodal, $ApplName
    END SELECT
    END FUNCTION

    CALLBACK FUNCTION ShowFrmListProc()
    LOCAL Items AS LONG
    LOCAL n AS LONG
    LOCAL First AS LONG
    LOCAL hList1 AS LONG
    LOCAL a AS LONG
    LOCAL szBuf1 AS ASCIIZ * %BUF_SIZE
    LOCAL pNmLv AS NM_LISTVIEW PTR
    LOCAL Result AS LONG

    SELECT CASE CBMSG
    CASE %WM_NCACTIVATE

    ' CASE %WM_KEYDOWN
    ' msgbox "keydown"
    CASE %WM_INITDIALOG
    DIALOG SEND CBHNDL, %WM_SETICON, %ICON_BIG, hIcon
    CASE %WM_NOTIFY

    CASE %WM_COMMAND
    SELECT CASE CBCTL
    CASE %IDC_List
    CASE %IDCANCEL
    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    DIALOG END CBHNDL, 0
    FUNCTION=1
    END IF
    CASE %IDC_CREATEMergeDataFILE
    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    ShowWaiting 0, "Creating Merge Data File"
    CreateMergeDataFile CBHNDL
    FUNCTION=1
    DIALOG END hPleaseWait, 0
    END IF


    END SELECT
    END SELECT

    END FUNCTION

    FUNCTION ShowWaiting(BYVAL hParent AS DWORD, Message AS STRING) AS LONG
    LOCAL lRslt AS LONG
    LOCAL Count AS DWORD
    #PBFORMS BEGIN DIALOG %IDD_Waiting->->
    LOCAL hDlg AS DWORD
    LOCAL hFont1 AS DWORD

    DIALOG NEW hParent, "Please Wait", 218, 156, 143, 58, %WS_POPUP OR _
    %WS_SYSMENU OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CLIPSIBLINGS OR _
    %WS_VISIBLE OR %DS_MODALFRAME OR %DS_CENTER OR %DS_3DLOOK OR _
    %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE OR _
    %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
    %WS_EX_RIGHTSCROLLBAR, TO hDlg
    CONTROL ADD LABEL, hDlg, %LBL_Message, "", 1, 5, 142, 31, %WS_CHILD OR _
    %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
    CONTROL ADD "msctls_progress32", hDlg, %IDC_MSCTLS_PROGRESS32_2, _
    "msctls_progress32_2", 0, 39, 143, 15, %WS_CHILD OR %WS_VISIBLE OR _
    %WS_BORDER

    hFont1 = PBFormsMakeFont("Arial", 14, 400, %FALSE, %FALSE, %FALSE, _
    %ANSI_CHARSET)

    CONTROL SEND hDlg, %LBL_Message, %WM_SETFONT, hFont1, 0
    #PBFORMS END DIALOG

    hPleaseWait=hDlg
    CONTROL SET TEXT hDlg, %LBL_Message, Message

    DIALOG SHOW MODELESS hDlg
    LOCAL a AS LONG
    FOR a=1 TO 10
    DIALOG DOEVENTS
    NEXT a

    DeleteObject hFont1

    FUNCTION = lRslt
    END FUNCTION
    Ian Docksey, Trinitarian Bible Society

  • #2
    Code:
    CASE %WM_COMMAND
      SELECT CASE CBCTL
         CASE %IDC_List
         CASE %IDCANCEL
           IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN  '
              DIALOG END CBHNDL, 0 
              FUNCTION=1
          END IF
    When you get WM_COMMAND/IDCANCEL, there is no BN_CLICKED notification and CBCTLMSG never equals one.

    That is, when you get WM_COMMAND/IDCANCEL, escape was pressed regardless of other conditions.

    MCM

    PS please use code tagswhen posting code:
    http://www.powerbasic.com/support/pb....php?do=bbcode
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment

    Working...
    X