.res file not displaying properly

Posted on 2007-07-30
Medium Priority
Last Modified: 2010-04-30
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?
Question by:Zeyadss
  • 3
  • 3
LVL 13

Accepted Solution

Mark_FreeSoftware earned 200 total points
ID: 19599000

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

Author Comment

ID: 19600804
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.

Author Comment

ID: 19600827
Oh wait a minute nevermind!. It worked. lol. I guess when I restarted visual basic it worked then. Sorry!
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 13

Expert Comment

ID: 19600915


Author Comment

ID: 19600939
Thanks again. I may have few more questions. You might want to participate.
LVL 13

Expert Comment

ID: 19602023

thanks for the points and the grade!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question