IonicWind Software

IWBasic => General Questions => Topic started by: aurelCB on December 05, 2010, 04:17:55 AM

Title: Load file to Richedit
Post by: aurelCB on December 05, 2010, 04:17:55 AM
Hi all...
Infact this is not question..and if someone know better option
im always ready to learn.
I find that :
SetDlgItemTextA(w1,1,buffer)
not work with richedit control,why im not sure(maby i do something wrong...)
here is my solution:
IF @CONTROLID = richeditID
If @notifycode=0
filename=""
                        buffer=""
filename = FILEREQUEST("Load file",w1,1,filter,"aon")
IF( Openfile(hFile,filename,"R") = 0): ' open a >1MB file
hsize=0
hsize = Len(hFile)
Allocmem htext,hsize,1
hzero=0
Writemem htext,hsize,hzero
Read hFile,htext
'load memory to pointer
pMem=htext
'load stringPointer to Istring
buffer=#<string>pMem
'NOT WORK->SetDlgItemTextA(w1,1,buffer)
Freemem htext
Closefile hFile
ENDIF
'WORK -> show file in richedit
Setcontroltext w1,1,buffer
                ENDIF
Title: Re: Load file to Richedit
Post by: LarryMc on December 05, 2010, 07:54:54 AM
Why not use the command that was designed to load a richedit from a string or file?
Quotereturn = CONTROLCMD (window | dialog, ID, @RTLOAD, FILE | STRING, type)

Use this function to load the contents of the rich edit control from an open file or a string variable.

Type is either 0 to load the contents in plain ASCII format or 1 to load the contents in rich text format (*.rtf). Returns number of characters loaded. FILE is a variable of type FILE and must have been successfully opened for reading with the OPENFILE function.


LarryMc
Title: Re: Load file to Richedit
Post by: aurelCB on December 05, 2010, 12:22:10 PM
Simply becose this way i dont wanna use rtload.
Title: Re: Load file to Richedit
Post by: King64 on December 06, 2010, 03:40:56 AM
Hi Aurel. Assuming to use windows.inc, where _SetDlgItemText stands for SetDlgItemTextA, try with


_SetDlgItemText(w1.hwnd,1,buffer)

because SetDlgItemTextA expects you pass it an handle to the dialog, not the dialog!
Title: Re: Load file to Richedit
Post by: aurelCB on December 06, 2010, 08:37:23 AM
Hi King...
Orginaly is espected INT and i understand what you mean ,but this is not main problem then
problem is in variable buffer which must be string(istring) and i have memory so becose of this
i use pointer and work.(but maby im again in wrong...)
However ...it work. ;)
Title: Re: Load file to Richedit
Post by: aurelCB on December 06, 2010, 03:51:33 PM
Larry
sorry i dont explain better.
Ok i try with
CONTROLCMD (w1, 1, @RTLOAD,hfile, 0)
but dont load anything probably becose hfile is binary(i guess...)
Title: Re: Load file to Richedit
Post by: LarryMc on December 06, 2010, 03:55:53 PM
Aurel

I don't really know what you are doing but it seems to me that EDIT and RICHEDIT controls are for text and not for binary files.  Seems to me all the non printing characters in a binary file would make and EDIT control go crazy.

LarryMc
Title: Re: Load file to Richedit
Post by: aurelCB on December 07, 2010, 01:29:52 AM
Larry
Dont worry.
Im just testing how from memory load file into richedit control which
is main operation inside binded ABasic exe.
In another words.
ABasic create exe file which contain abruntime.exe +sourcecode.
Source code is in of course - binary shape.
So when you doubleclick this binded exe, source code is loaded into memory
then from memory is loaded into richedit and executed.
i think that is not to complicated for understand. :)