Solved

VB6 (Not .NET), RTF -  Write Rotated Text Picturebox to RTF String

Posted on 2008-10-23
8
1,151 Views
Last Modified: 2008-10-29
I am creating a "Print Preview" facility (we won't get into WHY I am creating it).
This facility provides a programmer with the ability to create a report; programmatically specify X and Y coordinates on a page, and then insert Text, Shapes, external pictures, or internal pictureboxes.
In addition, rotated text can be inserted.
This all works great

The facility also has the ability to EXPORT the resultant report to PDF and/or RTF.
It does this by writing the necessary control "strings" around the content, and writing all this out to an appropriately named file (xxx.PDF or xxx.RTF).
I have completed the PDF portion. It works just fine.
I have almost completed the RTF portion.

Here is my problem.
To rotate text in a RTF, it appears the only way is to build the rotated text into a picturebox,
with the desired font, size, forecolor, then crop this picturebox to only contain the rotated text.
I have done this successfully too.
When I extract the contents of the picturebox into a hex string, and insert that into the RTF,
that all works fine.
BUT.... the background of the picturebox is NOT transparent, so any other objects in the RTF which are near this picturebox (especially other rotated text) gets overlayed by the overlapping portions of this picturebox.

So I then make the background of this picturebox transparent.
This works fine. At least it does on a form.
But when I do my hexextract of this now transparent background picturebox, and insert that into my rtf file... again.... the background is NOT transparent. So overlay still occurs.

I have a sample of some rtf control strings and hexstring which actually does display rotated text with a transparent background.

So I am needing to figure out how to make that code string from my picturebox.

Here is the sample of rtf control strings and hexdata which DOES have rotated text in it.
And it DOES display as such, with no overlap showing (obviously the background is transparent).
(Or something else is going on, which I am not aware of... and would be greatfull for some direction in that regard)

{\shp{\*\shpinst\shpleft0\shptop0\shpright32000\shpbottom32000
\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1014
{\sp{\sn shapeType}{\sv 75}}
{\sp{\sn fFlipH}{\sv 0}}
{\sp{\sn fFlipV}{\sv 0}}
{\sp{\sn pib}{\sv
{\pict\wmetafile8
0100090000038200000002001C00000000000400000003010800050000000B0200000000050000000C02007D007D1C000000FB023DFF00000807080790010000000000100000417269616C00A775610F0A91709F740730CA120010DAA475C060A775440F668C040000002D01000005000000090285807A001A000000210527002E205072696E7420707265766965772069732074686520626573742C20616E676C6520313830B00050195019050000000902010000001C000000FB021000070000000000BC02000000000102022253797374656D0000440F668C00000A0022008A0100000000FFFFFFFFBCCA1200040000002D01010004000000F0010000030000000000
}}}
}
}

How do I get a similar hexstring within my program, from a picturebox which has the rotated text in it, and a transparent background?

Thanks

0
Comment
Question by:Antithesus
  • 4
  • 3
8 Comments
 
LVL 17

Expert Comment

by:inthedark
ID: 22794654
Sorry to be dumb but have you tried setting the landscape RTF tag?
0
 
LVL 18

Expert Comment

by:mdougan
ID: 22795957
wow, I'm impressed with how far you've gotten so far.

I doubt that this will help, but when you mentioned rotated fonts, I thought of this old example from Karl Peterson.  He does a lot of API stuff and has a font class you can download.  Sounds like you have no trouble rotating your fonts, but maybe his class will have something related to transparent backgrounds that you could use.  Longshot at best.

My guess as to how the example you have above that shows a transparent background works, is that the image represented by the values in the wmetafile8 tag was originally a GIF created with a transparent background, or perhaps a Windows Meta File.  Likely, you are saving your rotated text as a bitmap, and those don't support a transparent background.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 22795964
0
 

Author Comment

by:Antithesus
ID: 22797126
mdougan,
thanks for the link. I'll look into that.

More on what I have tried....
I have saved the contents of the picturebox to the clipboard as a metafile.
Then I have extracted them into another picturebox, as a metefile.
Then I have extracted the hexvalues of that picturebox, and inserted that into my rtf file...
nope... still no transparent background.
I have tried the same a s gif... same result.
I have tried actually saving the contents to a physical file, then reading that file (in hex)...
same result.

When I look at that hexstring in my example, I am quite sure it is NOT a hex representation of a picturebox contents. I think it has significant information regarding the font, color, and angle of rotation,
and then the actual text to be shown.

The string contains (from above)
0100090000038200000002001C00000000000400000003010800050000000B02000000000500
00000C02007D007D1C000000FB023DFF00000807080790010000000000100000417269616C00A775
610F0A91709F740730CA120010DAA475C060A775440F668C040000002D0100000500000009028580
7A001A000000210527002E205072696E7420707265766965772069732074686520626573742C2061
6E676C6520313830B00050195019050000000902010000001C000000FB021000070000000000BC02
000000000102022253797374656D0000440F668C00000A0022008A0100000000FFFFFFFFBCCA1200
040000002D01010004000000F0010000030000000000

Well, this part of that string actually translates into
7A001A000000210527002E20[color=red]5072696E7420707265766965772069732074686520626573742C
20[/color]616E676C6520313830B00050195019050
"Print preview is the best, angle 180"

I have looked at the RTF specifications for weeks, but I cannot find anything that describes what a Metafile record looks like.
I expect the hex values preceding the "text" have to do with fonts, colors, angles, etc., etc.
And obviously the hex values after the "text" mean something too.
But I just can't figure it out.

I am hoping someone here can help me.

inthedark,
I am not sure how setting any landscape rtf tag will help me.
Could you elaborate ?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Antithesus
ID: 22797167
hmmmm... obviously bbcodes are not recognized... I tried to hilite a portion of the string in red.. oh well

let's hilite it in bold

7A001A000000210527002E205072696E7420707265766965772069732074686520626573742C20616E676C6520313830B00050195019050
0
 

Author Comment

by:Antithesus
ID: 22797203
mdougan,
that link/article refers to an article from 1999.
It essentially describes everything I am doing in my routines to arrive at rotated text.

But thanks anyway
0
 

Accepted Solution

by:
Antithesus earned 0 total points
ID: 22799656
Ah ha !!!
After backing up, and looking at things with a new perspective,
I think I have stumbled on the reality of my situation.

1. That string in my example is NOT a hex string of a picturebox contents;
It is a hex string of a WMF.
And it perfectly describes what to draw, where to draw it, using what fonts, and color, etc.
Once I looked more closely at it, and further examined WMF structures, it is clear.

2. So I do NOT need to get the hex contents of a picturebox with a transparent background (which I HAVE done).

Now I have to figure out how to construct those WMF (Actually I think I will use EMF)
structures with the necessary info in them.

But I think this question is actually now done... no solution, but none really needed.

I'll ask another question about how to build EMF structures, and then how to output them to a string using VB6.

Thanks for your help
0
 
LVL 18

Expert Comment

by:mdougan
ID: 22800325
Feel free to ask to delete this question and refund the points to you.  Glad you have a new direction to follow!  You're doing some pretty advanced programming there, kudos to you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now