Clipper On Line • Ver Tópico - Função para localizar um texto em um richedit

Função para localizar um texto em um richedit

Projeto HwGui - Biblioteca visual para Harbour/xHarbour

Moderador: Moderadores

 

Função para localizar um texto em um richedit

Mensagempor asimoes » 28 Ago 2013 08:57

Pessoal,
´
O objetivo da função é um preview de relatório, nesta função tem uma função busca_texto que destaca o texto encontrado em vermelho.
A divisão do preview é por página(s).

Se alguém precisar dos icones e avi me informem.

Aceito criticas se não estiver bom.

[]s

*----------------------------------------------------------------------------*
* Programa____: VIEWREPORT.PRG                                               *
*                                                                            *
* Linguagem___: Harbour                                                      *
*                                                                            *
* LIB Gráfica_: HWGUI                                                        *
*                                                                            *
* Programador_: Alexandre Simões                                             *
*                                                                            *
* Data________: 2013/08                                                      *
*----------------------------------------------------------------------------*
* Atualizações:                                                              *
*----------------------------------------------------------------------------*
* Procedures__:                                                              *
* Funções_____: ViewReport(cArq)                                             *
*               TopoDoc()                                                    *
*               ImprimeRaw(cArqImp)                                          *
*               ZoomRep(oEdt,cSize)                                          *
*               Busca_Texto(oEdit)                                           *
*               PaginaInicio(aTexto, oDlgReport)                             *
*               PaginaFim(aTexto, oDlgReport )                               *
*               PaginaAnterior( nPage, aTexto, oDlgReport )                  *
*               PaginaSeguinte(oPage, nPage, aTexto, oDlgReport )            *
*               Status(This,aTexto)                                          *
*               TopoDoc()                                                    *
*               ZoomRep(oEdt,cSize,oDlgReport)                               *
*               RichEditProc( oEdit, Msg, wParam, lParam )                   *
*               MsgGet( cTitle, cText, nStyle, x, y, nDlgStyle, cResIni )    *
*               Reformata(cTexto)                                            *
*----------------------------------------------------------------------------*
* Objetivo____: Visualizar relatórios do tipo texto em janela gráfica gerados*
*               pelo harbour.                                                *
* Observações_:                                                              *
*----------------------------------------------------------------------------*
#include "windows.ch"
#include "hwgui.ch"
#include "common.ch"
#include "guilib.ch"

#define ID_TEXTO    300
#define IDC_STATUS 2001

FUNCTION ViewReport(cArq)
LOCAL oFont, oFont2
LOCAL cText       :=FileStr(cArq)

LOCAL oIconSair    :=HIcon():AddFile("P:\GERAL\HARBOUR\SAIR.ICO")
LOCAL oIconPrint   :=HIcon():AddFile("P:\GERAL\HARBOUR\RELATORIO.ICO")
LOCAL oIconZoomIn  :=HIcon():AddFile("P:\GERAL\HARBOUR\ZOOMIN.ICO")
LOCAL oIconZoomOut :=HIcon():AddFile("P:\GERAL\HARBOUR\ZOOMOUT.ICO")
LOCAL oIconSeguinte:=HIcon():AddFile("P:\GERAL\HARBOUR\ISEGUINTE.ICO")
LOCAL oIconAnterior:=HIcon():AddFile("P:\GERAL\HARBOUR\IANTERIOR.ICO")
LOCAL oIconPrimeiro:=HIcon():AddFile("P:\GERAL\HARBOUR\IPRIMEIRO.ICO")
LOCAL oIconUltimo  :=HIcon():AddFile("P:\GERAL\HARBOUR\IULTIMO.ICO")
LOCAL oIconLupa    :=HIcon():AddFile("P:\GERAL\HARBOUR\ILUPA.ICO")
LOCAL aTexto:={""}, nPage:=1, oPage:=1
LOCAL oDlg_Rel
PRIVATE oDlgReport, n_IniPos:=0, n_FimPos:=0
PRIVATE aBusca:={}

   oDlg_Rel:=DlgWait( "Gerando o Relatório", "Aguarde...","PROCESS32_32.AVI")
   //inkey(0)

   FT_FUSE( cArq )
   
   DO WHILE !FT_FEOF()
      cLinha:=FT_FREADLN()
      lEject:=(Chr(12) $ cLinha)
      lEscape:=(Chr(27) $ cLinha)
      cLinha:=StrTran( cLinha, Chr(12)) // Elimina caracter EJECT
      cLinha:=Reformata(cLinha)
      IF FT_FRECNO() = 1
         IF Empty(cLinha) //.AND. lEscape
            FT_FSKIP()
            LOOP
         ENDIF
      ENDIF
      aTexto[oPage]+=cLinha + Chr( 13 ) + Chr( 10 )
      IF lEject
         AADD(aTexto,"")
         oPage++
      ENDIF
      FT_FSKIP()
   ENDDO
   
   FT_FUSE()

   IF Empty(aTexto[oPage])
      hb_ADel( aTexto, oPage, .T. )
      oPage--
   ENDIF
   
   cText:=aTexto[ nPage ]

   nSizeFont:=-13
   
   PREPARE FONT oFont NAME "Arial" WIDTH 0 HEIGHT 0 WEIGHT -10
   
   oFont2:=HFont():Add( "Courier New" ,0,-13, 0,,, )

   SetToolTipBalloon(.T.)
   
   oDlg_Rel:Close()

   INIT DIALOG  oDlgReport TITLE "Visualização do Relatório" ;
        ICON    oIconPrint ;
        AT      0,0 SIZE nWIDTH-50,nHEIGHT-50 ;
        CLIPPER;
        FONT    oFont ;
        COLOR   15048208 ;
        STYLE DS_CENTER + WS_SYSMENU + WS_VISIBLE ;
        ON INIT {| oDlgReport | oDlgReport:nInitFocus:=btnSair}

        //ON INIT {| oDlgReport | oDlgReport:nInitFocus:=btnSair,PaginaInicio(aTexto, oDlgReport)}
       
   @ 127,019 RichEdit  oEdit TEXT cText SIZE nWIDTH-192,nHEIGHT-130 ;
             OF        oDlgReport ID ID_TEXTO ;
             COLOR     16711680 ;
             BACKCOLOR 15724484 ;
             STYLE     WS_HSCROLL+WS_VSCROLL+ES_LEFT+ES_MULTILINE+ES_READONLY ;
             ON        GETFOCUS {|| TopoDoc()};
             FONT      oFont2 ;
             ON OTHERMESSAGES {|This,m,wp,lp| richeditProc( this, m,wp, lp ) }             

             //oEdit:bOther := {|o,m,wp,lp|richeditProc(o,m,wp,lp)}

   @ 006,020 BUTTONEX cmd1 ;
             CAPTION  " - Zoom" ;
             ON CLICK { || ZoomRep(oEdit,'-',oDlgReport)} ;
             SIZE     115, 40 ;
             ICON     oIconZoomOut:handle  ;
             TOOLTIP  'Clique aqui para diminuir.'
   
   @ 006,070 BUTTONEX cmd2 ;
             CAPTION  " + Zoom" ;
             ON CLICK { || ZoomRep(oEdit,'+',oDlgReport)} ;
             SIZE     115, 40 ;
             ICON     oIconZoomIn:handle  ;
             TOOLTIP 'Clique aqui para ampliar.'
   
   @ 006,120 BUTTONEX cmd3 ;   
             CAPTION  "Primeira" ;
             ON CLICK { || nPage:=PaginaInicio( aTexto, oDlgReport ) } ;
             SIZE     115, 40 ;
             ICON     oIconPrimeiro:handle ;
             TOOLTIP 'Clique aqui para ir para primeira página.'

   @ 006,170 BUTTONEX cmd4 ;
             CAPTION  "Anterior" ;
             ON CLICK { || nPage:= PaginaAnterior( nPage, aTexto, oDlgReport ) } ;
             SIZE     115, 40 ;
             ICON oIconAnterior:handle ;
             TOOLTIP 'Clique aqui para ir para página anterior.'

   @ 006,220 BUTTONEX cmd5 ;   
             CAPTION  "Seguinte" ;
             ON CLICK { || nPage:= PaginaSeguinte( oPage, nPage, aTexto, oDlgReport ) } ;
             SIZE     115, 40 ;
             ICON     oIconSeguinte:handle ;
             TOOLTIP 'Clique aqui para ir para página seguinte.'
 
   @ 006,270 BUTTONEX cmd6 ;   
             CAPTION  "Última" ;
             ON CLICK { || nPage:=PaginaFim( aTexto, oDlgReport ) } ;
             SIZE     115, 40 ;
             ICON     oIconUltimo:handle ;
             TOOLTIP 'Clique aqui para ir para última página.'

   @ 006,320 BUTTONEX cmd7 ;
             CAPTION  "&Busca" ;
             ON CLICK { || Busca_Texto(oEdit,aTexto,oDlgReport)} ;
             SIZE     115, 40 ;
             ICON     oIconLupa:handle ;
             TOOLTIP 'Clique aqui localizar um texto.'
             
             //ON CLICK { || FocoRichEdit(oEdit),Busca_Texto(oEdit,aTexto,oDlgReport)} ;

   @ 006,370 BUTTONEX cmd8 ;
             CAPTION  "Imprimir" ;
             ON CLICK { || IF(MsgYesNo("Confirma a impressão?","Atenção"),ImprimeRaw((cArq)),)} ;
             SIZE     115, 40 ;
             ICON     oIconPrint:handle ;
             FONT     oFont ;
             TOOLTIP 'Clique aqui para imprimir.'

   @ 006,420 BUTTONEX btnSair ;
             CAPTION  "&Sair" ;
             ON CLICK { || EndDialog()} ;
             SIZE     115, 40 ;
             ICON     oIconSair:handle ;
             TOOLTIP 'Clique aqui para sair.'

   ADD STATUS oStatus TO oDlgReport PARTS 100,100,100,180,0 ON INIT {|This| Status(This,aTexto) }   
   
   oDlgReport:Activate() // Parâmetro .T. = NOMODAL, .F. ou () = MODAL

RETURN Nil

STATIC FUNCTION FocoRichEdit(oEdit)
   oEdit:SetFocus()
   SendMessage( oEdit:handle, EM_SETSEL, n_IniPos, n_FimPos )
RETUR Nil

STATIC FUNCTION Busca_Texto(oEdit,aTexto,oDlgReport)
LOCAL oDlg       :=GetModalHandle()
LOCAL cBusca     :=''
LOCAL nStartFind :=0
LOCAL lCase      :=.F.
LOCAL nPos       :=1
LOCAL I
LOCAL cRes
LOCAL nResulta   :=0
   
   cBusca:=MsgGet("Pesquisa de Texto","Informe o que deseja encontrar:")
   
   FOR I:=1 TO Len(aTexto)
       nSearch1:=AT(Upper(cBusca),Upper(aTexto[i]))
       IF nSearch1 > 0
           //nSearch2:=ASCAN(aBusca,{|a| a[1] == cBusca + Str(I) })
           //IF nSearch2 = 0
           //   AADD(aBusca,{cBusca+Str(I),I})
           //ENDIF
           nResulta:=I
           EXIT                   
       ENDIF
       hwg_doevents()
   NEXT

   IF nResulta > 0
      cTexto:=aTexto[ nResulta ]
      SetDlgItemText( oDlg, ID_TEXTO, HB_OEMTOANSI(cTexto) )
      WriteStatus( oDlgReport,4,'Página: '+LTrim(Str(nResulta,6))+" de "+LTrim(Str(Len(aTexto),6)))
   ENDIF
   
   nPos:=RE_FindText(oEdit:handle, cBusca, nStartFind, lCase)
   
   oEdit:SetColor(16711680)

   DO WHILE (nPos:=RE_FindText(oEdit:handle, cBusca, nStartFind, lCase)) > 0
      n_IniPos:=nPos
      n_FimPos:=nPos+Len(cBusca)
      oEdit:SetFocus()
      SendMessage( oEdit:handle, EM_SETSEL, n_IniPos, n_FimPos )
      re_SetCharFormat( oEdit:handle, { {n_IniPos+1,n_FimPos+1,,,,.T. }, { n_IniPos+1,n_FimPos+1,255,,,.T.,,.F. } } )
      SendMessage(oEdit:handle, EM_SETSEL, -1, 0 )
      nStartFind:=nPos+Len(cBusca)+1
   ENDDO
   
   IF nPos = 0 .AND. !Empty(cBusca)
      MsgInfo('Não foi possível encontrar o texto: '+cBusca+'.','Atenção')
   ENDIF
   
RETURN .T.

STATIC FUNCTION PaginaInicio(aTexto, oDlgReport)
LOCAL oDlg:=GetModalHandle()
   cTexto:=aTexto[ 1 ]
   Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI(cTexto) )
   WriteStatus( oDlgReport,4,'Página: '+LTrim(Str(1,6))+" de "+LTrim(Str(Len(aTexto),6)))
RETURN 1

STATIC FUNCTION PaginaFim(aTexto, oDlgReport )
LOCAL oDlg:=GetModalHandle(), nUltimaPag:=Len(aTexto)
   cTexto:=aTexto[ nUltimaPag ]
   IF Empty(cTexto)
      cTexto:=""   
   ENDIF
   Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI(cTexto) )
   WriteStatus( oDlgReport,4,'Página: '+LTrim(Str(nUltimaPag,6))+" de "+LTrim(Str(nUltimaPag,6)))
RETURN nUltimaPag

STATIC FUNCTION PaginaAnterior( nPage, aTexto, oDlgReport )
LOCAL oDlg:=GetModalHandle()
   nPage := -- nPage
   IF nPage < 1 ; nPage := 1 ; ENDIF
   cTexto:=aTexto[ nPage ]
   Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI(cTexto) )
   WriteStatus( oDlgReport,4,'Página: '+LTrim(Str(nPage,6))+" de "+LTrim(Str(Len(aTexto),6)))
RETURN nPage

STATIC FUNCTION PaginaSeguinte(oPage, nPage, aTexto, oDlgReport )
LOCAL oDlg:=GetModalHandle()
   nPage := ++ nPage
   IF nPage > oPage ; nPage := oPage ; ENDIF
   cTexto:=aTexto[ nPage ]
   IF Empty(cTexto)
      cTexto:=""   
   ENDIF
   Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI(cTexto) )
   WriteStatus( oDlgReport,4,'Página: '+LTrim(Str(nPage,6))+" de "+LTrim(Str(Len(aTexto),6)))
RETURN nPage

STATIC FUNCTION Reformata(cTexto)
LOCAL cText:=cTexto
   cText:=StrTran(cText,Chr(27)+"P"+Chr(15))
   cText:=StrTran(cText,Chr(12),Chr(13)+Chr(13))
   cText:=StrTran(cText,Chr(27)+"P")
   cText:=StrTran(cText,Chr(27)+Chr(77)+Chr(15))
   cText:=StrTran(cText,Chr(27)+Chr(77)+Chr(18))
   cText:=StrTran(cText,Chr(27)+Chr(80)+Chr(18))
   cText:=StrTran(cText,Chr(15))
   cText:=StrTran(cText,Chr(18))
   cText:=StrTran(cText,"%0A(s0p15h0s0b4102T")
   cText:=StrTran(cText,"%0A(s0p10h0s0b4099T")
   
RETURN cText

STATIC FUNCTION Status(This,aTexto)
   This:settextpanel(2,'Lin:'+Str(1,6))
   This:settextpanel(3,'Col:'+Str(1,6))
   This:settextpanel(4,'Página: '+LTrim(Str(1,6))+" de "+LTrim(Str(Len(aTexto),6)))
RETURN Nil

STATIC FUNCTION TopoDoc()
   SendMessage(oEdit:Handle, WM_VSCROLL  ,SB_TOP,0)
   SendMessage(oEdit:Handle, EM_SETSEL  ,0,0)
RETURN .T.

STATIC FUNCTION ZoomRep(oEdt,cSize,oDlgReport)
   IF cSize='+' ; WriteStatus(oDlgReport,1,'+ Zoom'); ELSE ; WriteStatus(oDlgReport,1,''); ENDIF
   nSizeFont+=nSizeFont + IIF(cSize='+', 1 , -1)
   nSizeFont:=IIF(cSize='+',Min(-9,nSizeFont),Max(-13,nSizeFont))
   oFont2:=HFont():Add( "Courier New",0,nSizeFont )
   SendMessage(oEdit:Handle,WM_SETFONT ,oFont2:handle,0 )
   oEdit:SetColor(16711680)
   oEdit:Refresh()
RETURN .T.

STATIC FUNCTION RichEditProc( oEdit, Msg, wParam, lParam )
   IF Msg == WM_KEYUP .OR. Msg == WM_KEYDOWN .OR. Msg == WM_LBUTTONDOWN .OR. Msg == WM_SYSKEYDOWN
      nColuna:=Loword(SendMessage(oEdit:Handle, EM_GETSEL, 0, 0))
      nLinha :=SendMessage(oEdit:Handle, EM_LINEFROMCHAR, nColuna, 0) + 1
      nColuna:=nColuna - SendMessage(oEdit:Handle, EM_LINEINDEX, -1, 0) + 1
      //
      WriteStatus( oDlgReport,2,'Lin:'+Str(nLinha,6))
      WriteStatus( oDlgReport,3,'Col:'+Str(nColuna,6))
      oEdit:Refresh()
   ENDIF
RETURN -1

STATIC FUNCTION MsgGet( cTitle, cText, nStyle, x, y, nDlgStyle, cResIni )
LOCAL oModDlg, oFont := HFont():Add( "MS Sans Serif", 0, - 13 )
LOCAL cRes := IIf( cResIni != Nil, Trim( cResIni ), "" )
LOCAL oIconOk      :=HIcon():AddFile("P:\GERAL\HARBOUR\IOK.ICO")
LOCAL oIconCancela :=HIcon():AddFile("P:\GERAL\HARBOUR\ICANCELA.ICO")
   
   nStyle := IIf( nStyle == Nil, 0, nStyle )
   x := IIf( x == Nil, 210, x )
   y := IIf( y == Nil, 10, y )
   nDlgStyle := IIf( nDlgStyle == Nil, 0, nDlgStyle )

   INIT DIALOG oModDlg TITLE cTitle At x, y SIZE 300, 140 ;
        FONT oFont CLIPPER ;
        STYLE DS_CENTER+ WS_POPUP + WS_VISIBLE + WS_CAPTION + WS_SYSMENU + WS_SIZEBOX + nDlgStyle

   @ 20, 10 SAY cText SIZE 260, 22
   @ 20, 35 GET cRes  SIZE 260, 26 STYLE WS_TABSTOP + ES_AUTOHSCROLL + nStyle
   oModDlg:aControls[ 2 ]:Anchor := ANCHOR_TOPABS + ANCHOR_LEFTABS + ANCHOR_RIGHTABS
   
   @ 20, 95 BUTTONEX "Ok" ID IDOK SIZE 115, 40 ICON oIconOk:handle TOOLTIP 'Clique aqui para iniciar a pesquisar.'
   oModDlg:aControls[ 3 ]:Anchor := ANCHOR_BOTTOMABS
   
   @ 168,95 BUTTONEX "Cancelar" ID IDCANCEL SIZE 115, 40 ICON oIconCancela:handle TOOLTIP 'Clique aqui para cancelar a pesquisa.'
   oModDlg:aControls[ 4 ]:Anchor := ANCHOR_RIGHTABS + ANCHOR_BOTTOMABS

   ACTIVATE DIALOG oModDlg ON ACTIVATE { || IIF( ! Empty( cRes ), KEYB_EVENT( VK_END ), .T. ) }

   oFont:Release()
   
   IF oModDlg:lResult
      RETURN Trim( cRes )
   ELSE
      cRes := ""
   ENDIF

RETURN cRes

STATIC FUNCTION DlgWait( cTitle, cMensagem_Wait, cArqVideo )
LOCAL oDlg_Wait, oLabel_Wait
LOCAL oIconWait:=HIcon():AddFile("P:\GERAL\HARBOUR\IAMPULHETA.ICO")
LOCAL lAutoPlay:=.T., lCenter:=.T., lTransparent:=.T.
DEFAULT cArqVideo TO "P:\GERAL\HARBOUR\LOADER.AVI"

   cRes:=""
   
   INIT DIALOG oDlg_Wait TITLE cTitle ;
         ICON oIconWait ;
         AT 0,0 ;
         SIZE 350,90  STYLE DS_CENTER + WS_SYSMENU //90

   @ 10,10 ANIMATION SIZE 30, 30 AUTOPLAY CENTER TRANSPARENT FILE cArqVideo
   
   @ 50,20 SAY oLabel_Wait CAPTION cMensagem_Wait SIZE 200,19

   ACTIVATE DIALOG oDlg_wait NOMODAL
   
RETURN oDlg_Wait

FUNCTION AberturaAvi( cArqVideo, cTitle )
LOCAL oDlg_Wait, oCtrl, oWait
LOCAL lAutoPlay:=.T., lCenter:=.T., lTransparent:=.F.
DEFAULT cArqVideo TO "",;
        cTitle    TO ""

   INIT DIALOG oDlg_Wait TITLE cTitle ;
         AT 0,0 ;
         CLIPPER;
         SIZE 737,518  STYLE DS_CENTER + WS_VISIBLE

   oCtrl:=HAnimation():New( oDlg_Wait, , , 5, 5, 720, 480, cArqVideo, lAutoPlay, lCenter, lTransparent )
 
   oDlg_Wait:Activate()
   
RETURN oDlg_Wait

PROCEDURE Fim( oControl1,oControl2 )
 
  oControl2:End()
  oControl1:Close()
  oControl1:Destroy()
  EndDialog()

RETURN

STATIC FUNCTION ImprimeRaw(cArqImp)
LOCAL cMsg:="", nRet, cPrinter:=WIN_PrinterGetDefault(), oDlg_Rel
      oDlg_Rel:=DlgWait( "Imprimindo o Relatório", "Aguarde...", "P:\GERAL\HARBOUR\IMPRESSORA.AVI" )
      nRet:=WIN_PrintFileRaw(cPrinter,cArqImp,'REPORT_PREVIEW')
      oDlg_Rel:Close()
RETURN Nil

â–ºHarbour 3.x | Minigui xx-x | HwGuiâ—„
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar de usuário

asimoes
Colaborador

Colaborador
 
Mensagens: 4919
Data de registro: 26 Abr 2007 16:48
Cidade/Estado: RIO DE JANEIRO-RJ
Curtiu: 341 vezes
Mens.Curtidas: 258 vezes

Função para localizar um texto em um richedit

Mensagempor HASA » 16 Set 2013 18:01

Boa tarde ASimoes, tentei compilar com Harbour 3.2, e não consegui da varios erros, vc teria um pequeno exemplo em harbour puro ?
:D
HASA
Avatar de usuário

HASA
Colaborador

Colaborador
 
Mensagens: 1082
Data de registro: 01 Set 2003 19:50
Cidade/Estado: São Paulo
Curtiu: 1 vez
Mens.Curtidas: 51 vezes

Função para localizar um texto em um richedit

Mensagempor asimoes » 16 Set 2013 19:40

Olá Hasa,

Por favor me informe qual é a sua versão da hwgui e se possível os erros.
â–ºHarbour 3.x | Minigui xx-x | HwGuiâ—„
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar de usuário

asimoes
Colaborador

Colaborador
 
Mensagens: 4919
Data de registro: 26 Abr 2007 16:48
Cidade/Estado: RIO DE JANEIRO-RJ
Curtiu: 341 vezes
Mens.Curtidas: 258 vezes

Função para localizar um texto em um richedit

Mensagempor HASA » 17 Set 2013 09:41

8-|

Na verdade não uso HWGUI por isso tentei recriar a funcionalidae em D.O.S.
:-O
HASA
Avatar de usuário

HASA
Colaborador

Colaborador
 
Mensagens: 1082
Data de registro: 01 Set 2003 19:50
Cidade/Estado: São Paulo
Curtiu: 1 vez
Mens.Curtidas: 51 vezes

Função para localizar um texto em um richedit

Mensagempor asimoes » 17 Set 2013 10:12

Hasa, sendo o exemplo que utiliza funcionalidades da hwgui, obrigatoriamente deve ser usado a hwgui.

Este é o código para testar a visualização do relatório.

Script para compilar o exemplo utilizando harbour + msvc 32
#---------------------------
# Nome do Executável
# ---------------------------
-orelatorio
# ---------------------------
# Bibliotecas
# ---------------------------
-lhwgui
-lprocmisc
-lhbactivex
-lhbct
-lhbgt
-lgtwvg
-lgtwvt
-lhbwin
-lhbnf
-lhbtip
-lxhb
# ---------------------------
# Caminhos dos Includes
# ---------------------------
-incpath=D:\HARBOUR32_MSVC\hwgui\include;
# ---------------------------
# Caminho das Libs da HwGui
# ---------------------------
-LD:\HARBOUR32_MSVC\hwgui\lib;
# ---------------------------
# Outros Parâmetros
# ---------------------------
-mt
-workdir=.\OBJMSVC\
-gtgui
-head=full
-n
-warn=no
-inc
#Para compactar o executável.
#-compr
-b
-dHARBOUR_MSVC
# ---------------------------
# Prg(s) e Rc(s)
# ---------------------------
RELATORIO.PRG
VIEWREPORT.PRG

* --------------------------------------------------------------
* Programa...: RELATORIO.PRG
* Finalidade.: Gerar testes de impressão
* Autor......: Alexandre Simões
* Data.......: 09/2013
* --------------------------------------------------------------
* Manutenção atual por: Alexandre Simões (SET/2013 A XXX/XXXX)
* Código migrado para Harbour (32Bit)
* --------------------------------------------------------------
* Compilador : MSVC (32-bit)
* --------------------------------------------------------------
#include "inkey.ch"
#include "setcurs.ch"
#include "error.ch"
#include "achoice.ch"
#include "fileio.ch"
#include "common.ch"
#include "dbinfo.ch"
#include "hbver.ch"
#include "hbdyn.ch"
#include "wvtwin.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvgparts.ch"
#include "hbcompat.ch"
#include "windows.ch"

FUNCTION MAIN
PUBLIC cArqPrint
 
  cSaida:=" "
  //a=b
   DO WHILE .T.
      IF SaidaImp(@cSaida,{"T","I"}) $ " IT"
         SWITCH cSaida
         CASE " "
            QUIT
         CASE "I"
            //CTImpressao(.T.)
            IniPrint(.T.,80,"PCL")
            FT_FUSE( "TESTE.TXT" )
            DO WHILE !FT_FEOF()
               cLinha:=FT_FREADLN()
               @ PRow()+1,000 SAY cLinha
               nLinha:=1
               FT_FSKIP()
            ENDDO
            FT_FUSE()
            IniPrint(.F.)
            //CTImpressao(.F.)
            //ImprimeRaw((cArqPrint))
            EXIT
         CASE "T"
            cArqPrint:="TESTE.TXT" //QUALQUER ARQUIVO TEXTO PARA TESTAR
            ViewReport(HB_OEMTOANSI((cArqPrint)))
            EXIT
         ENDSWITCH
      ENDIF
   ENDDO
RETURN Nil

INIT FUNCTION AppSetup()
 
  REQUEST HB_LANG_PT
  REQUEST HB_CODEPAGE_PT850
  HB_LANGSELECT("PT")
  HB_CDPSELECT( "PT850" )

  REQUEST DBFCDX

  RddSetDefault("DBFCDX")

  SETMODE(25,80)
  SET TYPEAHEAD TO 0
  SET INTENSITY ON
  SET SCOREBOARD OFF
  SET DELETED ON
  SET SAFETY OFF
  SET ESCAPE ON
  SET CENTURY ON
  SET DELIMITERS TO
  SET EXCLUSIVE OFF
  SET WRAP ON
  SET EPOCH TO 1920
  SET OPTIMIZE ON
  SET AUTOPEN ON
  SET DBFLOCKSCHEME TO DB_DBFLOCK_DEFAULT
  SET MESSAGE TO 24 CENTER
 
  CLS
 
  ColorWin(0,0,MaxRow(),MAxCol(),"W+/B")
 
  IniciaJanela()

RETURN Nil

FUNCTION IniciaJanela(nLi,nCi,nLf,nCf)

PUBLIC nWIDTH, nHEIGHT

  HB_Default(@nLi,0)
  HB_Default(@nCi,0)
  HB_Default(@nLf,MaxRow())
  HB_Default(@nCf,MaxCol())
 
  cTituloJanela:="TESTE DE IMPRESSÃO"

  HB_gtInfo(HB_GTI_FONTNAME, "Lucida Console")
  HB_gtInfo(HB_GTI_ICONRES, "ICON_001" )
  HB_gtInfo(HB_GTI_WINTITLE, cTituloJanela)
  HB_gtInfo(HB_GTI_CLOSABLE, .F. )
  HB_gtInfo(HB_GTI_CLIPBOARDDATA )
  HB_gtInfo(HB_GTI_SELECTCOPY, .T. )
  HB_gtInfo(HB_GTI_MOUSESTATUS, 1 )
  HB_gtInfo(HB_GTI_ISGRAPHIC, .T. )
  HB_gtInfo(HB_GTI_STDERRCON, .T. )
  HB_gtInfo(HB_GTI_COMPATBUFFER, .T. )
  HB_GtInfo(HB_GTI_MAXIMIZED, .T. )
  HB_gtInfo(HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED )
  //HB_GtInfo( HB_GTI_ISFULLSCREEN, .T. )
 
  nWIDTH :=hb_gtInfo( HB_GTI_SCREENWIDTH )
  nHEIGHT:=hb_gtInfo( HB_GTI_SCREENHEIGHT )
 
RETURN Nil

FUNCTION HB_GTSYS()
   REQUEST HB_GT_WVG_DEFAULT
   REQUEST HB_GT_WVT
   REQUEST HB_GT_WGU
   REQUEST HB_GT_WVG
RETURN Nil

FUNCTION CTImpressao(lInicia)

   HB_Default(@lInicia,.T.)

   IF lInicia
      cArqPrint:=Sys(".TXT")
      SET CONSOLE OFF
      SET DEVICE TO PRINT
      SET PRINTER TO &cArqPrint.
      SET PRINT ON
      SetPrc(0,0)
   ELSE
      SET PRINT OFF
      SET PRINTER TO
      SET DEVICE TO SCREEN
      SET CONSOLE ON
   ENDIF
RETURN Nil

FUNCTION SYS( cExtensao, Ini )
LOCAL cArqTmp,;
      cData,;
      nTmpHandle,;
      cDirTMP:=GetEnv("TEMP")+HB_PS()

   HB_Default(@Ini,"XT")
   HB_Default(@cExtensao,"")
   cArqTmp:=cDirTMP+Ini+StrZero(HB_Random(999999),6)+cExtensao
   DO WHILE .T.
      cFile  :=FileSeek(cArqTmp)
      lExiste:=.F.
      DO WHILE !Empty(cFile)
         cArqTmp:=cDirTMP+Ini+StrZero(HB_Random(999999),6)+cExtensao
         lExiste:=.T.
         IF !File(cArqTmp)
             lExiste:=.F.
             EXIT
         ENDIF
         cFile  :=FileSeek()
      ENDDO
      IF !lExiste
         nTmpHandle := FCreate(cArqTmp)
         IF nTmpHandle # - 1
            IF FClose(nTmpHandle)
               EXIT
            ENDIF
         ENDIF
      ENDIF
   ENDDO
RETURN (cArqTmp)
â–ºHarbour 3.x | Minigui xx-x | HwGuiâ—„
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar de usuário

asimoes
Colaborador

Colaborador
 
Mensagens: 4919
Data de registro: 26 Abr 2007 16:48
Cidade/Estado: RIO DE JANEIRO-RJ
Curtiu: 341 vezes
Mens.Curtidas: 258 vezes

Função para localizar um texto em um richedit

Mensagempor HASA » 17 Set 2013 10:30

:{

Obrigado, e quanto a FUNCTION Busca_Texto() é possivel migrar tbm ?, desculpe eu nem percebi que estava no forum de Hwgui é que pesquisei sobre o assunto e cliquei na sua mensagem com o fonte e só depois me dei conta ok.

HASA
:-O
Avatar de usuário

HASA
Colaborador

Colaborador
 
Mensagens: 1082
Data de registro: 01 Set 2003 19:50
Cidade/Estado: São Paulo
Curtiu: 1 vez
Mens.Curtidas: 51 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 16 Abr 2017 21:09

Estou tentando compilar este exemplo antigo, mas não vai.
Pelo menos com hwgui 2.20

d:\temp>hbmk2 test hwgui.hbc gtwvg.hbc hbwin.hbc hbtip.hbc xhb.hbc hbgt.hbc

test.obj : error LNK2001: unresolved external symbol _HB_FUN_KEYB_EVENT
test.obj : error LNK2001: unresolved external symbol _HB_FUN_LOWORD
test.obj : error LNK2001: unresolved external symbol _HB_FUN_MSGINFO
test.obj : error LNK2001: unresolved external symbol _HB_FUN_RE_SETCHARFORMAT
test.obj : error LNK2001: unresolved external symbol _HB_FUN_RE_FINDTEXT
test.obj : error LNK2001: unresolved external symbol _HB_FUN_WRITESTATUS
test.obj : error LNK2001: unresolved external symbol _HB_FUN_SETDLGITEMTEXT
test.obj : error LNK2001: unresolved external symbol _HB_FUN_GETMODALHANDLE
test.obj : error LNK2001: unresolved external symbol _HB_FUN_SENDMESSAGE
test.obj : error LNK2001: unresolved external symbol _HB_FUN_ENDDIALOG
test.obj : error LNK2001: unresolved external symbol _HB_FUN_MSGYESNO
test.obj : error LNK2001: unresolved external symbol _HB_FUN_SETTOOLTIPBALLOON
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Função para localizar um texto em um richedit

Mensagempor asimoes » 16 Abr 2017 21:35

Quintas,

tenta colocar o prefixo hwg_ no início das funções
â–ºHarbour 3.x | Minigui xx-x | HwGuiâ—„
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar de usuário

asimoes
Colaborador

Colaborador
 
Mensagens: 4919
Data de registro: 26 Abr 2007 16:48
Cidade/Estado: RIO DE JANEIRO-RJ
Curtiu: 341 vezes
Mens.Curtidas: 258 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 17 Abr 2017 00:12

deu certo colocar hwg_, mas depois deu este erro:

Error BASE/1003 Variable does not exist: NWIDTH

HWGUI 2.20 Build 3
Date:04/17/17
Time:00:01:51
Called from (b)HWG_ERRSYS(21)
Called from VIEWREPORT(117)
Called from MAIN(45)


Uma coisa interessante é compilando com -w3 -es2:
Ao que parece, agora hwgui.ch já inclui a windows.ch, e dispensa esse #include.
Abaixo apenas parcial, a lista é muito maior....

d:\cvsfiles\allgui\hwgui\include\windows.ch:1115: warning W0002 Redefinition or duplicate definition of #define MM_ANISOTROPIC
d:\cvsfiles\allgui\hwgui\include\windows.ch:1116: warning W0002 Redefinition or duplicate definition of #define AD_COUNTERCLOCKWISE
d:\cvsfiles\allgui\hwgui\include\windows.ch:1117: warning W0002 Redefinition or duplicate definition of #define AD_CLOCKWISE
d:\cvsfiles\allgui\hwgui\include\windows.ch:1118: warning W0002 Redefinition or duplicate definition of #define PS_COSMETIC
d:\cvsfiles\allgui\hwgui\include\windows.ch:1119: warning W0002 Redefinition or duplicate definition of #define PS_GEOMETRIC
d:\cvsfiles\allgui\hwgui\include\windows.ch:1120: warning W0002 Redefinition or duplicate definition of #define PS_TYPE_MASK
d:\cvsfiles\allgui\hwgui\include\windows.ch:1121: warning W0002 Redefinition or duplicate definition of #define R2_BLACK
d:\cvsfiles\allgui\hwgui\include\windows.ch:1122: warning W0002 Redefinition or duplicate definition of #define R2_NOTMERGEPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1123: warning W0002 Redefinition or duplicate definition of #define R2_MASKNOTPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1124: warning W0002 Redefinition or duplicate definition of #define R2_NOTCOPYPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1125: warning W0002 Redefinition or duplicate definition of #define R2_MASKPENNOT
d:\cvsfiles\allgui\hwgui\include\windows.ch:1126: warning W0002 Redefinition or duplicate definition of #define R2_NOT
d:\cvsfiles\allgui\hwgui\include\windows.ch:1127: warning W0002 Redefinition or duplicate definition of #define R2_XORPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1128: warning W0002 Redefinition or duplicate definition of #define R2_NOTMASKPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1129: warning W0002 Redefinition or duplicate definition of #define R2_MASKPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1130: warning W0002 Redefinition or duplicate definition of #define R2_NOTXORPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1131: warning W0002 Redefinition or duplicate definition of #define R2_NOP
d:\cvsfiles\allgui\hwgui\include\windows.ch:1132: warning W0002 Redefinition or duplicate definition of #define R2_MERGENOTPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1133: warning W0002 Redefinition or duplicate definition of #define R2_COPYPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1134: warning W0002 Redefinition or duplicate definition of #define R2_MERGEPENNOT
d:\cvsfiles\allgui\hwgui\include\windows.ch:1135: warning W0002 Redefinition or duplicate definition of #define R2_MERGEPEN
d:\cvsfiles\allgui\hwgui\include\windows.ch:1136: warning W0002 Redefinition or duplicate definition of #define R2_WHITE
d:\cvsfiles\allgui\hwgui\include\windows.ch:1137: warning W0002 Redefinition or duplicate definition of #define R2_LAST


Retirando o #include "windows.ch" essa lista de duplicados sumiu.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 17 Abr 2017 00:17

A propósito, ficaram só estes dois:

#include "hwgui.ch"
#include "hwg_extctrl.ch"
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 17 Abr 2017 04:03

Usei -w3 -es2
Eliminei variáveis inúteis, etc.
Sobraram duas pra resolver, que são usadas como referência ao tamanho da janela, mas que não tem valor nenhum, por isso dá erro na execução.

d:\temp>hbmk2 test hwgui.hbc -w3 -es2
hbmk2: Processing environment options: -comp=msvc
hbmk2: Processing configuration: d:\harbour\bin\hbmk.hbc
Harbour 3.4.0dev (5bb5f8cb04) (2017-04-08 11:17)
Copyright (c) 1999-2017, https://github.com/JoseQuintas/harbour-core/
Compiling 'test.prg'...
1000
test.prg:119: warning W0001 Ambiguous reference 'NWIDTH'

test.prg:119: warning W0001 Ambiguous reference 'NHEIGHT'

test.prg:130: warning W0001 Ambiguous reference 'NWIDTH'

test.prg:130: warning W0001 Ambiguous reference 'NHEIGHT'
400
No code generated.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 17 Abr 2017 09:02

Iniciei essas variáveis com 1920 e 1080, e fiz mais ajustes pra eliminar erros.
À primeira vista, agora está funcionando.

A título de curiosidade, como fica a mensagem de erro com minha errorsys.

hwgui1.png


O módulo em execução.

hwgui2.png


O fonte alterado, e também funcionando sozinho.

*----------------------------------------------------------------------------*
* Programa____: VIEWREPORT.PRG                       *
*                                      *
* Linguagem___: Harbour                           *
*                                      *
* LIB Gráfica_: HWGUI                            *
*                                      *
* Programador_: Alexandre Simões                      *
*                                      *
* Data________: 2013/08                           *
*----------------------------------------------------------------------------*
* Atualizações:                               *
*----------------------------------------------------------------------------*
* Procedures__:                               *
* Funções_____: ViewReport(cArq)                      *
*       TopoDoc( oEdit )                          *
*       ImprimeRaw(cArqImp)                     *
*       ZoomRep(oEdt,cSize)                     *
*       Busca_Texto(oEdit)                     *
*       PaginaInicio(aTexto, oDlgReport)              *
*       PaginaFim(aTexto, oDlgReport )               *
*       PaginaAnterior( nPage, aTexto, oDlgReport )         *
*       PaginaSeguinte(oPage, nPage, aTexto, oDlgReport )      *
*       Status(This,aTexto)                     *
*       TopoDoc oEdit ()                          *
*       ZoomRep(oEdt,cSize,oDlgReport)               *
*       RichEditProc( oEdit, Msg, wParam, lParam )         *
*       MsgGet( cTitle, cText, nStyle, x, y, nDlgStyle, cResIni )  *
*       Reformata(cTexto)                      *
*----------------------------------------------------------------------------*
* Objetivo____: Visualizar relatórios do tipo texto em janela gráfica gerados*
*       pelo harbour.                        *
* Observações_:                               *
*----------------------------------------------------------------------------*

#include "hwgui.ch"
#include "hwg_extctrl.ch"

#define ID_TEXTO  300
#define IDC_STATUS 2001

MEMVAR oDlgReport, n_IniPos, n_FimPos, aBusca, nSizeFont

FUNCTION Main()

   ViewReport( "test.prg" )

   RETURN NIL

FUNCTION ViewReport( cArq )

   LOCAL oFont, oFont2, cText // := FileStr( cArq )
   LOCAL oIconSair     := HIcon():AddFile( "P:\GERAL\HARBOUR\SAIR.ICO" )
   LOCAL oIconPrint    := HIcon():AddFile( "P:\GERAL\HARBOUR\RELATORIO.ICO" )
   LOCAL oIconZoomIn   := HIcon():AddFile( "P:\GERAL\HARBOUR\ZOOMIN.ICO" )
   LOCAL oIconZoomOut  := HIcon():AddFile( "P:\GERAL\HARBOUR\ZOOMOUT.ICO" )
   LOCAL oIconSeguinte := HIcon():AddFile( "P:\GERAL\HARBOUR\ISEGUINTE.ICO" )
   LOCAL oIconAnterior := HIcon():AddFile( "P:\GERAL\HARBOUR\IANTERIOR.ICO" )
   LOCAL oIconPrimeiro := HIcon():AddFile( "P:\GERAL\HARBOUR\IPRIMEIRO.ICO" )
   LOCAL oIconUltimo   := HIcon():AddFile( "P:\GERAL\HARBOUR\IULTIMO.ICO" )
   LOCAL oIconLupa     := HIcon():AddFile( "P:\GERAL\HARBOUR\ILUPA.ICO" )
   LOCAL aTexto := { "" }, nPage := 1, oPage := 1
   LOCAL oDlg_Rel, cLinha, lEject
   LOCAL cmd1, cmd2, cmd3, cmd4, cmd5, cmd6, cmd7, cmd8, btnsair, oEdit, oStatus
   LOCAL nWidth := 1920, nHeight := 1080
   PRIVATE oDlgReport, n_IniPos := 0, n_FimPos := 0
   PRIVATE aBusca := {}

   oDlg_Rel := DlgWait( "Gerando o Relatório", "Aguarde...", "PROCESS32_32.AVI" )
   //inkey(0)

   FT_FUSE( cArq )

   DO WHILE ! FT_FEOF()
      cLinha  := FT_FREADLN()
      lEject  := ( Chr(12) $ cLinha )
      //lEscape := ( Chr(27) $ cLinha )
      cLinha  := StrTran( cLinha, Chr( 12 ) ) // Elimina caracter EJECT
      cLinha  := Reformata( cLinha )
      IF FT_FRECNO() = 1
         IF Empty( cLinha ) //.AND. lEscape
            FT_FSKIP()
            LOOP
         ENDIF
      ENDIF
      aTexto[ oPage ] += cLinha + Chr( 13 ) + Chr( 10 )
      IF lEject
         AADD( aTexto, "" )
         oPage++
      ENDIF
      FT_FSKIP()
   ENDDO

   FT_FUSE()

   IF Empty( aTexto[ oPage ] )
      hb_ADel( aTexto, oPage, .T. )
      oPage--
   ENDIF

   cText := aTexto[ nPage ]

   nSizeFont := -13

   PREPARE FONT oFont NAME "Arial" WIDTH 0 HEIGHT 0 WEIGHT -10

   oFont2 := HFont():Add( "Courier New" ,0,-13, 0,,, )

   hwg_SetToolTipBalloon( .T. )

   oDlg_Rel:Close()

   INIT DIALOG oDlgReport TITLE "Visualização do Relatório" ;
      ICON  oIconPrint ;
      AT 0, 0 SIZE nWIDTH - 50, nHEIGHT - 50 ;
      CLIPPER;
      FONT  oFont ;
      COLOR 15048208 ;
      STYLE DS_CENTER + WS_SYSMENU + WS_VISIBLE ;
      //ON INIT { | oDlgReport | oDlgReport:nInitFocus := btnSair }

    //ON INIT {| oDlgReport | oDlgReport:nInitFocus:=btnSair,PaginaInicio(aTexto, oDlgReport)}

   @ 127, 019 RichEdit oEdit TEXT cText SIZE nWIDTH - 192, nHEIGHT - 130 ;
      OF    oDlgReport ID ID_TEXTO ;
      COLOR  16711680 ;
      BACKCOLOR 15724484 ;
      STYLE  WS_HSCROLL + WS_VSCROLL + ES_LEFT + ES_MULTILINE + ES_READONLY ;
      ON    GETFOCUS { || TopoDoc( oEdit ) };
      FONT   oFont2 ;
      ON OTHERMESSAGES { | This, m, wp, lp | richeditProc( this, m,wp, lp ) }

      //oEdit:bOther := {|o,m,wp,lp|richeditProc(o,m,wp,lp)}

   @ 006, 020 BUTTONEX cmd1 ;
      CAPTION " - Zoom" ;
      ON CLICK { || ZoomRep( oEdit, '-', oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON  oIconZoomOut:handle ;
      TOOLTIP 'Clique aqui para diminuir.'

   @ 006, 070 BUTTONEX cmd2 ;
      CAPTION " + Zoom" ;
      ON CLICK { || ZoomRep(oEdit, '+', oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON  oIconZoomIn:handle ;
      TOOLTIP 'Clique aqui para ampliar.'

   @ 006, 120 BUTTONEX cmd3 ;
      CAPTION "Primeira" ;
      ON CLICK { || nPage := PaginaInicio( aTexto, oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON  oIconPrimeiro:handle ;
      TOOLTIP 'Clique aqui para ir para primeira página.'

   @ 006, 170 BUTTONEX cmd4 ;
      CAPTION "Anterior" ;
      ON CLICK { || nPage := PaginaAnterior( nPage, aTexto, oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON oIconAnterior:handle ;
      TOOLTIP 'Clique aqui para ir para página anterior.'

   @ 006, 220 BUTTONEX cmd5 ;
      CAPTION "Seguinte" ;
      ON CLICK { || nPage := PaginaSeguinte( oPage, nPage, aTexto, oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON  oIconSeguinte:handle ;
      TOOLTIP 'Clique aqui para ir para página seguinte.'

   @ 006, 270 BUTTONEX cmd6 ;
      CAPTION "Última" ;
      ON CLICK { || nPage:=PaginaFim( aTexto, oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON  oIconUltimo:handle ;
      TOOLTIP 'Clique aqui para ir para última página.'

   @ 006, 320 BUTTONEX cmd7 ;
      CAPTION "&Busca" ;
      ON CLICK { || Busca_Texto( oEdit, aTexto, oDlgReport ) } ;
      SIZE  115, 40 ;
      ICON  oIconLupa:handle ;
      TOOLTIP 'Clique aqui localizar um texto.'

      //ON CLICK { || FocoRichEdit(oEdit),Busca_Texto(oEdit,aTexto,oDlgReport)} ;

   @ 006, 370 BUTTONEX cmd8 ;
      CAPTION "Imprimir" ;
      ON CLICK { || iif( hwg_MsgYesNo( "Confirma a impressão?", "Atenção" ), ImprimeRaw( cArq ), ) } ;
      SIZE  115, 40 ;
      ICON  oIconPrint:handle ;
      FONT  oFont ;
      TOOLTIP 'Clique aqui para imprimir.'

   @ 006, 420 BUTTONEX btnSair ;
      CAPTION "&Sair" ;
      ON CLICK { || hwg_EndDialog() } ;
      SIZE  115, 40 ;
      ICON  oIconSair:handle ;
      TOOLTIP 'Clique aqui para sair.'

   //ADD STATUS oStatus TO oDlgReport PARTS 100, 100, 100, 180, 0 ON INIT { |This| Status( This, aTexto ) }

   oDlgReport:Activate() // Parâmetro .T. = NOMODAL, .F. ou () = MODAL

   RETURN NIL

STATIC FUNCTION FocoRichEdit( oEdit )

   oEdit:SetFocus()
   hwg_SendMessage( oEdit:handle, EM_SETSEL, n_IniPos, n_FimPos )

   RETURN NIL

STATIC FUNCTION Busca_Texto( oEdit, aTexto, oDlgReport )

   LOCAL oDlg       := hwg_GetModalHandle()
   LOCAL cBusca
   LOCAL nStartFind := 0
   LOCAL lCase      := .F.
   LOCAL nPos
   LOCAL nResulta   := 0
   LOCAL I, cTexto, nSearch1
   //LOCAL cRes

   cBusca := MsgGet( "Pesquisa de Texto","Informe o que deseja encontrar:" )

   FOR I := 1 TO Len( aTexto )
      nSearch1 := At( Upper( cBusca ), Upper( aTexto[ i ] ) )
      IF nSearch1 > 0
         //nSearch2 := AScan( aBusca, { | a | a[ 1 ] == cBusca + Str(I) } )
         //IF nSearch2 = 0
         // AADD( aBusca, { cBusca + Str( I ), I } )
         //ENDIF
         nResulta := I
         EXIT
      ENDIF
      hwg_doevents()
   NEXT

   IF nResulta > 0
      cTexto := aTexto[ nResulta ]
      hwg_SetDlgItemText( oDlg, ID_TEXTO, HB_OEMTOANSI( cTexto ) )
      hwg_WriteStatus( oDlgReport, 4, 'Página: ' + LTrim( Str( nResulta, 6 ) ) + " de " + LTrim( Str( Len( aTexto ), 6 ) ) )
   ENDIF

   //nPos := hwg_RE_FindText( oEdit:handle, cBusca, nStartFind, lCase )

   oEdit:SetColor( 16711680 )

   DO WHILE ( nPos := hwg_RE_FindText( oEdit:handle, cBusca, nStartFind, lCase ) ) > 0
      n_IniPos := nPos
      n_FimPos := nPos + Len( cBusca )
      oEdit:SetFocus()
      hwg_SendMessage( oEdit:handle, EM_SETSEL, n_IniPos, n_FimPos )
      hwg_re_SetCharFormat( oEdit:handle, { { n_IniPos + 1, n_FimPos + 1,,,, .T. }, { n_IniPos + 1, n_FimPos + 1, 255,,, .T.,, .F. } } )
      hwg_SendMessage(oEdit:handle, EM_SETSEL, -1, 0 )
      nStartFind := nPos + Len( cBusca ) + 1
   ENDDO

   IF nPos == 0 .AND. ! Empty( cBusca )
      hwg_MsgInfo( 'Não foi possível encontrar o texto: ' + cBusca + '.', 'Atenção' )
   ENDIF

   RETURN .T.

STATIC FUNCTION PaginaInicio( aTexto, oDlgReport )

   LOCAL oDlg := hwg_GetModalHandle(), cTexto

   cTexto := aTexto[ 1 ]
   hwg_Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI( cTexto ) )
   hwg_WriteStatus( oDlgReport, 4, 'Página: ' + LTrim( Str( 1, 6 ) ) + " de " + LTrim( Str( Len( aTexto ), 6 ) ) )

   RETURN 1

STATIC FUNCTION PaginaFim( aTexto, oDlgReport )

   LOCAL oDlg := hwg_GetModalHandle(), nUltimaPag := Len( aTexto ), cTexto

   cTexto := aTexto[ nUltimaPag ]
   IF Empty( cTexto )
      cTexto := ""
   ENDIF
   hwg_Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI( cTexto ) )
   hwg_WriteStatus( oDlgReport, 4, 'Página: ' + LTrim( Str( nUltimaPag, 6 ) ) + " de " + LTrim( Str( nUltimaPag, 6 ) ) )

   RETURN nUltimaPag

STATIC FUNCTION PaginaAnterior( nPage, aTexto, oDlgReport )

   LOCAL oDlg:=hwg_GetModalHandle(), cTexto

   nPage := -- nPage
   IF nPage < 1
      nPage := 1
   ENDIF
   cTexto:=aTexto[ nPage ]
   hwg_Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI( cTexto ) )
   hwg_WriteStatus( oDlgReport, 4, 'Página: ' + LTrim( Str( nPage, 6 ) ) + " de " + LTrim( Str( Len( aTexto ), 6 ) ) )

   RETURN nPage

STATIC FUNCTION PaginaSeguinte( oPage, nPage, aTexto, oDlgReport )

   LOCAL oDlg:=hwg_GetModalHandle(), cTexto

   nPage := ++ nPage
   IF nPage > oPage
      nPage := oPage
   ENDIF
   cTexto:=aTexto[ nPage ]
   IF Empty( cTexto )
      cTexto:=""
   ENDIF
   hwg_Setdlgitemtext( oDlg, ID_TEXTO, HB_OEMTOANSI( cTexto ) )
   hwg_WriteStatus( oDlgReport, 4, 'Página: ' + LTrim( Str( nPage, 6 ) ) + " de " + LTrim( Str( Len( aTexto ), 6 ) ) )

   RETURN nPage

STATIC FUNCTION Reformata( cTexto )

   LOCAL cText := cTexto

   cText := StrTran( cText, Chr(27) + "P" + Chr(15) )
   cText := StrTran( cText, Chr(12), Chr(13) + Chr(13) )
   cText := StrTran( cText, Chr(27) + "P" )
   cText := StrTran( cText, Chr(27) + Chr(77) + Chr(15) )
   cText := StrTran( cText, Chr(27) + Chr(77) + Chr(18) )
   cText := StrTran( cText, Chr(27) + Chr(80) + Chr(18) )
   cText := StrTran( cText, Chr(15) )
   cText := StrTran( cText, Chr(18) )
   cText := StrTran( cText, "%0A(s0p15h0s0b4102T" )
   cText := StrTran( cText, "%0A(s0p10h0s0b4099T" )

   RETURN cText

STATIC FUNCTION Status( This, aTexto )

   This:settextpanel( 2, 'Lin:' + Str( 1, 6 ) )
   This:settextpanel( 3, 'Col:' + Str( 1, 6 ) )
   This:settextpanel( 4, 'Página: ' + LTrim( Str( 1, 6 ) ) + " de " + LTrim( Str( Len( aTexto ), 6 ) ) )

   RETURN NIL

STATIC FUNCTION TopoDoc( oEdit )

   hwg_SendMessage( oEdit:Handle, WM_VSCROLL ,SB_TOP, 0 )
   hwg_SendMessage( oEdit:Handle, EM_SETSEL , 0, 0 )

   RETURN .T.

STATIC FUNCTION ZoomRep( oEdit, cSize, oDlgReport )

   LOCAL oFont2

   IF cSize = '+'
      hwg_WriteStatus( oDlgReport, 1, '+ Zoom' )
   ELSE
      hwg_WriteStatus( oDlgReport, 1, '' )
   ENDIF
   nSizeFont += nSizeFont + IIF( cSize = '+', 1, -1 )
   nSizeFont := IIF( cSize = '+', Min( -9, nSizeFont ), Max( -13, nSizeFont ) )
   oFont2 := HFont():Add( "Courier New", 0, nSizeFont )
   hwg_SendMessage( oEdit:Handle, WM_SETFONT, oFont2:handle, 0 )
   oEdit:SetColor( 16711680 )
   oEdit:Refresh()

   RETURN .T.

STATIC FUNCTION RichEditProc( oEdit, Msg, wParam, lParam )

   LOCAL nLinha, nColuna

   IF Msg == WM_KEYUP .OR. Msg == WM_KEYDOWN .OR. Msg == WM_LBUTTONDOWN .OR. Msg == WM_SYSKEYDOWN
      nColuna := hwg_Loword( hwg_SendMessage( oEdit:Handle, EM_GETSEL, 0, 0 ) )
      nLinha  := hwg_SendMessage( oEdit:Handle, EM_LINEFROMCHAR, nColuna, 0 ) + 1
      nColuna := nColuna - hwg_SendMessage( oEdit:Handle, EM_LINEINDEX, -1, 0 ) + 1
      //
      hwg_WriteStatus( oDlgReport, 2, 'Lin:' + Str( nLinha, 6 ) )
      hwg_WriteStatus( oDlgReport, 3, 'Col:' + Str( nColuna, 6 ) )
      oEdit:Refresh()
   ENDIF
   HB_SYMBOL_UNUSED( wParam + lParam )

   RETURN -1

STATIC FUNCTION MsgGet( cTitle, cText, nStyle, x, y, nDlgStyle, cResIni )

   LOCAL oModDlg, oFont := HFont():Add( "MS Sans Serif", 0, - 13 )
   LOCAL cRes := IIf( cResIni != Nil, Trim( cResIni ), "" )
   LOCAL oIconOk   := HIcon():AddFile( "P:\GERAL\HARBOUR\IOK.ICO" )
   LOCAL oIconCancela := HIcon():AddFile( "P:\GERAL\HARBOUR\ICANCELA.ICO" )

   nStyle := IIf( nStyle == Nil, 0, nStyle )
   x := IIf( x == NIL, 210, x )
   y := IIf( y == NIL, 10, y )
   nDlgStyle := IIf( nDlgStyle == NIL, 0, nDlgStyle )

   INIT DIALOG oModDlg TITLE cTitle At x, y SIZE 300, 140 ;
      FONT oFont CLIPPER ;
      STYLE DS_CENTER+ WS_POPUP + WS_VISIBLE + WS_CAPTION + WS_SYSMENU + WS_SIZEBOX + nDlgStyle

   @ 20, 10 SAY cText SIZE 260, 22
   @ 20, 35 GET cRes SIZE 260, 26 STYLE WS_TABSTOP + ES_AUTOHSCROLL + nStyle
   oModDlg:aControls[ 2 ]:Anchor := ANCHOR_TOPABS + ANCHOR_LEFTABS + ANCHOR_RIGHTABS

   @ 20, 95 BUTTONEX "Ok" ID IDOK SIZE 115, 40 ICON oIconOk:handle TOOLTIP 'Clique aqui para iniciar a pesquisar.'
   oModDlg:aControls[ 3 ]:Anchor := ANCHOR_BOTTOMABS

   @ 168,95 BUTTONEX "Cancelar" ID IDCANCEL SIZE 115, 40 ICON oIconCancela:handle TOOLTIP 'Clique aqui para cancelar a pesquisa.'
   oModDlg:aControls[ 4 ]:Anchor := ANCHOR_RIGHTABS + ANCHOR_BOTTOMABS

   ACTIVATE DIALOG oModDlg ON ACTIVATE { || IIF( ! Empty( cRes ), HWG_KEYB_EVENT( VK_END ), .T. ) }

   oFont:Release()

   IF oModDlg:lResult
      RETURN Trim( cRes )
   ELSE
      cRes := ""
   ENDIF

   RETURN cRes

STATIC FUNCTION DlgWait( cTitle, cMensagem_Wait, cArqVideo )

   LOCAL oDlg_Wait, oLabel_Wait
   LOCAL oIconWait := HIcon():AddFile( "P:\GERAL\HARBOUR\IAMPULHETA.ICO" )
   /* LOCAL lAutoPlay := .T., lCenter:=.T., lTransparent := .T. */

   hb_Default( @cArqVideo, "P:\GERAL\HARBOUR\LOADER.AVI" )

   /* cRes := "" */

   INIT DIALOG oDlg_Wait TITLE cTitle ;
      ICON oIconWait ;
      AT 0, 0 ;
      SIZE 350, 90 STYLE DS_CENTER + WS_SYSMENU //90

   // @ 10,10 ANIMATION SIZE 30, 30 AUTOPLAY CENTER TRANSPARENT FILE cArqVideo

   @ 50, 20 SAY oLabel_Wait CAPTION cMensagem_Wait SIZE 200, 19

   ACTIVATE DIALOG oDlg_wait NOMODAL

   RETURN oDlg_Wait

FUNCTION AberturaAvi( cArqVideo, cTitle )

   LOCAL oDlg_Wait /*, oCtrl, oWait */
   LOCAL lAutoPlay := .T., lCenter := .T., lTransparent := .F.

   hb_Default( @cArqVideo, "" )
   hb_Default( @cTitle, "" )

   INIT DIALOG oDlg_Wait TITLE cTitle ;
      AT 0, 0 ;
      CLIPPER;
      SIZE 737, 518 STYLE DS_CENTER + WS_VISIBLE

   /* oCtrl := */ HAnimation():New( oDlg_Wait, , , 5, 5, 720, 480, cArqVideo, lAutoPlay, lCenter, lTransparent )

   oDlg_Wait:Activate()

   RETURN oDlg_Wait

PROCEDURE Fim( oControl1,oControl2 )

   oControl2:End()
   oControl1:Close()
   oControl1:Destroy()
   hwg_EndDialog()

   RETURN

STATIC FUNCTION ImprimeRaw(cArqImp)

   LOCAL cPrinter := WIN_PrinterGetDefault(), oDlg_Rel

   oDlg_Rel := DlgWait( "Imprimindo o Relatório", "Aguarde...", "P:\GERAL\HARBOUR\IMPRESSORA.AVI" )
   WIN_PrintFileRaw( cPrinter, cArqImp, 'REPORT_PREVIEW' )
   oDlg_Rel:Close()

   RETURN Nil


Não sei com a hwgui original, mas com a allgui é hbmk2 test hwgui.hbc
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 17 Abr 2017 09:19

Mas dá pra mostrar o que a allgui usa:

\harbour\bin\hbmk.hbc -> só indica a pasta da allgui, e um padrão geral básico do Harbour na minha máquina

Description=hbmk.hbc
libpaths=d:\cvsfiles\allgui\allgui
compr=yes
strip=yes
prgflags=-m -n -ge1


allgui\hwgui.hbc => libs da hwgui, e pasta de include da hwgui

Description=hwgui.hbc
incpaths=..\hwgui\include
libs=hwgui allgui.hbc


allgui\allgui.hbc => acrescento 3 PRGs padrão: pra errorsys, gtwvg default, e funções renomeadas no Harbour 3.4
também o path das libs (hwgui está lá), e algumas libs padrão

Description=allgui.hbc
sources={!hblib}errorsys.prg
sources={!hblib}allgui.prg
sources={!hblib}harbour34.prg
libpaths=..\lib\win\${hb_comp}
libs=msvfw32 vfw32 hbmisc.hbc hbziparc.hbc hbhpdf.hbc hbct.hbc gtwvg hbwin
gui=yes
mt=yes


Apenas divisão por "grupo" de uso:
hbmk.hbc é utilizado automaticamente pelo Harbour, vale pra qualquer coisa que eu compilar
hwgui.hbc é o que define a parte de hwgui
allgui.hbc é o que define pra todas libs gráficas, e evita ficar duplicando configuração (usa pra HMG 3, HMG Extended, HWGUI e OOHG)

Pra quem quiser criar um hbc comum pra hwgui comum, é só criar com tudo junto e colocar na pasta do Harbour, ajustando os paths, e colocando a lista de libs da hwgui, que na original são pelo menos 3.

{!hblib} é pra NÃO acrescentar os fontes indicados quando o projeto for pra uma LIB. Só acrescenta se for EXE.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Função para localizar um texto em um richedit

Mensagempor asimoes » 17 Abr 2017 09:56

Quintas,

Eu fiz várias modificações desde 2013 na função ViewReport, se você quiser eu posto aqui.
â–ºHarbour 3.x | Minigui xx-x | HwGuiâ—„
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar de usuário

asimoes
Colaborador

Colaborador
 
Mensagens: 4919
Data de registro: 26 Abr 2007 16:48
Cidade/Estado: RIO DE JANEIRO-RJ
Curtiu: 341 vezes
Mens.Curtidas: 258 vezes

Função para localizar um texto em um richedit

Mensagempor JoséQuintas » 17 Abr 2017 11:19

As alterações não prendem à hwgui 2.17?
Se quiser postar até completo com ícones, pode ser interessante até pra outras pessoas.
Lembro num outro post do usuário estar tentando compilar um preview antigo, também em hwgui, e não conseguir, deve interessar pra ele também.
Se permitir, deixo em allgui\samples\hwgui
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18014
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Próximo



Retornar para HwGui

Quem está online

Usuários vendo este fórum: Nenhum usuário registrado online e 5 visitantes


Ola Amigo, espero que meu site e forum tem lhe beneficiado, com exemplos e dicas de programacao.
Entao divulgue o link da Doacao abaixo para seus amigos e redes sociais ou faça uma doacao para o site forum...
MUITO OBRIGADO PELA SUA DOACAO!
Faça uma doação para o forum
cron
v
Olá visitante, seja bem-vindo ao Fórum Clipper On Line!
Efetue o seu login ou faça o seu Registro