News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Iczelion's Tutorial 35

Started by Robert Collins, December 27, 2004, 06:09:28 AM

Previous topic - Next topic

Robert Collins

With some help of those who posted replies I finaly got the sample code in Tutorial 35 to use the font of my choise plus after battleing and pounding my head against the desk I also figured out how to change the font from BOLD to not BOLD. The only problem is that I have really no idea or conception of what I did and that really bugs me because it is not good enough to just be able to do something, I have to know the how and why but for now as long as it does what I want I will leave it as such and maybe later as I learn more I will find out then how all this stuff works.

pbrennick

Robert,
It takes years, and remember, debugging is a way of life from now on.  It is not a failing, it is justhard for us to think the way a computer does.  Every success will give you the desire to go on.
Paul

farrier

Here is the code I promised for printing an RTF file.  This program uses KetilO's most excellent RadASM IDE and uses the RichEdit template to get things going.  I made some small modifications to the RTF format instead of plain text.  I added 8 new procedures which do the work:

mov landscape, 0
mov NumOfCopies, 1
call CreateMasm32RTF
call ChangeBP ;change \page to *page to simulate breaks
call DisplayRTFFile
call GetPrinterInfo
call GetPageInfo
call FormatScreenLikePrinter
call PrintFile
call UnChangeBP ;change *page back to \page


CreateMasm32RTF creates the new demo RTF file.
ChangeBP searches the RTF file for page breaks, and changes \page to *page, because the RichEdit control doesn't handle page breaks.
DisplayRTFFile streams the RTF file into the RichEdit control
GetPrinterInfo gives us control of the printer, Landscape/Portrait, # of copies, Collate
GetPageInfo gets info about page dimensions and sets user defined margins
FormatScreenLikePrinter makes the RichEdit control output resemble the printer output
PrintFile prints the RichEdit control contents, handling page breaks "Properly"  I had to add a few additionl checks to handle pages with more than one page worth of content that does not have a page break.
UnChangeBP changes the *page back to \page

HTH

farrier


[attachment deleted by admin]
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

Robert Collins

I downloaded your project, RTFPrint. Upon observing the source code in RTFPrint.asm I noticed that it has
a very close resemblance to the source code that Paul posted earlier. As a matter of fact it has exactly
the same function calls. I have to conclude that both projects came from the same origin. Also, upon
running RTFPrint.exe I noticed that the same problem occurs in the font dialog box. I can change the
font name but cannot change the font styles. Also, when the application first comes up it I look at the
font dialog box and it says that the current font is Courier New, Regular at 9 points. When I try to change
the point size to 10 and click on OK the font actually gets smaller rather than larger.
Another problem is that when the application starts up it automatically invokes the printer option.

I am not 100% sure but I think one of the problems that occur in both projects is the usage of the
CHARFORMAT structure. There are no provisions in this structure to change the font styles. However, I
changed it to CHARFORMAT2 which does have a member element to allow the font style to be changed.

donkey

QuoteI noticed that it has a very close resemblance to the source code that Paul posted earlier. As a matter of fact it has exactly
the same function calls. I have to conclude that both projects came from the same origin.

As farrier said in his post, he is using Ketil Olsen's RadASM and the RichEdit template that comes as part of the demo package for RadASM.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

farrier

Robert Collins,

All I was trying to show was how I have managed to print an RTF file, and manage the Landscape/Portrait, Number of copies, and Collate capabilities.  The procedures I added were all added to the end of the WM_INITDIALOG handler of the WndProc proc.

I haven't looked at pbrennick's code, but will soon.  His code may help me further my efforts.

The only thing I use the RichEdit control for is to display the contents of the RTF file.  This is not an editor, just a demonstration of how to print an RTF file with no user interaction.  No effort was made to change or add fonts to the RTF file.  In order to add fonts, you would add them to the rtf1 variable and then add the \fs codes to the RTF file content when you want to change fonts or type sizes.

Sorry for any confusion.

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

pbrennick

I cannot speak for anyone else, but I do not copy other peoples code.  I may use it as a base to do my own thing and might even use portions that can really only be done one way. Since there are only so many ways to skin a cat, similarities can creep in.  If you become concerned about these things, then you would have troubles using code frome libraries, etc.This is of no real concern and can be funny when an error in documentation causes several peoples code to hiccup at the same time.  As far as Print goes, I was actually working with Ewayne Wagner about this issue several years ago and I got a lot of advice from him on how to do that.  He also gave me some excellent help about the Splash screen.  I was having trouble trying to get it to center to the parent and not to the screen.  He is a good coder and was a lot of help.

When someone reverses someones commercial applications to make money from someone elses efforts, well, that is not only worg, it is against the law.  Every thing I make is freeware and any one can use it or portions of it and don't worry if your print routine winds up looking like mine.  It is no big deal.  The only requirement  I used to make (and may do so again) is that if you assume ownership of my code by improving upon it, you should also assume ownership of any support mechanism.  This is because I don't want to have to trace down every change that has been made.  Once it is modified, I will deny owning it.

Paul

pbrennick

Robert,
Continue to ask questions and I will continue to help as we all will (we cross posted so I want to make sure you understand).
Paul

Robert Collins

I was only pointing out that due the exactness of both projects they must have the same origin point and therefore, unless one is corrected, have the same identical problems. As it turned out, both projects did have the same problem with the font dialog box. I was looking for an answer to my original question so when one or more persons post sample code or even allow downloads that in the end, does not really provide an answer to my question (although very helpful in other aspects) I want you to know that I am very appreatiative for your help and anyone else's help even though I was unable to get an answer to my original question. It is of no concern how anyone obtains source code for any project; I use code snippits from anywhere I can get my hands on it if it is going to make my project work. If two people send me the same stuff to try and help me and both have the same problem then in essence I cannot use either but I believe it should be made known in an effort to eliminate duplicate problems.

I am still working on the original problem which involves trying to get the correct way to change the font styles. I was somewhat successful but it didn't work in all cases and that was when I changed the CHARFORMAT structure to CHARFORMAT2. It worked in one program (I beleive it was in Tutorial 33) but does not work in Tutorial 35 which is the one I want it to work in.

pbrennick

Robert,
You have my most recent version of my editor, I haven't posted it yet.  I want to make two more changes first.  In the program you probably noticed that True Type fonts are not shown.  All others work, so until I resolve that issue, I choose to disallow them.  I haven't had time to do so yet, but Donkey really already pointed us in the right direction when he said to save and restore the entire structure.  Because filling out those structures is what the ChooseFont dialog does, he must be correct because it works correctly after this is done.  So why don't you write a procedure to save the contents of the CHOOSEFONT, LOGFONT and CHARFORMAT structures.  Take the contents of that file and use it to initialize the 3 structures when you create the font at the start of the program and I bet it will work!  I am going to do that once my flu goes away.
Paul

farrier

Robert Collins,

Your comments in the post:

http://www.masmforum.com/simple/index.php?topic=180.msg1630#msg1630

don't make sense to me.  The code in RTFPrint shows very little resemblence to what I have just seen in pbrennick's GENESYS.ZIP project.  The only similarities are the standard windows message handling routines.  Nothing was used from pbrennick's code to construct RTFPrint.  The only things that are "original" in RTFPrint are the routines I highlighted in my post with the attachment.  Again, sorry for any confusion.  I acknowledged the techniques and code I adapted from Chib777's Print/Preview code.  Without that code, I would still be in the dark.

pbrennick,

Your response:

http://www.masmforum.com/simple/index.php?topic=180.msg1663#msg1663

seemed to me to be either defensive or accusatory, I'm not sure which.  After looking at your GENESYS.ZIP code--thanks for sharing--I can only assume Robert Collins is confused.  I don't think you stole from me--you're futher up the editor/print ladder than I am and you don't need to steal or borrow from me.  And I never saw your code before writing mine.  Hope I'm overestimating you intentions!

I've studied your code enough to know I will study it more.  It covers a lot more than I need right now, but may help me with some future projects.

I did steal from donkey!  I used the code he shared with us a while ago which loads the appropriate version of Winspool .drv or .dll  Depending on the version of Windows being used.  Thanks donkey!


If anyone has a question or comment concerning my RTFPrint program, I will be glad to help or learn!

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

pbrennick

farrier,
I am not accusing anybody of anything.  My code is free for all to use.  If you used any code from one of my projects, it would not be theft because I give it to the community for free.  I wish Robert had never accidentally said those words.  Okay, the distasteful stuff is done, let's move on.

I appreciate your compliments on my code.  I have been coding for many years and even though the move to windows was a huge step (backwards?) for me, I have been able to bring my methods into that platform, as well.  It is important to take the time to document your code.  If you have any questions about my code or need to tweak a part of it to suit your needs, I will help.

BTW:  my editor is the biggest example of a dialog box you will probably ever see.  Did you notice that?  I thought, for sure, that someone would say something about that!

Paul

pbrennick

One last thought, I have looked at code from others, it is a good way to improve my skills.  But I continually run into people writing VERY involved procedures with hundreds of lines to achieve wordwrap fumctionality.  They destroy windows and recreate them, etc. 

My WordWrap function is 5 lines, 4 of them are only used to do the flip flop.  This one has always baffled me.

Paul

hutch--

Guys,

Lets face it, there is a lot of common code around and when someone is trying to answr a question, its not a copyright debate but an attempt to help someone understand what the code does or what its used for.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

farrier

pbrennick,

Thanks for your reply.  I was confused by the nature of the two replies back to back.  What little I've done in windows programming, I've done in MASM32 and FASM and have shared everything openly and without condition.  And occasionally I've been able to help others, usually based on the work I've done on my projects.  I understand and appreciate your contributions.  And I apologize if I misunderstood your intentions and the spirit of your reply.

hutch--,

I agree!  My problem was the nature of Robert Collins' "the exactness of both projects" comment.  Still doen't make sense.

Imitation is the sincerest form of flaterry.  I've flattered many, but not stolen and taken credit for it.

Thanks to al,l for your help :U

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)