Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Accelarators with DDT

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

  • Accelarators with DDT

    Code:
       ' Particually used Borje's code (FindReplace)
    
       #Compile Exe
       #Register None
       #Dim All
       #Include "WIN32API.INC"
       #Include "COMDLG32.INC"
       #Resource "FINDREPL.PBR"
    
       %IDM_FIND    =    1001
       %IDM_REPLACE =    1002
    
       ' ============= RC-file ============
       '% AnyName ACCELERATORS
       '% {"^F", 1001
       '% "^R", 1002}
    
       %IDTEXT     = 101
       
       CallBack Function DlgProc
          Select Case CbMsg
             Case %WM_COMMAND
                Select Case CbCtl
                   Static ReplaceWith As Asciiz * 256, FindWhat As Asciiz * 256, iMsgFindReplace As Long
                   Case %IDM_FIND, %IDM_REPLACE
                      Static fr As FINDREPLACE
                      If fr.lCustData = 0 Then
                         iMsgFindReplace = RegisterWindowMessage ("CommDlg_FindReplace")
                         fr.lStructSize = SizeOf(fr)
                         fr.hwndOwner = CbHndl
                         fr.hInstance = 0
                         fr.Flags = %FR_DOWN
                         fr.lpstrFindWhat =  VarPtr(FindWhat)
                         fr.lpstrReplaceWith = VarPtr(ReplaceWith)
                         fr.wFindWhatLen = SizeOf(FindWhat)
                         fr.wReplaceWithLen = SizeOf(ReplaceWith)
                         fr.lCustData = CbCtl
                         fr.lpfnHook = 0
                         fr.lpTemplateName = 0
                         If CbCtl = %IDM_FIND Then FindText fr Else ReplaceText fr
                      Else
                         MsgBox "Cancel previous Find/Replace dialog"
                      End If
                End Select
                
             Case iMsgFindReplace
                Dim Txt1 As String, Txt2 As String
                If (fr.flags And %FR_DIALOGTERM) = %FR_DIALOGTERM Then
                   fr.lCustData = 0
                   Txt2 = "Finished"
                Else
                   If (fr.flags And %FR_FINDNEXT) = %FR_FINDNEXT Then
                      Txt2 = "Next"
                   ElseIf (fr.flags And %FR_REPLACE) = %FR_REPLACE Then
                      Txt2 = "Replace"
                   ElseIf (fr.flags And %FR_REPLACEALL) = %FR_REPLACEALL Then
                      Txt2 = "Replace All"
                   End If
                   Txt1 = "What: " + FindWhat: If fr.lCustData = %IDM_REPLACE Then Txt1 = Txt1 + $CRLF + "With: " + ReplaceWith
                End If
                MsgBox Txt1,, Txt2
             Case %WM_DESTROY
                PostQuitMessage 0
          End Select
       End Function
    
    
       Function PbMain
          Dim hDlg   As Long
          Dialog New 0, "Test for Ctrl-F / Ctrl-R", ,, 200, 200, %WS_SYSMENU Or %WS_CAPTION Or %WS_MINIMIZEBOX To hDlg
          Control Add TextBox, hDlg, %IDTEXT, "", 10,  10, 180, 150, %ES_MULTILINE Or %ES_WANTRETURN   Or _
            %WS_CHILD Or %WS_TABSTOP, %WS_EX_CLIENTEDGE
          Control Add Button, hDlg, %IDOK, "Nothing", 80, 170, 40, 14, %BS_DEFAULT
          Dialog Show Modeless hDlg, Call DlgProc
          
          Dim hAccel As Long, Msg As tagMsg
          hAccel = LoadAccelerators(GetModuleHandle(""), "AnyName")
          While GetMessage(msg, ByVal 0&, 0, 0)
             If TranslateAccelerator(hDlg, hAccel, Msg) Then
             ElseIf IsDialogMessage (hDlg, Msg) Then
             Else
                TranslateMessage Msg
                DispatchMessage  Msg
             End If
          Wend
      
       End Function
    ------------------
    E-MAIL: [email protected]
Working...
X