Announcement

Collapse
No announcement yet.

Find and Replace and Page Setup Dialogs information requested.

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

  • Find and Replace and Page Setup Dialogs information requested.

    Hi,

    Are there any of you who have experience with the Find and
    Replace Dialog Boxes and the Page Setup Dialog Box of Windows 32?
    Can these dialogs be used with the more easy PB DDT or do they
    need a classical Windows build-up? I searched the FORUM but
    found nothing on these subjects? Strange! Can you enlighten me?

    Regards,

    Erik


    ------------------

  • #2
    Following is a cut from a test I once made. Never liked the Find/Replace
    dialogs, so I build my own, but at least this can lead you in the right
    direction, even if it only shows how to call up the Find dialog.
    Code for actual search must be added by the programmer, see note
    in the Callback, under registered message.

    As for Page setup dialog - Sorry, never used it..

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Simple sample of how to call up the "Find" common dialog..
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMDLG32.INC"
     
    %ID_TEXT = 20
    GLOBAL iMsgFindReplace AS LONG
    GLOBAL OldTextProc     AS LONG
     
    DECLARE CALLBACK FUNCTION DlgProc() AS LONG
    DECLARE FUNCTION PopFindFindDlg (BYVAL hWnd AS LONG, BYVAL sFindText AS STRING) AS LONG
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Call up the Find text dialog
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PopFindFindDlg (BYVAL hWnd AS LONG, BYVAL sFindText AS STRING) AS LONG
      STATIC fr AS FINDREPLACE, zTxt AS ASCIIZ * 256
     
      zTxt                = sFindText
      fr.lStructSize      = SIZEOF(fr)
      fr.hWndOwner        = hWnd
      fr.hInstance        = %NULL
      fr.Flags            = %FR_DOWN ' OR %FR_FINDNEXT '%FR_SHOWHELP' OR %FR_FINDNEXT
      fr.lpstrFindWhat    = VARPTR(zTxt)
      fr.lpstrReplaceWith = %NULL
      fr.wFindWhatLen     = SIZEOF(zTxt)
      fr.wReplaceWithLen  = 0
      fr.lCustData        = 0
      fr.lpfnHook         = %NULL
      fr.lpTemplateName   = %NULL
     
      FUNCTION = FindText(fr)
     
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Main callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgProc() AS LONG
     
      SELECT CASE CBMSG
         CASE %WM_COMMAND
            LOCAL lRes AS LONG, fName AS STRING
            SELECT CASE CBCTL
               CASE 1  : DIALOG END CBHNDL, 1                      '<- EXIT
               CASE 10 : lRes = PopFindFindDlg(GetDlgItem(CBHNDL, %ID_TEXT), "this") '<- FIND..
            END SELECT
     
         CASE %WM_DESTROY
            SetWindowLong GetDlgItem(CBHNDL, %ID_TEXT), %GWL_WNDPROC, OldTextProc
      END SELECT
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Create dialog and controls, etc
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN () AS LONG
      LOCAL hDlg AS LONG, txt AS STRING
                             'register a message for the find dialog..
      iMsgFindReplace = RegisterWindowMessage ("commdlg_FindReplace")
     
      DIALOG NEW 0, "Find dialog test ",,, 140, 120, %WS_SYSMENU, 0 TO hDlg
     
      CONTROL ADD BUTTON, hDlg, 10, "Find..",  10, 90, 60, 14, 1
      CONTROL ADD BUTTON, hDlg, 1,  "E&xit",   70, 90, 60, 14, 1
      txt = REPEAT$(10, "Find this ")
      CONTROL ADD TEXTBOX, hDlg, %ID_TEXT, txt, 4, 4, 128, 60, _
                           %WS_CHILD OR %ES_MULTILINE OR %ES_NOHIDESEL, %WS_EX_CLIENTEDGE
      OldTextProc = SetWindowLong(GetDlgItem(hDlg, %ID_TEXT), %GWL_WNDPROC, CODEPTR(TextProc))
     
      DIALOG SHOW MODAL hDlg CALL DlgProc
     
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Text control subclass
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION TextProc
      LOCAL lpPfr AS FINDREPLACE PTR
      LOCAL txt AS STRING, zt AS ASCIIZ PTR, lRes AS LONG
      STATIC pos AS LONG
     
      SELECT CASE CBMSG
         CASE iMsgFindReplace                            '<- this is the message we registered
            lpPfr = CBLPARAM                             'a few flags one can trap
            IF (@lpPfr.Flags AND %FR_DIALOGTERM) THEN    '<- Find dialog is closed
            ELSEIF (@lpPfr.Flags AND %FR_FINDNEXT) THEN  '<- Find next button is pressed
               CONTROL GET TEXT GetParent(CBHNDL), %ID_TEXT TO txt '<- text to search in
               zt = @lpPfr.lpstrFindWhat                           '<- text to search for
     
               pos = INSTR(pos + 1, txt, @zt)                      '<- search
               IF pos THEN                                         '<- if result
                  DECR pos
                  CALL SendMessage(CBHNDL, %EM_SETSEL, pos, pos + LEN(@zt))
                  pos = pos + LEN(@zt)                             '<- for next search
               ELSE
                  MSGBOX "Sorry, no more occurrences!"
               END IF
           END IF
     
         CASE %WM_KEYDOWN
            IF HIWRD(GetKeyState(%VK_CONTROL)) AND CBWPARAM = 70 THEN '<- CTRL+F pressed in texbox,
               lRes = PopFindFindDlg(CBHNDL, "this")                  '<- so popup Find dialog
            END IF
      END SELECT
      FUNCTION = CallWindowProc(OldTextProc, CBHNDL, CBMSG, CBWPARAM, CBLPARAM)
    END FUNCTION
    ------------------
    March 25, changed the PopFindFindDlg function a bit, so it works..


    [This message has been edited by Borje Hagsten (edited March 25, 2001).]

    Comment


    • #3
      Borje,

      Thanks very much for your quick response. I will take a closer
      look at your code and see if I can get it to do some real work.

      I had a look at the translated Charles Petzold program POPPAD
      which includes find/replace controls. One difficulty of getting
      it to work in the PB DDT context seems to have something to do
      with incorporating this function “IsDialogMessage” correctly in
      the program.

      The IsDialogMessage function “should be used in the main message
      loop of the application to ensure that the dialog box correctly
      processes keyboard input, such as the TAB and ESC keys”.

      Probably the dialogs should be modeless as the find/replace
      dialogs themselves and probably a “message pump” like this should
      be used in the PBMAIN function:
      Code:
      DO
          DIALOG DOEVENTS TO Count&
      LOOP UNTIL Count&=0
      The problem for me is to incorporate the “IsDialogMessage” function
      correctly in this context. I have not been successful so far.
      I will try again.

      Thanks again for your kind help.

      Best Regards,

      Erik


      ------------------




      [This message has been edited by Erik Christensen (edited March 24, 2001).]

      Comment


      • #4
        Erik --
        Are you about Ctrl-R, Ctrl-F (accelerators) ?
        I already posted how to bypass DDT restrictions.


        ------------------
        E-MAIL: [email protected]

        Comment


        • #5
          I changed the sample above slightly and added a subclassed textbox
          to it, just to show basic way of using the find dialog, plus one
          way of trapping CTRL+F in the textbox. Nothing fancy, but it works..


          ------------------

          Comment


          • #6
            Borje --
            You can use Dialog Modeless and separate message loop (similar modal SDK + modeless dialog).
            Code:
              WHILE GetMessage(msg, %NULL, 0, 0)
                IF IsDialogMessage (hDlg, msg) THEN
                  'Skip
                ELSEIF TranslateAccelerator(hDlg, hAccel, msg) THEN
                  'Skip
                ELSE
                  TranslateMessage msg
                  DispatchMessage  msg
                END IF
              WEND

            ------------------
            E-MAIL: [email protected]

            Comment


            • #7
              Borje,
              The new version is better. However, if you replace “this” with
              an empty string (“”) in the program lines and enter the search
              string in the Find dialog, as you would normally do, the search
              is only performed on the first character of the search string.
              It is probably just a small detail easy to adjust.

              Semen,
              Your suggestion is highly interesting. I will try to implement this.

              Thanks a lot for your help. This FORUM is really great.

              Regards,

              Erik

              ------------------


              [This message has been edited by Erik Christensen (edited March 25, 2001).]

              Comment


              • #8
                Sorry. Told you I never used it, so obviously I never tried the
                the code fully. Made a small change in the PopFindFindDlg function,
                so it works better. Needed to add/use a ASCIIZ there..

                The problem with using MS dialogs, as I see it, is that it is much
                harder to change/add anything to them. Personally, I prefer a search
                text field to be a combobox, where each search can be stored for later
                use, etc.

                Tip: there is a complete, custom-built Find dialog in the code for the
                current version of Poffs. See http://tolken99.com/pb/pbfile_e.htm
                Also possible to download the program and code only there, in case
                you don't already have it and don't want to download the entire package.

                Next version of Poffs will not use this Find dialog though. I have made
                it even easier to use than that. Soon ready for Beta test..


                ------------------

                Comment


                • #9
                  Thanks a lot. I have seen your homepage. Very impressive.
                  Need more time - - -

                  Now it is Sunday and Summertime – although still quite cold –
                  and my family is dragging me away from the scre..... :-)


                  ------------------

                  Comment


                  • #10
                    Erik,

                    Summertime in Danmark, now? Don't you mean Daylight Savings Time instead (last Sunday of March thru last Sunday of October)?
                    Like in The Netherlands the Danes obviously say 'summertime', which is very confusing for Anglosaxons because in plain English 'summertime' is just another word for 'summer'.
                    Want to hear a nice story? A few years ago, a colleague of mine and I were rushing through London in a cab. My colleague asked: 'When is summertime in England?' Well, the driver replied, July, August approximately.

                    ------------------
                    mailto:[email protected][email protected]</A>
                    www.basicguru.com/zijlema/

                    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
                    http://zijlema.basicguru.eu
                    *** Opinions expressed here are not necessarily untrue ***

                    Comment


                    • #11
                      You are absolutely right. It was meant as a joke.
                      Regards,
                      Erik

                      ------------------

                      Comment


                      • #12
                        Originally posted by Egbert Zijlema:
                        Erik,

                        Summertime in Danmark, now? Don't you mean Daylight Savings Time instead (last Sunday of March thru last Sunday of October)?
                        Like in The Netherlands the Danes obviously say 'summertime', which is very confusing for Anglosaxons because in plain English 'summertime' is just another word for 'summer'.
                        Well, that's the term we use in Germany, too and - correct me if I'm wrong - that's meant by MEST (Middle European Summer Time). Question is who confuses whom ?

                        Knuth

                        ------------------
                        http://www.softAware.de

                        Comment

                        Working...
                        X