terça-feira, 12 de janeiro de 2016

Wx - Trabalhando com arquivo .RTF (Texto Formatado)



http://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/751-trabalhando-com-arquivo-rtf-texto-formatado/read.awp








Botão SALVAR:
//Anotacoes do Usuario - SALVAR
s is string = RTFToText(EDT_Anotacoes)
IF s <> "" THEN
RtfSalvar()
ELSE
Info("Não foi digitado nada para ser salvo.")
END


Ao abrir a Janela
Procedure RtfAbrir()

//RTF
PathFile_RTF is string = fCurrentDir(fCurrentDrive()) +"\Anotacoes_"+Usuario+".RTF"
EDT_Anotacoes..RichEdit = True
EDT_Anotacoes..Visible = True

// Open the selected document
IF RTFLoad(EDT_Anotacoes, PathFile_RTF) = False THEN

RETURN

END

// Initialize the global variable with the name of the opened document
gfsDocumentName = PathFile_RTF

// Position the cursor at the beginning of the edit control
EDT_Anotacoes..Cursor = 1

IF TextHeight(EDT_Anotacoes, EDT_Anotacoes) > EDT_Anotacoes..Height THEN
// Display the vertical scrollbar
ScrollBarShow(EDT_Anotacoes, sbVert)
ELSE
// Remove the scrollbar
ScrollBarShow(EDT_Anotacoes, sbVert, False)
END


Procedure Salvar
Procedure RtfSalvar()

//RTF
PathFile_RTF is string = fCurrentDir(fCurrentDrive()) +"\Anotacoes_"+Usuario+".RTF"

EDT_Anotacoes..RichEdit = True

EDT_Anotacoes..Visible = True

// Procedure used to write data to a text file
// IN: sDocumentName: Name of the document

nFileID is int = 0

// Open the file
nFileID = fOpen(PathFile_RTF, foCreate + foWrite)

// Save the document
fWrite(nFileID, EDT_Anotacoes, Length(EDT_Anotacoes))

// Initialize the global variables
PathFile_RTF = ExtractString(PathFile_RTF, 1, “-)

// Close the document
fClose(nFileID)


Nenhum comentário:

Postar um comentário

Teste

Teste
teste