.res file not displaying properly

Now that I figured how to use .res and add any kind of file, I have a slight problem with my .rtf file. My .rtf file has information in it, including the formatting of colors and text as Arial Narrow.
When I use LoadResData(101, "CUSTOM") to open the .rtf file, it shows alll question marks in my rich text box. The formatting of the .rtf file is gone too. There are no more colors and the font and size changed all of a sudden to blank question marks.

May I know why?
LVL 2
ZeyadssAsked:
Who is Participating?
 
Mark_FreeSoftwareConnect With a Mentor Commented:

if you open the file before it is put in a resource with notepad or the like, it looks like this, right?:

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
{\colortbl ;\red255\green0\blue0;}
\viewkind4\uc1\pard\lang1033\f0\fs17 Ric\cf1 hTextB\cf0 ox1
\par }


then you added it to a resource with the resource editor as custom resource
saved the resource.

and then you did:
Richtextbox1.textRTF = Loadresdata(101, "CUSTOM")

but that wil fail, becaus Loadresdata returns a byte array.
you have to convert it to a string, before trying to use it as a string.

something like this will work:

Private Sub Command1_Click()
Dim sBuf As String
    sBuf = strconv( LoadResData(101, "CUSTOM"), vbUnicode )
    Richtextbox1.textRTF = sBuf
End Sub


or you could leave sBuf out totally, but this way you can manipulate the data before it is in the textbox
0
 
ZeyadssAuthor Commented:
I have done what you said exactly. I can see the text in english, but the fonts, colors and size of the fonts are not working. I also still see the codes like these:
{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial Narrow;}}
{\colortbl ;\red0\green128\blue128;}
I use wordpad to create my formatting for my chapters and save them as .txt and when I open the text file it shows all those weird codes. I have the same problem with .rtf files. I also heard that wordpad also uses richtextbox to open those files but im not sure if it does. If you look at those weird codes above, it looks like wordpad creates them to give the formatting colors, sizes and look of my text.

The code you gave me worked since I can read the text, but those weird codes are still shown and the formatting of my text is not working.
0
 
ZeyadssAuthor Commented:
Oh wait a minute nevermind!. It worked. lol. I guess when I restarted visual basic it worked then. Sorry!
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Mark_FreeSoftwareCommented:

great!
0
 
ZeyadssAuthor Commented:
Thanks again. I may have few more questions. You might want to participate.
0
 
Mark_FreeSoftwareCommented:

thanks for the points and the grade!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.