FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour select and evidence one line
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
select and evidence one line
Posted: Sat May 07, 2016 09:44 AM
I have a richedit control with n 9 lines

I wish select one line but not with the mouse but select by a listbox
and focus only that line I tried making a Colorizeline(nLine,oRtf) function but it not run ok

any solution please ?


Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "constant.ch"
#include "RichEdit.ch"

Function test()
Local oLbx
local oDlg
local oRtf
 Local cText:= "Test test test test test test test test test test test test "+CRLF+;
                    "Test test test test test test test test test test test test"+CRLF+;
                    "Test test test test test test test test test test test"+CRLF+;
                    "Test test test test test test test test test test"+CRLF+;
                    "Test test test test test test test test test "+CRLF+;
                    "Test test test test test test test test test "+CRLF+;
                    "Test test test test test test test"+CRLF+;
                    "Test test test test test test test"+CRLF+;
                    "Test test test test test test test"
      local uTemp := If( ! Empty( cText ), cText, '' )
      Local  nBottom_c   := 15
      Local  nRight_c    := 75
      Local  nWidth_c :=  Max( nRight_c * DLG_CHARPIX_W, 180 )
      Local  nHeight_c := nBottom_c * DLG_CHARPIX_H
      Local hDLL
      local  alevel := {"1","2","3","4","5","6","7","8","9"}
      local nlevel := 1
       Local oFontPreview:=TFont():New( GetSysFont(), -3, 5)


 DEFINE DIALOG oDlg FROM 6, 6 TO 37, 71 ;
      TITLE "test :"


 oDlg:lTruePixel   := .f.

 hDLL  = LoadLibrary( "Riched20.dll"  )

 @ 15, 71 RICHEDIT oRtf VAR uTemp OF oDlg PIXEL SIZE 175, 90 FONT oFontPreview  NOBORDER  NO SCROLL

 @ 1,1 LISTBOX oLbx VAR nlevel ITEMS alevel  OF oDlg size 20,100;
               on change (    oRtf:goto( nlevel) , ;
                                   Colorizeline(nLevel,oRtf)  )



ACTIVATE DIALOG oDlg CENTER 
     oFontPreview:End()

   if hDLL != nil
      FreeLibrary( hDLL )
   endif
return nil 

//--------------------------------------------------------------------//

Function Colorizeline(nLine,oRtf)
   oRtf:goto( nLine)
   for nLine := 0 to nline
      oRtf:HighLightLine( nLine )
       SysRefresh()
    next
    return ni
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: select and evidence one line
Posted: Sun May 08, 2016 09:52 AM
Antonio,
I saw it run ok on Window
when we use a dialog it not run ok
please try this test :

On Window ( run but run bad , before select one line then select the middle on line up and middle of line down)

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "constant.ch"
#include "RichEdit.ch"
#define CRLF1 Chr( 10 )



Function test()

   local oLbx
   local oDlg
   local oRtf
   local cText:= "Test test test test test test test test test test test test " + CRLF +;
                 "Test test test test test test test test test test test test" + CRLF +;
                 "Test test test test test test test test test test test" + CRLF +;
                 "Test test test test test test test test test test" + CRLF +;
                 "Test test test test test test test test test " + CRLF +;
                 "Test test test test test test test test test " + CRLF +;
                 "Test test test test test test test" + CRLF +;
                 "Test test test test test test test" + CRLF +;
                 "Test test test test test test test"

   local cText1
   local uTemp       := If( ! Empty( cText ), cText, "" )
   local nBottom_c   := 15
   local nRight_c    := 75
   local nWidth_c :=  Max( nRight_c * DLG_CHARPIX_W, 180 )
   local nHeight_c := nBottom_c * DLG_CHARPIX_H
   local hDLL
   local alevel := {"1","2","3","4","5","6","7","8","9"}
   local nlevel := 1
   local oFontPreview:=TFont():New( GetSysFont(), -3, 5)



   DEFINE WINDOW oDlg FROM 6, 6 TO 37, 71 TITLE "test :"

   //oDlg:lTruePixel   := .f.



   hDLL  = LoadLibrary( "Msftedit.dll" ) //"Riched20.dll"  )   //
 // hDLL  = LoadLibrary( "Riched20.dll" ) //"Riched20.dll"  )


   @ 15, 60 RICHEDIT oRtf VAR uTemp OF oDlg PIXEL SIZE 425, 410 FONT oFontPreview  NO SCROLL NOBORDER

   @ 15, 10 LISTBOX oLbx VAR nlevel ITEMS alevel  OF oDlg size 40, 160  PIXEL ;
         ON CHANGE ( SelectLine( nlevel,oRtf ),oRtf:setfocus()  )

   ACTIVATE WINDOW oDlg CENTER ;
   on init oLbx:setfocus()
   oFontPreview:End()

   if hDLL != nil
      FreeLibrary( hDLL )
   endif

return nil

//--------------------------------------------------------------------//



//----------------------------------------------------------------------------//
Function     SelectLine( nRow,oRtf )

   local   nCol   := oRtf:GetCol()
   if !Empty( nRow )
      oRtf:GoToLine( nRow - 1 )
   endif
   DEFAULT nRow   := oRtf:GetRow()
   nRow    := Min( nRow, oRtf:GetLineCount() )
   oRtf:SetPos( oRtf:GetPos() - ( nCol - 1 ) )
   oRtf:SetSel( oRtf:GetPos(), oRtf:GetPos() + Len( oRtf:GetLine( nRow ) ) )  // - 1
     //oRTF:SetFocus()
   Return nil
//----------------------------------------------------------------------------//




Dialog


Code (fw): Select all Collapse
 
#include "FiveWin.ch"
#include "constant.ch"
#include "RichEdit.ch"
#define CRLF1 Chr( 10 )



Function test()

   local oLbx
   local oDlg
   local oRtf
   local cText:= "Test test test test test test test test test test test test " + CRLF +;
                 "Test test test test test test test test test test test test" + CRLF +;
                 "Test test test test test test test test test test test" + CRLF +;
                 "Test test test test test test test test test test" + CRLF +;
                 "Test test test test test test test test test " + CRLF +;
                 "Test test test test test test test test test " + CRLF +;
                 "Test test test test test test test" + CRLF +;
                 "Test test test test test test test" + CRLF +;
                 "Test test test test test test test"

   local cText1
   local uTemp       := If( ! Empty( cText ), cText, "" )
   local nBottom_c   := 15
   local nRight_c    := 75
   local nWidth_c :=  Max( nRight_c * DLG_CHARPIX_W, 180 )
   local nHeight_c := nBottom_c * DLG_CHARPIX_H
   local hDLL
   local alevel := {"1","2","3","4","5","6","7","8","9"}
   local nlevel := 1
   local oFontPreview:=TFont():New( GetSysFont(), -3, 5)



   DEFINE DIALOG oDlg FROM 6, 6 TO 37, 71 TITLE "test :"

   //oDlg:lTruePixel   := .f.



   hDLL  = LoadLibrary( "Msftedit.dll" ) //"Riched20.dll"  )   //
 // hDLL  = LoadLibrary( "Riched20.dll" ) //"Riched20.dll"  )


   @ 15, 60 RICHEDIT oRtf VAR uTemp OF oDlg PIXEL SIZE 425, 410 FONT oFontPreview  NO SCROLL NOBORDER

   @ 15, 10 LISTBOX oLbx VAR nlevel ITEMS alevel  OF oDlg size 40, 160  PIXEL ;
         ON CHANGE ( SelectLine( nlevel,oRtf ),oRtf:setfocus()  )

   ACTIVATE DIALOG oDlg CENTER ;
   on init oLbx:setfocus()
   oFontPreview:End()

   if hDLL != nil
      FreeLibrary( hDLL )
   endif

return nil

//--------------------------------------------------------------------//



//----------------------------------------------------------------------------//
Function     SelectLine( nRow,oRtf )

   local   nCol   := oRtf:GetCol()
   if !Empty( nRow )
      oRtf:GoToLine( nRow - 1 )
   endif
   DEFAULT nRow   := oRtf:GetRow()
   nRow    := Min( nRow, oRtf:GetLineCount() )
   oRtf:SetPos( oRtf:GetPos() - ( nCol - 1 ) )
   oRtf:SetSel( oRtf:GetPos(), oRtf:GetPos() + Len( oRtf:GetLine( nRow ) ) )  // - 1
     //oRTF:SetFocus()
   Return nil
//----------------------------------------------------------------------------//



we not understood why on Dialog not run !!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: select and evidence one line
Posted: Sun May 08, 2016 11:41 AM

Silvio,

windows and dialogs use different low level procedures

FWH uses standard Windows API Dialogs procedures

I guess that the difference comes from there. I have not been able to solve it

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion