Announcement

Collapse
No announcement yet.

Editing a textbox with overwrite

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

  • Editing a textbox with overwrite

    I have a program where the user can re-access some textboxes with the view of editing them. I have no trouble giving the textbox(s) the focus or in saving the edited text but would like the user to be able to use overwrite rather than delete and insert to accomplish the edit.

    I know that there are many examples of using overwrite in a textbox in these forums but none appear to be simple code examples where the program automatically goes to overwrite when placed in edit mode.

    Following is the code I use to reverse from textbox to textbox which is really like <SHIFT+TAB> except that it eliminates the chance of completely deleting the contents of the textbox. This code is triggered by a hotkey.

    Code:
    SUB GoBack()
        LOCAL Txt$
    
         SELECT CASE TRIM$(Info.ContNo)                       'the selects act as equiv. to shift+tab
             CASE "1","3"
                 SELECT CASE GetFocus
                        CASE GetDlgItem( hDlg17& ,3108)       'call to brno
                             CONTROL SET FOCUS hDlg17& ,1137
                        CASE GetDlgItem( hDlg17& ,1137)       'brno to exch
                             CONTROL SET FOCUS hDlg17& ,3109
                        CASE GetDlgItem( hDlg17& ,3109)       'exch to call
                             CONTROL SET FOCUS hDlg17& ,3108
                 END SELECT
             CASE "2"
                 SELECT CASE GetFocus
                        CASE GetDlgItem( hDlg17& ,1138)       'name to brno
                             CONTROL SET FOCUS hDlg17& ,1137
                        CASE GetDlgItem( hDlg17& ,1137)       'brno to exch
                             CONTROL SET FOCUS hDlg17& ,3109
                        CASE GetDlgItem( hDlg17& ,3109)       'exch to call
                             CONTROL SET FOCUS hDlg17& ,3108
                        CASE GetDlgItem( hDlg17& ,3108)       'call to name
                             CONTROL SET FOCUS hDlg17& ,1138
                  END SELECT
              CASE ELSE '4 to 12
                  SELECT CASE GetFocus
                        CASE GetDlgItem( hDlg17& ,3109)       'exch to call
                             CONTROL SET FOCUS hDlg17& ,3108
                        CASE GetDlgItem( hDlg17& ,3108)       'call to exch
                             CONTROL SET FOCUS hDlg17& ,3109
                  END SELECT
         END SELECT
                      CONTROL GET TEXT hDlg17&, 3108 TO Txt$  'callsign (this block saves the edits)
                            HS.CSign = Txt$                            '(to the hs. type/end type)
                      CONTROL GET TEXT hDlg17&, 3109 TO Txt$  'exchrec
                            HS.ExchRec = Txt$
                      CONTROL GET TEXT hDlg17&, 1137 TO Txt$  'branchno
                            HS.BrNoRec = Txt$
                      CONTROL GET TEXT hDlg17&, 1138 TO Txt$  'name
                            HS.NameRec = Txt$
    
    END SUB
    Can anyone help me out of this jam. Thanks
    Denys C Brosnan

  • #2
    Do you mean that (having navigated back to a textbox that had text entered at an earlier time) you want all the text selected so that when the user begins to (re)type, all text will be replaced?
    Or do you mean that you would like to change from 'Insert' mode typing to 'Overwrite' mode so that the user's input will replace existing text on a character by character basis?

    If the former check out %EM_SETSEL (, 0, -1)
    If the later you may need to Subclass or Superclass the TextBoxes to get them to 'overwrite'. An alternative might be to use RichEdit controls in place of Textboxes as they have native support for Insert/Overwrite.
    Rgds, Dave

    Comment


    • #3
      Did you know equates MAY be used for control IDs?
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Following Dave's suggestion of subclassing, here is a little demo for overwriting in a regular textbox.

        Code:
        'edit text in a textbox with over-write available
        '[keywords] edit overWrite, subclass, %EM_GETSEL, %EM_SETSEL
        '--------------------------------------------------------------------------------------------
        #COMPILE EXE
        #DIM ALL
        #INCLUDE "win32api.inc"
        #INCLUDE "debug.inc"
        
        GLOBAL hDlg, gOldEditClassProc, gChar, overWrite AS LONG
        
        FUNCTION PBMAIN
           DIALOG NEW PIXELS, 0, "Overwrite Test",,, 200, 100, %WS_OverlappedWindow TO hDlg
           CONTROL ADD TEXTBOX, hDlg, 100, "", 20, 20, 120, 20
           CONTROL ADD CHECKBOX, hDlg, 101, "OverWrite", 20, 40, 100, 20
           DIALOG SHOW MODAL hDlg, CALL dlgProc
        END FUNCTION
        
        CALLBACK FUNCTION dlgProc
           LOCAL hEdit, i, n AS LONG
           STATIC txt AS STRING
           SELECT CASE CBMSG
              CASE %WM_INITDIALOG
                 txt = "Overwrite this text"
                 CONTROL HANDLE CB.HNDL, 100 TO hEdit
                 gOldEditClassProc = SetWindowLong(hEdit, %GWL_WNDPROC, CODEPTR(EditSubClassProc))
                 DIALOG POST CB.HNDL, %WM_USER + 1, 0, 0
              CASE %WM_COMMAND
                 IF CB.CTL = 101 THEN
                    CONTROL GET CHECK CB.HNDL, 101 TO n
                    IF n <> overWrite THEN CONTROL SET FOCUS CB.HNDL, 100: overWrite = n
                 END IF 
              CASE %WM_USER + 1
                 CONTROL SET TEXT CB.HNDL, 100, txt
                 CONTROL SET CHECK CB.HNDL, 101, 1: overWrite = 1
                 CONTROL SEND CB.HNDL, 100, %EM_SETSEL, -1, 0 
              CASE %WM_USER + 2
                 CONTROL GET TEXT CB.HNDL, 100 TO txt 
                 CONTROL SEND hDlg, 100, %EM_GETSEL, 0, VARPTR(i): INCR i
                 IF i <= LEN(txt) THEN 
                    MID$(txt, i, 1) = CHR$(gChar)
                 ELSE
                    txt = txt + CHR$(gChar)
                 END IF
                 CONTROL SET TEXT CB.HNDL, 100, txt
                 CONTROL SEND CB.HNDL, 100, %EM_SETSEL, i, i
           END SELECT   
        END FUNCTION
        
        FUNCTION EditSubClassProc(BYVAL hWnd&, BYVAL wMsg&, BYVAL wParm&, BYVAL lParm&) AS LONG
           'capture characters
           LOCAL n AS LONG
           SELECT CASE wMsg&
              CASE %WM_CHAR
                 IF wParm& >= 65 AND wParm& <= 90 OR _
                    wParm& >= 97 AND wParm& <= 122 THEN
                    IF overWrite THEN
                       gChar = wParm&
                       DIALOG SEND hDlg, %WM_USER + 2, 100, 0
                       EXIT FUNCTION
                    END IF
                 END IF
           END SELECT      
           FUNCTION = CallWindowProc(gOldEditClassProc, hWnd&, wMsg&, wParm&, lParm&)
        END FUNCTION

        Comment


        • #5
          Nice one Charles.

          I've added code to respond to the Insert key just fo fun.
          The caret needs a bit more work though
          Code:
          #COMPILE EXE
          #DIM ALL
          #INCLUDE "win32api.inc"
          '#INCLUDE "debug.inc"
           
          GLOBAL hDlg, gOldEditClassProc, gChar, overWrite, caretWidth AS LONG
           
          FUNCTION PBMAIN
             DIALOG NEW PIXELS, 0, "Overwrite Test",,, 200, 100, %WS_OverlappedWindow TO hDlg
             CONTROL ADD TEXTBOX, hDlg, 100, "", 20, 20, 120, 20
             CONTROL ADD CHECKBOX, hDlg, 101, "OverWrite", 20, 40, 100, 20
             DIALOG SHOW MODAL hDlg, CALL dlgProc
          END FUNCTION
           
          CALLBACK FUNCTION dlgProc
             LOCAL hEdit, i, n AS LONG
             STATIC txt AS STRING
             SELECT CASE CBMSG
                CASE %WM_INITDIALOG
                   txt = "Overwrite this text"
                   CONTROL HANDLE CB.HNDL, 100 TO hEdit
                   gOldEditClassProc = SetWindowLong(hEdit, %GWL_WNDPROC, CODEPTR(EditSubClassProc))
                   DIALOG POST CB.HNDL, %WM_USER + 1, 0, 0
                CASE %WM_COMMAND
                   IF CB.CTL = 101 THEN
                      CONTROL GET CHECK CB.HNDL, 101 TO n
                      IF n <> overWrite THEN CONTROL SET FOCUS CB.HNDL, 100: overWrite = n
                      CONTROL SEND CB.HNDL, 100, %WM_USER + 3, 0, 0
                   END IF 
                CASE %WM_USER + 1
                   CONTROL SET TEXT CB.HNDL, 100, txt
                   CONTROL SET CHECK CB.HNDL, 101, 1: overWrite = 1
                   CONTROL SEND CB.HNDL, 100, %EM_SETSEL, -1, 0
                   CONTROL SEND CB.HNDL, 100, %WM_USER + 3, 0, 0
                CASE %WM_USER + 2
                   CONTROL GET TEXT CB.HNDL, 100 TO txt 
                   CONTROL SEND hDlg, 100, %EM_GETSEL, 0, VARPTR(i): INCR i
                   IF i <= LEN(txt) THEN 
                      MID$(txt, i, 1) = CHR$(gChar)
                   ELSE
                      txt = txt + CHR$(gChar)
                   END IF
                   CONTROL SET TEXT CB.HNDL, 100, txt
                   CONTROL SEND CB.HNDL, 100, %EM_SETSEL, i, i
             END SELECT   
          END FUNCTION
           
          FUNCTION EditSubClassProc(BYVAL hWnd&, BYVAL wMsg&, BYVAL wParm&, BYVAL lParm&) AS LONG
             'capture characters
             LOCAL n AS LONG
             SELECT CASE wMsg&
                CASE %WM_USER + 3
                  GoSub SetCaret
                CASE %WM_KEYUP
                  If wParm& = %VK_INSERT Then 
                    overWrite = IIF(overWrite, 0, 1)
                    CONTROL SET CHECK hDlg, 101, overWrite
                    GoSub SetCaret
                   END IF
                CASE %WM_CHAR
                   IF wParm& >= 65 AND wParm& <= 90 OR _
                      wParm& >= 97 AND wParm& <= 122 THEN
                      IF overWrite THEN
                         gChar = wParm&
                         DIALOG SEND hDlg, %WM_USER + 2, 100, 0
                         EXIT FUNCTION
                      END IF
                   END IF
             END SELECT      
            FUNCTION = CallWindowProc(gOldEditClassProc, hWnd&, wMsg&, wParm&, lParm&)
            Exit Function 
           SetCaret:
            IF overWrite THEN
              caretWidth = 4   'GetCharWidthAtCursor??   <- needs work :)
              CreateCaret hWnd&, %NULL, caretWidth, 12
              ShowCaret hWnd&
             Else '
              caretWidth = 0
              CreateCaret hWnd&, %NULL, caretWidth, 12
              ShowCaret hWnd&
            END IF
           RETURN
          END FUNCTION
          Rgds, Dave

          Comment


          • #6
            Thanks Everyone

            Well well. It just goes to show you can teach an old dog new tricks. In 16 years of programming I have never used rich edit. Looks like from now on I will be using it. The richedit textbox seems to be the answer although it appears to be limited in color choice but I'm working on that. I am a great fan of color change when saving something. So that fixes that.

            Dave. Your second statement is the one I needed. Overstrike when editing the textbox. It is amazing that even though one thinks they have covered all the bases there is always something slips through. I thought I had covered that.

            MCM. Yes. I know. It is just that I find it easier to remember numbers rather than equates. In this particular program there is over 12,000 lines which include 94 equates so please bear with me. I have been writing this program since 1993. First in PBDOS then PBCC and now PBWIN and PBFORMS. It is Amatuer Radio orientated and as such is constantly having to be revised as the hierachy change rules and specs. However, as I am getting long in the tooth (76 this year) it does help to pass the time.

            Dave Biggs. I will have a look at the code you have given me to see if I can use part of it to switch from "Insert" to "Overstrike" mode without hitting a key.

            Thanks to all for your input.
            Denys C Brosnan

            Comment


            • #7
              Carrying on Dave's code a little further, resizing the textbox caret, and doing a little rearranging...

              Code:
              'edit text in a textbox with over-write available
              '[keywords] edit overWrite, subclass, %EM_GETSEL, %EM_SETSEL, GetTextExtentPoint32
              '--------------------------------------------------------------------------------------------
              #COMPILE EXE
              #DIM ALL
              #INCLUDE "win32api.inc"
              '#INCLUDE "debug.inc"
              
              GLOBAL hDlg, gOldEditClassProc, gChar, overWrite AS LONG
              
              FUNCTION PBMAIN
                 DIALOG NEW PIXELS, 0, "Overwrite Test",,, 200, 100, %WS_OverlappedWindow TO hDlg
                 CONTROL ADD TEXTBOX, hDlg, 100, "", 20, 20, 150, 20
                 CONTROL ADD CHECKBOX, hDlg, 101, "OverWrite", 20, 40, 100, 20
                 DIALOG SHOW MODAL hDlg, CALL dlgProc
              END FUNCTION
              
              CALLBACK FUNCTION dlgProc
                 LOCAL i, n AS LONG
                 LOCAL t AS SIZEL, cz AS ASCIIZ * 2
                 STATIC hEdit, caretWidth, caretHeight, hdc AS LONG
                 STATIC txt, s AS STRING
                 SELECT CASE CBMSG
                    CASE %WM_INITDIALOG
                       txt = "Overwrite this text"
                       CONTROL HANDLE CB.HNDL, 100 TO hEdit
                       gOldEditClassProc = SetWindowLong(hEdit, %GWL_WNDPROC, CODEPTR(EditSubClassProc))
                       hdc = GetDC(hEdit)
                       DIALOG POST CB.HNDL, %WM_USER + 1, 0, 0
                    CASE %WM_COMMAND 
                       IF CB.CTL = 101 THEN 'toggle overWrite checkmark
                          CONTROL GET CHECK CB.HNDL, 101 TO n
                          CONTROL SET FOCUS CB.HNDL, 100: overWrite = n
                          DIALOG SEND CB.HNDL, %WM_USER + 3, 0, 0
                       END IF 
                    CASE %WM_USER + 1 'complete initialization
                       CONTROL SET TEXT CB.HNDL, 100, txt
                       CONTROL SET CHECK CB.HNDL, 101, 1: overWrite = 1
                       CONTROL SEND CB.HNDL, 100, %EM_SETSEL, -1, 0
                       DIALOG SEND CB.HNDL, %WM_USER + 3, 0, 0
                    CASE %WM_USER + 2 'overWrite text
                       CONTROL GET TEXT CB.HNDL, 100 TO txt 
                       CONTROL SEND hDlg, 100, %EM_GETSEL, 0, VARPTR(i): INCR i
                       IF i <= LEN(txt) THEN 
                          MID$(txt, i, 1) = CHR$(gChar)
                       ELSE
                          txt = txt + CHR$(gChar)
                       END IF
                       CONTROL SET TEXT CB.HNDL, 100, txt
                       CONTROL SEND CB.HNDL, 100, %EM_SETSEL, i, i
                       DIALOG SEND CB.HNDL, %WM_USER + 3, 0, 0
                    CASE %WM_USER + 3 'resize caret width
                       caretHeight = 12
                       IF overWrite THEN
                          CONTROL SEND hDlg, 100, %EM_GETSEL, 0, VARPTR(i)
                          INCR i: cz = MID$(txt, i, 1)
                          GetTextExtentPoint32 hdc, cz, 1, t
                          caretWidth = t.cx
                          DIALOG PIXELS hEdit, caretWidth, caretHeight TO UNITS caretWidth, caretHeight
                          CreateCaret hEdit, %NULL, caretWidth, 12
                          ShowCaret hEdit
                       ELSE
                          caretWidth = 0
                          CreateCaret hEdit, %NULL, caretWidth, 12
                          ShowCaret hEdit
                       END IF
                    CASE %WM_DESTROY
                       ReleaseDC hEdit, hdc   
                 END SELECT   
              END FUNCTION
              
              FUNCTION EditSubClassProc(BYVAL hWnd&, BYVAL wMsg&, BYVAL wParm&, BYVAL lParm&) AS LONG
                 'capture keybd characters and left mouse clicks
                 LOCAL n AS LONG
                 SELECT CASE wMsg&
                    CASE %WM_LBUTTONUP
                       DIALOG SEND hDlg, %WM_USER + 3, 100, 0
                    CASE %WM_KEYUP
                       IF wParm& = %VK_INSERT THEN 
                          overWrite = IIF(overWrite, 0, 1) 'toggle overWrite
                          CONTROL SET CHECK hDlg, 101, overWrite
                       END IF
                       DIALOG SEND hDlg, %WM_USER + 3, 100, 0
                       EXIT FUNCTION
                    CASE %WM_CHAR
                       IF wParm& >= 65 AND wParm& <= 90 OR _
                          wParm& >= 97 AND wParm& <= 122 THEN
                          IF overWrite THEN
                             gChar = wParm&
                             DIALOG SEND hDlg, %WM_USER + 2, 100, 0
                             EXIT FUNCTION
                          END IF
                       END IF
                 END SELECT      
                 FUNCTION = CallWindowProc(gOldEditClassProc, hWnd&, wMsg&, wParm&, lParm&)
              END FUNCTION

              Comment


              • #8
                Another way without using a subclass

                Just another way to do overwrite mode/insert mode but without using a subclass.

                Thanks to many code fragments from other examples.

                Code:
                ' Overwrite mode with insert/overwrite toggle without using a subclass
                #PBFORMS CREATED V2.01
                '------------------------------------------------------------------------------
                ' The first line in this file is a PB/Forms metastatement.
                ' It should ALWAYS be the first line of the file. Other
                ' PB/Forms metastatements are placed at the beginning and
                ' end of "Named Blocks" of code that should be edited
                ' with PBForms only. Do not manually edit or delete these
                ' metastatements or PB/Forms will not be able to reread
                ' the file correctly.  See the PB/Forms documentation for
                ' more information.
                ' Named blocks begin like this:    #PBFORMS BEGIN ...
                ' Named blocks end like this:      #PBFORMS END ...
                ' Other PB/Forms metastatements such as:
                '     #PBFORMS DECLARATIONS
                ' are used by PB/Forms to insert additional code.
                ' Feel free to make changes anywhere else in the file.
                '------------------------------------------------------------------------------
                
                #COMPILE EXE
                #DIM ALL
                
                '------------------------------------------------------------------------------
                '   ** Includes **
                '------------------------------------------------------------------------------
                #PBFORMS BEGIN INCLUDES
                #INCLUDE ONCE "WIN32API.INC"
                #PBFORMS END INCLUDES
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** Constants **
                '------------------------------------------------------------------------------
                #PBFORMS BEGIN CONSTANTS
                %IDD_DIALOG1  =  101
                %IDC_TEXTBOX1 = 1001
                %IDL_LABEL1   = 1002
                %IDB_BUTTON1  = 1003
                #PBFORMS END CONSTANTS
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** Declarations **
                '------------------------------------------------------------------------------
                DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                #PBFORMS DECLARATIONS
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** Main Application Entry Point **
                '------------------------------------------------------------------------------
                GLOBAL GHDLG,ghKeyb AS DWORD,V_INSERTION AS INTEGER, V_ERRORCD AS INTEGER,BYPASS_ENUPDATE AS INTEGER,V_DELETE AS INTEGER 
                FUNCTION PBMAIN()
                    ShowDIALOG1 %HWND_DESKTOP
                END FUNCTION
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** CallBacks **
                '------------------------------------------------------------------------------
                FUNCTION KeyBoardProc(BYVAL iCode AS INTEGER, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS DWORD
                  SELECT CASE wParam
                    CASE %VK_INSERT                                              
                      PostMessage GhDlg, %WM_USER + 501, wParam, lParam     
                    CASE %VK_DELETE                                             
                      PostMessage GhDlg, %WM_USER + 502, wParam, lParam
                  END SELECT
                  FUNCTION = CallNextHookEx(ghKeyb, iCode, wParam, lParam)  
                END FUNCTION
                CALLBACK FUNCTION ShowDIALOG1Proc()
                    STATIC TXT AS STRING
                    LOCAL Field_Len AS INTEGER,Msg AS tagMsg,lpsize AS SIZEL,lresult AS LONG
                    STATIC V_NKEYPOS AS LONG,lPar AS LONG
                    STATIC EditBusy AS INTEGER,ShiftKeyState AS INTEGER
                    field_len = 20
                    SELECT CASE AS LONG CB.MSG
                        CASE %WM_INITDIALOG
                          ghDlg  = CB.HNDL
                          ghKeyb = SetWindowsHookEx(%WH_KEYBOARD, CODEPTR(KeyBoardProc), 0, GetCurrentThreadId)   ' Install keyboard hook
                            ' Initialization handler
                          DIALOG SET TEXT CB.HNDL,"INS"
                        CASE %WM_DESTROY
                            UnhookWindowsHookEx ghKeyb                          ' House Keeping - unhook keyboard on exit
                        CASE %WM_NCACTIVATE
                            STATIC hWndSaveFocus AS DWORD
                            IF ISFALSE CB.WPARAM THEN
                                ' Save control focus
                                hWndSaveFocus = GetFocus()
                            ELSEIF hWndSaveFocus THEN
                                ' Restore control focus
                                SetFocus(hWndSaveFocus)
                                hWndSaveFocus = 0
                            END IF
                
                        CASE %WM_USER + 501                                   ' msg from hook proc.
                          lPar& = CBLPARAM
                          IF BIT(lPar&, 31) THEN  ' on INSERT KEY UP then set the INSERT Toggle flag
                            V_INSERTION% = NOT V_INSERTION% 
                            IF V_INSERTION% = 0 THEN
                              DIALOG SET TEXT CB.HNDL,"OVR" 
                            ELSE
                              DIALOG SET TEXT CB.HNDL,"INS"
                            END IF  
                          END IF
                        CASE %WM_USER + 502                                   ' msg from hook proc.
                          lPar& = CBLPARAM
                          IF BIT(lPar&, 31) THEN  ' on INSERT KEY UP then set the INSERT Toggle flag
                            V_DELETE% = -1
                          END IF
                        CASE %WM_COMMAND
                            ' Process control notifications
                            SELECT CASE AS LONG CB.CTL
                                CASE %IDC_TEXTBOX1
                                  SELECT CASE CB.CTLMSG          
                                    CASE %EN_SETFOCUS
                                      CONTROL SET COLOR CB.HNDL,CB.CTL,-1,RGB(255,255,128)
                                      CONTROL REDRAW CB.HNDL,CB.CTL
                                      CONTROL GET TEXT CB.HNDL,CB.CTL TO TXT$
                                      CONTROL SEND CB.HNDL,CB.CTL, %EM_SETSEL,0,-1           
                                      EXIT FUNCTION
                                    CASE %EN_UPDATE
                                      IF EditBusy THEN EXIT FUNCTION
                                      Editbusy = -1
                                      CONTROL GET TEXT CB.HNDL,CB.CTL TO TXT$
                                      CONTROL SEND CB.HNDL,CB.CTL, %EM_GETSEL,0,0 TO V_NKEYPOS
                                      V_NKEYPOS = LOWRD(V_NKEYPOS)
                                      IF V_INSERTION% = 0 AND NOT V_DELETE% THEN
                                        CONTROL SEND CB.HNDL,CB.CTL, %EM_SETSEL,V_NKEYPOS&,V_NKEYPOS& + 1  'Selects current character
                                        CONTROL SEND CB.HNDL,CB.CTL,%WM_CLEAR,0,0                          'If nothing to clear doesn't act
                                        CONTROL GET TEXT CB.HNDL,CB.CTL TO TXT$
                                      ELSE
                                        V_DELETE% = 0
                                      END IF
                                      IF V_NKEYPOS = Field_Len THEN
                                        RESET Editbusy: EXIT FUNCTION
                                      END IF
                                      IF LEN(TXT$) = Field_Len AND V_INSERTION% = -1 THEN
                                        RESET Editbusy: EXIT FUNCTION
                                      END IF
                                      IF LEN(TXT$) > Field_Len THEN
                                        CONTROL SET TEXT CB.HNDL,CB.CTL,LEFT$(TXT$,Field_Len)
                                        CONTROL SEND CB.HNDL,CB.CTL, %EM_SETSEL,Field_Len,Field_Len              
                                        RESET Editbusy: EXIT FUNCTION
                                      END IF
                                      RESET Editbusy: EXIT FUNCTION
                                    CASE %EN_KILLFOCUS
                                      CONTROL SET COLOR CB.HNDL,CB.CTL,-1,%WHITE  
                                      CONTROL REDRAW CB.HNDL,CB.CTL
                                  END SELECT      
                                CASE %IDB_BUTTON1
                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                      DIALOG END CB.HNDL,0
                                    END IF
                
                            END SELECT
                    END SELECT
                END FUNCTION
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** Dialogs **
                '------------------------------------------------------------------------------
                FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                    LOCAL lRslt  AS LONG
                
                #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                    LOCAL hDlg   AS DWORD
                    LOCAL hFont1 AS DWORD
                
                    DIALOG NEW hParent, "Overwrite mode", 161, 157, 410, 199, %WS_POPUP OR _
                        %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
                        %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
                        %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                        OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                    CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "", 90, 40, 135, 15
                    CONTROL ADD LABEL,   hDlg, %IDL_LABEL1, "Data", 20, 40, 65, 15
                    CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON1, "&Cancel", 305, 160, 60, 15
                
                    FONT NEW "MS Sans Serif", 12, 0, %ANSI_CHARSET TO hFont1
                
                    CONTROL SET FONT hDlg, %IDL_LABEL1, hFont1
                #PBFORMS END DIALOG
                
                    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                
                #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                    FONT END hFont1
                #PBFORMS END CLEANUP
                
                    FUNCTION = lRslt
                END FUNCTION
                '------------------------------------------------------------------------------
                BOB MECHLER

                Comment

                Working...
                X