Announcement

Collapse
No announcement yet.

RichEdit not scrolling without focus ?

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

  • RichEdit not scrolling without focus ?

    Hi folks,

    I tried to search an answer for this, but without any luck, so if you could give me some tips with this, please.

    I'm trying to use RichEdit box as an (optional) extra data display, which will receive text as the main program proceeds (kind of debug and/or log window). I selected RichEdit tech, because it seems to handle more text. The problem I have with this is, that I just can't get the RichEdit to scroll automatically to the last line without receiving focus first.

    This version demoed here will scroll to the end after you click on it. Or set the focus there programmatically. Usage: click on "Show extra data window", after that click on "Generate some text" to fill it. The last line (no.50) should be visible without activating/focusing the RichEdit box.

    What should I try?

    Code:
     
    #PBFORMS CREATED V1.51
    #COMPILE EXE
    #DIM ALL
    #DEBUG ERROR ON
    #TOOLS OFF
    ___________________________________________________________________________________________________
     
    #PBFORMS BEGIN INCLUDES
    #IF NOT %DEF(%WINAPI)
      #INCLUDE "WIN32API.INC"
    #ENDIF
    #IF NOT %DEF(%RICHEDIT_INC)
      #INCLUDE "RICHEDIT.INC"
    #ENDIF
    #INCLUDE "PBForms.INC"
    #PBFORMS END INCLUDES
    ___________________________________________________________________________________________________
     
    #PBFORMS BEGIN CONSTANTS
    %IDD_dlgMAIN          =  101
    %IDD_dlgEXTRADATA     =  102
    %IDC_btnSHOWEXTRADATA = 4020
    %IDC_redEXTRADATA     = 4300
    %IDC_btnSUMTEXT       = 4301
    #PBFORMS END CONSTANTS
    ___________________________________________________________________________________________________
     
    DECLARE CALLBACK FUNCTION ShowMAINProc()
    DECLARE FUNCTION ShowMAIN(BYVAL hParent AS DWORD) AS LONG
    DECLARE CALLBACK FUNCTION ShowEXTRADATAProc()
    DECLARE FUNCTION ShowEXTRADATA(BYVAL hDlg AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    DECLARE FUNCTION TEXTLOG(txt$) AS LONG
    ___________________________________________________________________________________________________
     
    GLOBAL gMainHDLG, gExtraDataHDLG AS LONG
    ___________________________________________________________________________________________________
    ___________________________________________________________________________________________________
     
    FUNCTION PBMAIN()
      PBFormsRichEdit ()      ' Load RichEdit
      ShowMAIN %HWND_DESKTOP
      PBFormsRichEdit (%TRUE) ' Unload RichEdit
    END FUNCTION
    ___________________________________________________________________________________________________
    ___________________________________________________________________________________________________
     
    CALLBACK FUNCTION ShowMAINProc()
      LOCAL i AS LONG
      SELECT CASE AS LONG CB.MSG
        CASE %WM_INITDIALOG
          '-------------------------------------------------------------------
          '-------------------------------------------------------------------
        CASE %WM_DESTROY
          '-------------------------------------------------------------------
          IF ISTRUE(gExtraDataHDLG) THEN
            DIALOG SEND gExtraDataHDLG, %WM_SYSCOMMAND, %SC_CLOSE, 0
          END IF
          '-------------------------------------------------------------------
        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_COMMAND
          '-------------------------------------------------------------------
          SELECT CASE AS LONG CB.CTL
            CASE %IDC_btnSHOWEXTRADATA
              '---------------------------------------------------------------
              IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                IF gExtraDataHDLG=0 THEN
                  CALL ShowEXTRADATA(CB.HNDL)
                END IF
              END IF
              '---------------------------------------------------------------
            CASE %IDC_btnSUMTEXT
              '---------------------------------------------------------------
              IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                IF ISTRUE(gExtraDataHDLG) THEN
                  FOR i=1 TO 50
                    TEXTLOG("The last line (and caret) should be visible without setting focus here " & FORMAT$(i) & $CRLF)
                  NEXT
                END IF
              END IF
              '---------------------------------------------------------------
          END SELECT
          '-------------------------------------------------------------------
      END SELECT
    END FUNCTION
    ___________________________________________________________________________________________________
     
    FUNCTION ShowMAIN(BYVAL hParent AS DWORD) AS LONG
      LOCAL lRslt AS LONG
    #PBFORMS BEGIN DIALOG %IDD_dlgMAIN->->
      LOCAL hDlg  AS DWORD
      DIALOG NEW hParent, "MainDialog", 58, 62, 211, 73, %WS_POPUP OR %WS_BORDER _
        OR %WS_DLGFRAME OR %WS_SYSMENU 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 BUTTON, hDlg, %IDC_btnSHOWEXTRADATA, "Show extra data window", _
        15, 25, 75, 25, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
        %BS_MULTILINE OR %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, _
        %WS_EX_LEFT OR %WS_EX_LTRREADING
      CONTROL ADD BUTTON, hDlg, %IDC_btnSUMTEXT, "Generate some text", 120, 25, _
        75, 25
    #PBFORMS END DIALOG
      gMainHDLG = hDlg
      DIALOG SHOW MODAL hDlg, CALL ShowMAINProc TO lRslt
    #PBFORMS BEGIN CLEANUP %IDD_dlgMAIN
    #PBFORMS END CLEANUP
      FUNCTION = lRslt
    END FUNCTION
    ___________________________________________________________________________________________________
    ___________________________________________________________________________________________________
     
    CALLBACK FUNCTION ShowEXTRADATAProc()
      STATIC gRTFtop, gRTFbottom, gRTFleft, gRTFright AS LONG
      LOCAL tmpDlgSizex, tmpDlgSizey, tmpsizex, tmpsizey AS LONG
      SELECT CASE AS LONG CB.MSG
        CASE %WM_INITDIALOG
          '-------------------------------------------------------------------
          DIALOG GET CLIENT CB.HNDL TO tmpDlgSizex, tmpDlgSizey
          ' ensin RTF boxi dialogin kokoiseksi
          CONTROL SET LOC CB.HNDL, %IDC_redEXTRADATA, 0,0
          CONTROL SET SIZE CB.HNDL, %IDC_redEXTRADATA, tmpDlgSizex, tmpDlgSizey
          ' richedit, levitys pystyyn ja vaakaan
          CONTROL GET LOC CB.HNDL, %IDC_redEXTRADATA TO gRTFleft, gRTFtop
          CONTROL GET SIZE CB.HNDL, %IDC_redEXTRADATA TO tmpsizex, tmpsizey
          gRTFright = tmpDlgSizex-gRTFleft-tmpsizex
          gRTFbottom = tmpDlgSizey-gRTFtop-tmpsizey
          '-------------------------------------------------------------------
        CASE %WM_SIZE
          '-------------------------------------------------------------
          IF CB.WPARAM <> %SIZE_MINIMIZED THEN
            DIALOG GET CLIENT CB.HNDL TO tmpDlgSizex, tmpDlgSizey
            CONTROL SET SIZE CB.HNDL, %IDC_redEXTRADATA, tmpDlgSizex-gRTFleft-gRTFright, tmpDlgSizey-gRTFtop-gRTFbottom
          END IF
          '-------------------------------------------------------------
        CASE %WM_DESTROY
          '-------------------------------------------------------------
          gExtraDataHDLG = 0
          '-------------------------------------------------------------
        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_COMMAND
          '-------------------------------------------------------------
          SELECT CASE AS LONG CB.CTL
            CASE %IDCANCEL
                DIALOG END CB.HNDL
                FUNCTION = 1
          END SELECT
          '-------------------------------------------------------------
      END SELECT
    END FUNCTION
    ___________________________________________________________________________________________________
     
    FUNCTION ShowEXTRADATA(BYVAL hParent AS DWORD) AS LONG
      LOCAL lRslt AS LONG
    #PBFORMS BEGIN DIALOG %IDD_dlgEXTRADATA->->
      LOCAL hDlg  AS DWORD
      DIALOG NEW %HWND_DESKTOP, "Extra data", 53, 58, 325, 234, %WS_OVERLAPPED OR _
        %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_VISIBLE OR _
        %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE OR _
        %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
      CONTROL ADD PBFormsRichEdit(), hDlg, %IDC_redEXTRADATA, "", 0, 0, 325, 235, _
        %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR %WS_VSCROLL OR _
        %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR %ES_AUTOVSCROLL OR _
        %ES_READONLY OR %ES_SAVESEL OR %ES_NOOLEDRAGDROP, %WS_EX_CLIENTEDGE OR _
        %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
    #PBFORMS END DIALOG
      gExtraDataHDLG = hDlg
      DIALOG SHOW MODELESS hDlg, CALL ShowEXTRADATAProc TO lRslt
    #PBFORMS BEGIN CLEANUP %IDD_dlgEXTRADATA
    #PBFORMS END CLEANUP
      FUNCTION = lRslt
    END FUNCTION
    ___________________________________________________________________________________________________
    ___________________________________________________________________________________________________
     
    FUNCTION TEXTLOG(txt$) AS LONG
      IF ISTRUE(gExtraDataHDLG) THEN
        ' no selections (the first -1), go to the end (the second -1)
        CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL, -1, -1
        CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_REPLACESEL, %FALSE, STRPTR(txt$)
        'CONTROL SET FOCUS gExtraDataHDLG,%IDC_redEXTRADATA
      END IF
    END FUNCTION
    Thank You.

    cheers.. aSa C[_]

  • #2
    Debugging/logging message display? Automatically scrolls to "last" entry?

    Use Listview control as a console. September 13 2003.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      As I'm a lazy and stupid "coder", I like the Textbox's/RichEdit's ability to allow easy transfer of variable sized data directly to the clipboard. Also other "built in" functionality that RichEdit has, might get handy (IF I learn how to use it effectively ).

      Anyway your example seems a good starting point for a listview use, thank you. I'll have it saved for other times/purposes.

      cheers.. aSa C[_]

      Comment


      • #4
        This will insert new data at the top of the richedit box
        Code:
         
        CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL, 0, 0
        Rgds, Dave

        Comment


        • #5
          As I'm a lazy and stupid "coder", I like the Textbox's/RichEdit's ability to allow easy transfer of variable sized data directly to the clipboard
          I'm sure you or someone else can port this to store on the clipboard instead of in a disk file...

          Code:
          ' ------------------------------------------------------------------
          '              Save All entries in Listview control to a file
          ' HWnd          = Handle to listview control
          ' szFileName    = Where to saveText to be printed.
          ' returns:        0 = success else error
          ' to do?? Add startrow, endrow as parameters?
          ' note: listview_getItem cannot return "how much text" is there.. you have to allocate
          ' in this function anyway
          ' ------------------------------------------------------------------
          FUNCTION SaveConsoleLogToFile (BYVAL hWnd AS LONG, szFile AS ASCIIZ ) AS LONG
            LOCAL hF AS LONG, nRow AS LONG, Z AS LONG
          
          
            LOCAL szText  AS ASCIIZ * 4096
            LOCAL w AS STRING
            LOCAL szProgramName AS ASCIIZ * %MAX_PATH, sPRogramName AS STRING
          
            ' get program name to put on report header
            GetModuleFileName  BYVAL %NULL, szProgramName, SIZEOF(szPRogramName)
            sPRogramName = MID$ (szProgramName, INSTR (-1, szPRogramName, "\") + 1)
          
          
            nRow= ListView_GetItemCount (hWnd)
            IF nRow > 0& THEN
          
                hF    = FREEFILE
                OPEN    szFile FOR OUTPUT AS hF
                IF ERR THEN
                    FUNCTION = ERR
                    EXIT FUNCTION
                END IF
          
          
                PRINT #hF, sProgramName  & SPACE$(12) & "CONSOLE LOG" & SPACE$(24) & DATE$ & " " & TIME$
                PRINT #hF,
          
                PRINT #hF, "Date and Time           Message"
                PRINT #hF, "------------------      -------------------------------------------------------"
          
                FOR Z = 0 TO nRow -1
          
                    ' get col zero text, the date and time
                    Listview_GetItemText hWnd, Z, 0, szText, SIZEOF(szText)
                    w        = LSET$(szText, 24)
                    PRINT #hF, w;
                    ' get col 1, the message text
                    Listview_GetItemText hWnd, Z, 1, szText, SIZEOF(szText)
                    W        = szText
                    PRINT #hF, W
                NEXT
                PRINT #hF,
                PRINT #hF, " *** END OF REPORT ***"
                CLOSE hF
          
             END IF     ' if there was any data to print
          
             FUNCTION = 0
          
          END FUNCTION
          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            How about this???
            (I know you wanted without losing focus, but this is so fast that I never notice it)

            Code:
            #PBFORMS CREATED V1.51
            #COMPILE EXE
            #DIM ALL
            #DEBUG ERROR ON
            #TOOLS OFF
            ___________________________________________________________________________________________________
            
            #PBFORMS BEGIN INCLUDES
            #IF NOT %DEF(%WINAPI)
              #INCLUDE "WIN32API.INC"
            #ENDIF
            #IF NOT %DEF(%RICHEDIT_INC)
              #INCLUDE "RICHEDIT.INC"
            #ENDIF
            #INCLUDE "PBForms.INC"
            #PBFORMS END INCLUDES
            ___________________________________________________________________________________________________
            
            #PBFORMS BEGIN CONSTANTS
            %IDD_dlgMAIN          =  101
            %IDD_dlgEXTRADATA     =  102
            %IDC_btnSHOWEXTRADATA = 4020
            %IDC_redEXTRADATA     = 4300
            %IDC_btnSUMTEXT       = 4301
            #PBFORMS END CONSTANTS
            ___________________________________________________________________________________________________
            
            DECLARE CALLBACK FUNCTION ShowMAINProc()
            DECLARE FUNCTION ShowMAIN(BYVAL hParent AS DWORD) AS LONG
            DECLARE CALLBACK FUNCTION ShowEXTRADATAProc()
            DECLARE FUNCTION ShowEXTRADATA(BYVAL hDlg AS DWORD) AS LONG
            #PBFORMS DECLARATIONS
            DECLARE FUNCTION TEXTLOG(txt$) AS LONG
            ___________________________________________________________________________________________________
            
            GLOBAL gMainHDLG, gExtraDataHDLG AS LONG
            GLOBAL hDlg  AS DWORD         '<--- Had to make global...but you were using globals anyways
            ___________________________________________________________________________________________________
            ___________________________________________________________________________________________________
            
            FUNCTION PBMAIN()
              PBFormsRichEdit ()      ' Load RichEdit
              ShowMAIN %HWND_DESKTOP
              PBFormsRichEdit (%TRUE) ' Unload RichEdit
            END FUNCTION
            ___________________________________________________________________________________________________
            ___________________________________________________________________________________________________
            
            CALLBACK FUNCTION ShowMAINProc()
              LOCAL i AS LONG
              SELECT CASE AS LONG CB.MSG
                CASE %WM_INITDIALOG
                  '-------------------------------------------------------------------
                  '-------------------------------------------------------------------
                CASE %WM_DESTROY
                  '-------------------------------------------------------------------
                  IF ISTRUE(gExtraDataHDLG) THEN
                    DIALOG SEND gExtraDataHDLG, %WM_SYSCOMMAND, %SC_CLOSE, 0
                  END IF
                  '-------------------------------------------------------------------
                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_COMMAND
                  '-------------------------------------------------------------------
                  SELECT CASE AS LONG CB.CTL
                    CASE %IDC_btnSHOWEXTRADATA
                      '---------------------------------------------------------------
                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                        IF gExtraDataHDLG=0 THEN
                          CALL ShowEXTRADATA(CB.HNDL)
                        END IF
                      END IF
                      '---------------------------------------------------------------
                    CASE %IDC_btnSUMTEXT
                      '---------------------------------------------------------------
                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                        IF ISTRUE(gExtraDataHDLG) THEN
                          FOR i=1 TO 50
                            TEXTLOG("The last line (and caret) should be visible without setting focus here " & FORMAT$(i) & $CRLF)
                          NEXT
                        END IF
                      END IF
                      '---------------------------------------------------------------
            '*** WORKS BETTER HERE!!!!!!!!!!!!!!
            '*** Works
                SetFocus GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
                SetFocus hDlg
            '*** Does not work
            '     InvalidateRect GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA) , BYVAL %NULL, 0
            '     UpdateWindow GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
                  END SELECT
                  '-------------------------------------------------------------------
              END SELECT
            END FUNCTION
            ___________________________________________________________________________________________________
            
            FUNCTION ShowMAIN(BYVAL hParent AS DWORD) AS LONG
              LOCAL lRslt AS LONG
            #PBFORMS BEGIN DIALOG %IDD_dlgMAIN->->
              DIALOG NEW hParent, "MainDialog", 58, 62, 211, 73, %WS_POPUP OR %WS_BORDER _
                OR %WS_DLGFRAME OR %WS_SYSMENU 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 BUTTON, hDlg, %IDC_btnSHOWEXTRADATA, "Show extra data window", _
                15, 25, 75, 25, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
                %BS_MULTILINE OR %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, _
                %WS_EX_LEFT OR %WS_EX_LTRREADING
              CONTROL ADD BUTTON, hDlg, %IDC_btnSUMTEXT, "Generate some text", 120, 25, _
                75, 25
            #PBFORMS END DIALOG
              gMainHDLG = hDlg
              DIALOG SHOW MODAL hDlg, CALL ShowMAINProc TO lRslt
            #PBFORMS BEGIN CLEANUP %IDD_dlgMAIN
            #PBFORMS END CLEANUP
              FUNCTION = lRslt
            END FUNCTION
            ___________________________________________________________________________________________________
            ___________________________________________________________________________________________________
            
            CALLBACK FUNCTION ShowEXTRADATAProc()
              STATIC gRTFtop, gRTFbottom, gRTFleft, gRTFright AS LONG
              LOCAL tmpDlgSizex, tmpDlgSizey, tmpsizex, tmpsizey AS LONG
              SELECT CASE AS LONG CB.MSG
                CASE %WM_INITDIALOG
                  '-------------------------------------------------------------------
                  DIALOG GET CLIENT CB.HNDL TO tmpDlgSizex, tmpDlgSizey
                  ' ensin RTF boxi dialogin kokoiseksi
                  CONTROL SET LOC CB.HNDL, %IDC_redEXTRADATA, 0,0
                  CONTROL SET SIZE CB.HNDL, %IDC_redEXTRADATA, tmpDlgSizex, tmpDlgSizey
                  ' richedit, levitys pystyyn ja vaakaan
                  CONTROL GET LOC CB.HNDL, %IDC_redEXTRADATA TO gRTFleft, gRTFtop
                  CONTROL GET SIZE CB.HNDL, %IDC_redEXTRADATA TO tmpsizex, tmpsizey
                  gRTFright = tmpDlgSizex-gRTFleft-tmpsizex
                  gRTFbottom = tmpDlgSizey-gRTFtop-tmpsizey
                  '-------------------------------------------------------------------
                CASE %WM_SIZE
                  '-------------------------------------------------------------
                  IF CB.WPARAM <> %SIZE_MINIMIZED THEN
                    DIALOG GET CLIENT CB.HNDL TO tmpDlgSizex, tmpDlgSizey
                    CONTROL SET SIZE CB.HNDL, %IDC_redEXTRADATA, tmpDlgSizex-gRTFleft-gRTFright, tmpDlgSizey-gRTFtop-gRTFbottom
                  END IF
                  '-------------------------------------------------------------
                CASE %WM_DESTROY
                  '-------------------------------------------------------------
                  gExtraDataHDLG = 0
                  '-------------------------------------------------------------
                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_COMMAND
                  '-------------------------------------------------------------
                  SELECT CASE AS LONG CB.CTL
                    CASE %IDCANCEL
                        DIALOG END CB.HNDL
                        FUNCTION = 1
                  END SELECT
                  '-------------------------------------------------------------
              END SELECT
            END FUNCTION
            ___________________________________________________________________________________________________
            
            FUNCTION ShowEXTRADATA(BYVAL hParent AS DWORD) AS LONG
              LOCAL lRslt AS LONG
            #PBFORMS BEGIN DIALOG %IDD_dlgEXTRADATA->->
              LOCAL hDlg  AS DWORD
              DIALOG NEW %HWND_DESKTOP, "Extra data", 53, 58, 325, 234, %WS_OVERLAPPED OR _
                %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_VISIBLE OR _
                %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE OR _
                %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
              CONTROL ADD PBFormsRichEdit(), hDlg, %IDC_redEXTRADATA, "", 0, 0, 325, 235, _
                %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR %WS_VSCROLL OR _
                %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR %ES_AUTOVSCROLL OR _
                %ES_READONLY OR %ES_SAVESEL OR %ES_NOOLEDRAGDROP, %WS_EX_CLIENTEDGE OR _
                %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
            #PBFORMS END DIALOG
              gExtraDataHDLG = hDlg
              DIALOG SHOW MODELESS hDlg, CALL ShowEXTRADATAProc TO lRslt
            #PBFORMS BEGIN CLEANUP %IDD_dlgEXTRADATA
            #PBFORMS END CLEANUP
              FUNCTION = lRslt
            END FUNCTION
            ___________________________________________________________________________________________________
            ___________________________________________________________________________________________________
            
            FUNCTION TEXTLOG(txt$) AS LONG
              IF ISTRUE(gExtraDataHDLG) THEN
                ' no selections (the first -1), go to the end (the second -1)
                CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL, -1, -1
                CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_REPLACESEL, %FALSE, STRPTR(txt$)
                'CONTROL SET FOCUS gExtraDataHDLG,%IDC_redEXTRADATA
                 LOCAL TempText AS STRING
                CONTROL GET TEXT gExtraDataHDLG,%IDC_redEXTRADATA TO TempText
                CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL,LEN(TempText), LEN(TempText)
            '*** Works better if in the callback proc
            ''*** Works
            '    SetFocus GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
            '    SetFocus hDlg
            ''*** Does not work
            ''     InvalidateRect GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA) , BYVAL %NULL, 0
            ''     UpdateWindow GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
              END IF
            END FUNCTION
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              Thank You, Cliff. You were the first really trying to solve this particular case. But I have to say, I AM interested to know the other ways too you have been pushing here. They won't stay unnoted.

              I had some thoughts that this kind of focus trick could be one way *around* this, but postponed it, because I don't know how I could retain currently focused controls, except with a "last_focused" global : P (if you click repeatedly the generator button, you'll notice it will receive focus only every second press). In THIS example I could force that button to be focused every time, but in the real program there is no such a button to be focused.

              I also have tried using forced scrolling features, but something went slightly wrong, as I wasn't very happy with the result.

              Tried scrolling was something like these lines:
              Code:
              ' retrieves either the line number of the current line (the line containing the caret)
              ' or, if there is a selection, the line number of the line containing the beginning of the selection
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_LINEFROMCHAR, -1, 0 TO x1
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_GETFIRSTVISIBLELINE, 0, 0 TO x2
              x1 = x1-x2-5  ' why needs a 5 here? without it scrolls too much!
               
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%WM_SETREDRAW, 0, 0         '<- turn off redraw
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%EM_LINESCROLL, 0, x1       '<- scroll
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%EM_SETSEL, -1, -1          '<- set selection
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%WM_SETREDRAW, 1, 0         '<- turn on redraw
              Or even:
              Code:
               
              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%EM_LINESCROLL, 0, 9999
              If I could at least enquire somehow, what is the current visible line count in the RichEdit control..?? (note: resizable RichEdit => visible line count is not a constant)

              cheers.. aSa C[_]

              Comment


              • #8
                EM_SETSCROLLPOS Message
                --------------------------------------------------------------------------------
                An application sends an EM_SETSCROLLPOS message to tell the rich edit control to scroll to a particular point.
                EM_SCROLL Message
                --------------------------------------------------------------------------------
                The EM_SCROLL message scrolls the text vertically in a multiline edit control. This message is equivalent to sending a WM_VSCROLL message to the edit control. You can send this message to either an edit control or a rich edit control.
                MCM
                Last edited by Michael Mattias; 13 Sep 2008, 11:59 AM.
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Maybe this will spark someone's mind (I can not think of it at the moment)

                  At some point in the past, I did have something (not sure if it was a work-around, or something real), that would on notification of loosing focus, and then before loosing focus, count the lines, and the current cursor position. That way you could put the cursor back where you wanted.

                  I will look around and see if I can find it (or even if I had the idea right, but went about it wrong), but maybe this sparks an idea for someone else
                  Engineer's Motto: If it aint broke take it apart and fix it

                  "If at 1st you don't succeed... call it version 1.0"

                  "Half of Programming is coding"....."The other 90% is DEBUGGING"

                  "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                  Comment


                  • #10
                    You know, keyboard focus is not really part of this problem... the application shown is modifying the contents of a display control (the richedit) when a button is clicked.

                    The way I'd do that is
                    Code:
                       When Button_clicked or other event 
                            add/change delete text of display control 
                            scroll control if desired to ensure latest data are visible 
                            force repaint of scroll control 
                       END WHEN
                    Call me old-fashioned but I like to believe tinkering with the keyboard focus is for ... tinkering with the keyboard interface.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Originally posted by Michael Mattias View Post
                      keyboard focus is not really part of this problem...
                      Probably very true. But "keyboard" focus (for the richedit control) produces the result I would like to see. I also tried dialog and control redraw for it, but it didn't help. Perhaps I didn't do it the right way?

                      The cursor position is in the end, but it just doesn't scroll down there without being focused (this is the problem).

                      Using "%EM_LINESCROLL,0,x" works somewhat, but I need to figure out what is the current (not constant) visible line count of the richedit control to make it nice. Also it scrolled too many lines which I had to compensate (-5 to make the caret stay at the same line. Where does that come from?).

                      "%EM_SCROLLCARET,0,0" didn't work, probably I just don't know how to use it correctly. Or is this just for horizontal scrolling ?

                      cheers.. aSa C[_]

                      Comment


                      • #12
                        Changing the focus "works" because when you gain the focus Windows does other stuff automatically if needed... the stuff you DIDN'T do when you added the text.

                        CONTROL/DIALOG REDRAW DID work... it redrew the control. What it doesn't do is what you should have done ... moved the scroll position.

                        MCM
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          MCM has a point (if I got it right)

                          Code:
                          #PBFORMS CREATED V1.51
                          #COMPILE EXE
                          #DIM ALL
                          #DEBUG ERROR ON
                          #TOOLS OFF
                          ___________________________________________________________________________________________________
                          
                          #PBFORMS BEGIN INCLUDES
                          #IF NOT %DEF(%WINAPI)
                            #INCLUDE "WIN32API.INC"
                          #ENDIF
                          #IF NOT %DEF(%RICHEDIT_INC)
                            #INCLUDE "RICHEDIT.INC"
                          #ENDIF
                          #INCLUDE "PBForms.INC"
                          #PBFORMS END INCLUDES
                          ___________________________________________________________________________________________________
                          
                          #PBFORMS BEGIN CONSTANTS
                          %IDD_dlgMAIN          =  101
                          %IDD_dlgEXTRADATA     =  102
                          %IDC_btnSHOWEXTRADATA = 4020
                          %IDC_redEXTRADATA     = 4300
                          %IDC_btnSUMTEXT       = 4301
                          #PBFORMS END CONSTANTS
                          ___________________________________________________________________________________________________
                          
                          DECLARE CALLBACK FUNCTION ShowMAINProc()
                          DECLARE FUNCTION ShowMAIN(BYVAL hParent AS DWORD) AS LONG
                          DECLARE CALLBACK FUNCTION ShowEXTRADATAProc()
                          DECLARE FUNCTION ShowEXTRADATA(BYVAL hDlg AS DWORD) AS LONG
                          #PBFORMS DECLARATIONS
                          DECLARE FUNCTION TEXTLOG(txt$) AS LONG
                          ___________________________________________________________________________________________________
                          
                          GLOBAL gMainHDLG, gExtraDataHDLG AS LONG
                          GLOBAL hDlg  AS DWORD         '<--- Had to make global...but you were using globals anyways
                          ___________________________________________________________________________________________________
                          ___________________________________________________________________________________________________
                          
                          FUNCTION PBMAIN()
                            PBFormsRichEdit ()      ' Load RichEdit
                            ShowMAIN %HWND_DESKTOP
                            PBFormsRichEdit (%TRUE) ' Unload RichEdit
                          END FUNCTION
                          ___________________________________________________________________________________________________
                          ___________________________________________________________________________________________________
                          
                          CALLBACK FUNCTION ShowMAINProc()
                            LOCAL i AS LONG
                            SELECT CASE AS LONG CB.MSG
                              CASE %WM_INITDIALOG
                                '-------------------------------------------------------------------
                                '-------------------------------------------------------------------
                              CASE %WM_DESTROY
                                '-------------------------------------------------------------------
                                IF ISTRUE(gExtraDataHDLG) THEN
                                  DIALOG SEND gExtraDataHDLG, %WM_SYSCOMMAND, %SC_CLOSE, 0
                                END IF
                                '-------------------------------------------------------------------
                              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_COMMAND
                                '-------------------------------------------------------------------
                                SELECT CASE AS LONG CB.CTL
                                  CASE %IDC_btnSHOWEXTRADATA
                                    '---------------------------------------------------------------
                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                      IF gExtraDataHDLG=0 THEN
                                        CALL ShowEXTRADATA(CB.HNDL)
                                      END IF
                                    END IF
                                    '---------------------------------------------------------------
                                  CASE %IDC_btnSUMTEXT
                                    '---------------------------------------------------------------
                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                      IF ISTRUE(gExtraDataHDLG) THEN
                                        FOR i=1 TO 50
                                          TEXTLOG("The last line (and caret) should be visible without setting focus here " & FORMAT$(i) & $CRLF)
                                        NEXT
                          
                          '&&&&&& Added here just in case                        '<---MCM was right, either no set focus, or one passed for me CCN 9-15-08
                               LOCAL TempText AS STRING
                              CONTROL GET TEXT gExtraDataHDLG,%IDC_redEXTRADATA TO TempText
                              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL,LEN(TempText), LEN(TempText)
                          '&&&&&&&&& Yep it works !!!!
                          
                                        
                                      END IF
                                    END IF
                                    '---------------------------------------------------------------
                          '*** WORKS BETTER HERE!!!!!!!!!!!!!!
                          '*** Works
                              SetFocus GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
                              SetFocus hDlg
                          '*** Does not work
                          '     InvalidateRect GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA) , BYVAL %NULL, 0
                          '     UpdateWindow GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
                                END SELECT
                                '-------------------------------------------------------------------
                            END SELECT
                          END FUNCTION
                          ___________________________________________________________________________________________________
                          
                          FUNCTION ShowMAIN(BYVAL hParent AS DWORD) AS LONG
                            LOCAL lRslt AS LONG
                          #PBFORMS BEGIN DIALOG %IDD_dlgMAIN->->
                            DIALOG NEW hParent, "MainDialog", 58, 62, 211, 73, %WS_POPUP OR %WS_BORDER _
                              OR %WS_DLGFRAME OR %WS_SYSMENU 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 BUTTON, hDlg, %IDC_btnSHOWEXTRADATA, "Show extra data window", _
                              15, 25, 75, 25, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
                              %BS_MULTILINE OR %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, _
                              %WS_EX_LEFT OR %WS_EX_LTRREADING
                            CONTROL ADD BUTTON, hDlg, %IDC_btnSUMTEXT, "Generate some text", 120, 25, _
                              75, 25
                          #PBFORMS END DIALOG
                            gMainHDLG = hDlg
                            DIALOG SHOW MODAL hDlg, CALL ShowMAINProc TO lRslt
                          #PBFORMS BEGIN CLEANUP %IDD_dlgMAIN
                          #PBFORMS END CLEANUP
                            FUNCTION = lRslt
                          END FUNCTION
                          ___________________________________________________________________________________________________
                          ___________________________________________________________________________________________________
                          
                          CALLBACK FUNCTION ShowEXTRADATAProc()
                            STATIC gRTFtop, gRTFbottom, gRTFleft, gRTFright AS LONG
                            LOCAL tmpDlgSizex, tmpDlgSizey, tmpsizex, tmpsizey AS LONG
                            SELECT CASE AS LONG CB.MSG
                              CASE %WM_INITDIALOG
                                '-------------------------------------------------------------------
                                DIALOG GET CLIENT CB.HNDL TO tmpDlgSizex, tmpDlgSizey
                                ' ensin RTF boxi dialogin kokoiseksi
                                CONTROL SET LOC CB.HNDL, %IDC_redEXTRADATA, 0,0
                                CONTROL SET SIZE CB.HNDL, %IDC_redEXTRADATA, tmpDlgSizex, tmpDlgSizey
                                ' richedit, levitys pystyyn ja vaakaan
                                CONTROL GET LOC CB.HNDL, %IDC_redEXTRADATA TO gRTFleft, gRTFtop
                                CONTROL GET SIZE CB.HNDL, %IDC_redEXTRADATA TO tmpsizex, tmpsizey
                                gRTFright = tmpDlgSizex-gRTFleft-tmpsizex
                                gRTFbottom = tmpDlgSizey-gRTFtop-tmpsizey
                                '-------------------------------------------------------------------
                              CASE %WM_SIZE
                                '-------------------------------------------------------------
                                IF CB.WPARAM <> %SIZE_MINIMIZED THEN
                                  DIALOG GET CLIENT CB.HNDL TO tmpDlgSizex, tmpDlgSizey
                                  CONTROL SET SIZE CB.HNDL, %IDC_redEXTRADATA, tmpDlgSizex-gRTFleft-gRTFright, tmpDlgSizey-gRTFtop-gRTFbottom
                                END IF
                                '-------------------------------------------------------------
                              CASE %WM_DESTROY
                                '-------------------------------------------------------------
                                gExtraDataHDLG = 0
                                '-------------------------------------------------------------
                              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_COMMAND
                                '-------------------------------------------------------------
                                SELECT CASE AS LONG CB.CTL
                                  CASE %IDCANCEL
                                      DIALOG END CB.HNDL
                                      FUNCTION = 1
                                END SELECT
                                '-------------------------------------------------------------
                            END SELECT
                          END FUNCTION
                          ___________________________________________________________________________________________________
                          
                          FUNCTION ShowEXTRADATA(BYVAL hParent AS DWORD) AS LONG
                            LOCAL lRslt AS LONG
                          #PBFORMS BEGIN DIALOG %IDD_dlgEXTRADATA->->
                            LOCAL hDlg  AS DWORD
                            DIALOG NEW %HWND_DESKTOP, "Extra data", 53, 58, 325, 234, %WS_OVERLAPPED OR _
                              %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_VISIBLE OR _
                              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE OR _
                              %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                            CONTROL ADD PBFormsRichEdit(), hDlg, %IDC_redEXTRADATA, "", 0, 0, 325, 235, _
                              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR %WS_VSCROLL OR _
                              %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR %ES_AUTOVSCROLL OR _
                              %ES_READONLY OR %ES_SAVESEL OR %ES_NOOLEDRAGDROP, %WS_EX_CLIENTEDGE OR _
                              %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
                          #PBFORMS END DIALOG
                            gExtraDataHDLG = hDlg
                            DIALOG SHOW MODELESS hDlg, CALL ShowEXTRADATAProc TO lRslt
                          #PBFORMS BEGIN CLEANUP %IDD_dlgEXTRADATA
                          #PBFORMS END CLEANUP
                            FUNCTION = lRslt
                          END FUNCTION
                          ___________________________________________________________________________________________________
                          ___________________________________________________________________________________________________
                          
                          FUNCTION TEXTLOG(txt$) AS LONG
                            IF ISTRUE(gExtraDataHDLG) THEN
                              ' no selections (the first -1), go to the end (the second -1)
                              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL, -1, -1
                              CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_REPLACESEL, %FALSE, STRPTR(txt$)
                          '    'CONTROL SET FOCUS gExtraDataHDLG,%IDC_redEXTRADATA
                          '     LOCAL TempText AS STRING
                          '    CONTROL GET TEXT gExtraDataHDLG,%IDC_redEXTRADATA TO TempText
                          '    CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_SETSEL,LEN(TempText), LEN(TempText)
                          ''*** Works better if in the callback proc
                          '''*** Works
                          ''    SetFocus GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
                          ''    SetFocus hDlg
                          '''*** Does not work
                          '''     InvalidateRect GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA) , BYVAL %NULL, 0
                          '''     UpdateWindow GetDlgItem(gExtraDataHDLG,%IDC_redEXTRADATA)
                            END IF
                          END FUNCTION
                          (latest changes marked with &&&&&)
                          Engineer's Motto: If it aint broke take it apart and fix it

                          "If at 1st you don't succeed... call it version 1.0"

                          "Half of Programming is coding"....."The other 90% is DEBUGGING"

                          "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                          Comment


                          • #14
                            Originally posted by Michael Mattias View Post
                            Changing the focus "works" because when you gain the focus Windows does other stuff automatically if needed... the stuff you DIDN'T do when you added the text.
                            Yes, I understand this. I just don't know what the missing bit of code is and I'm trying to fish it here as I have noticed there's a lot of knowledge among the users here.


                            Originally posted by Michael Mattias View Post
                            CONTROL/DIALOG REDRAW DID work... it redrew the control. What it doesn't do is what you should have done ... moved the scroll position.
                            Hmm.. I have managed to scroll "forcefully", but even that had something I didn't understand. Learning is a slow and painfull process for me..

                            I had something like this added when I tried:
                            Code:
                             
                            LOCAL x1, x2 AS LONG
                            ' retrieves either the line number of the current line (the line containing the caret)
                            ' or, if there is a selection, the line number of the line containing the beginning of the selection
                            CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_LINEFROMCHAR, -1, 0 to x1   'the caret is/should be already at the end and without a selection!
                            CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA, %EM_GETFIRSTVISIBLELINE, 0, 0 to x2
                            x1 = x1-x2-5
                            CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%WM_SETREDRAW, 0, 0         '<- turn off redraw
                            CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%EM_LINESCROLL, 0, x1     '<- scroll
                            CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%EM_SETSEL, -1, -1          '<- set selection
                            CONTROL SEND gExtraDataHDLG,%IDC_redEXTRADATA,%WM_SETREDRAW, 1, 0         '<- turn on redraw


                            The problems I had with this were:
                            1. if I wanted the cursor place/caret to stop at the last visible line in the richedit control, I would need to know how many lines there are currently. As I prefer resizable richedit, it will change..
                            2. where did that -5 come from ? Why do I need it to not to scroll over ? (if wanting to stop the cursor position at the same visible line as it were before scroll)
                            cheers.. aSa C[_]
                            Last edited by Ari Savola; 16 Sep 2008, 01:37 AM. Reason: Code example was "REMmed"

                            Comment


                            • #15
                              I need to figure out what is the current (not constant) visible line count of the richedit control to make it nice.
                              Lots of tools to do this kind of thing....

                              EM_GETFIRSTVISIBLELINE
                              EM_GETLINECOUNT
                              EM_GETSCROLLPOS
                              EM_LINEFROMCHAR


                              >Learning is a slow and painfull process for me

                              It's slow for everyone at first; no pain = no gain!


                              MCM
                              Michael Mattias
                              Tal Systems (retired)
                              Port Washington WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                              • #16
                                EM_GETFIRSTVISIBLELINE
                                Gets the zero-based index of the uppermost visible line.

                                EM_GETLINECOUNT
                                Retrieves the total number of text lines, not just the number of lines that are currently visible.

                                EM_GETSCROLLPOS
                                Gets the current scroll position.

                                EM_LINEFROMCHAR
                                Gets the index of the line that contains the specified character index.


                                I'm sorry for being so stupid again, maybe I'm doing too many things at once. How do I get the visible line COUNT with these ?

                                I guess I'm starting to bug you, as this seems quite impossible for me to do at the moment (without focus transfer). And I'm quite picky sometimes..

                                One last question: How it would be possible to get the control id of the currently focused control in a dialog? "DIALOG GET FOCUSEDCONTROL" or something with API would save me from another global


                                cheers.. aSa C[_]

                                Comment


                                • #17
                                  Since you have found the descriptions and know these are window messages, you should be able to use them. Using messages is fundamental to Windows programming.

                                  Unless of course, you are a refugee from some pointy-clicky-dragee-dropee-touchy-feely language product, in which case you probably never learned the fundamentals.
                                  Michael Mattias
                                  Tal Systems (retired)
                                  Port Washington WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    Since you have found the descriptions and know these are window messages, you should be able to use them. Using messages is fundamental to Windows programming.
                                    And fundamental to learning PB is searching the fora for the terms that you need. A search on any one of those terms will lead to examples, and other opportunities.
                                    Don't be surprised to see a familiar name.
                                    Rod
                                    In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                                    Comment


                                    • #19
                                      GetFocus(BYVAL %NULL) - handle of window that has keyboard focus.
                                      Note.. %ID_Control=GetDlgCtrlID(GetFocus())


                                      FYI: Sources of info..

                                      POFFS offline search engine for PB Forums - download here: http://www.reonis.com/POFFS/index.htm

                                      MSDN Library online: http://msdn2.microsoft.com/en-us/Library

                                      Download Windows 32-bit API help file: http://www.powerbasic.com/files/pub/mstools/Win32.zip

                                      (That's an old reference but still usable while your waiting for..
                                      Microsoft Platform SDK CD (low cost) - order here: http://www.qmedia.ca/launch/psdk.htm
                                      (Funky order form asks for a 10 digit phone number whatever your country! Use 123-456-7890 if you are not in the US )
                                      Rgds, Dave

                                      Comment


                                      • #20
                                        Originally posted by Michael Mattias View Post
                                        Since you have found the descriptions and know these are window messages, you should be able to use them. Using messages is fundamental to Windows programming.
                                        As I'm not a Windows programmer.. (u'know there are still ppl alive who have never been educated with Windows stuff, real relics) I just try to make these little exercises to happen, for a learning process of mine. If I only had a personal teacher who would be always watching over my shoulders.. Btw. I have tried those messages, I didn't see any light there, yet. I think I might be missing something (maybe very fundamental?), but how would I know I feel sorry I dragged you all in to this little swamp of mine.

                                        Unless of course, you are a refugee from some pointy-clicky-dragee-dropee-touchy-feely language product, in which case you probably never learned the fundamentals.
                                        Exactly. Well not so much about "pointy-clicky.." as my bible in the past has been Ralf Brown's excellent list. You can call me an old Dos hacker Windows is not my bag.


                                        Dave, thank you. I thought I had seen something like that somewhere.

                                        cheers.. aSa C[_]

                                        Comment

                                        Working...
                                        X