flat assembler
Message board for the users of flat assembler.
Index
> Windows > Printing Goto page 1, 2 Next |
Author |
|
revolution 06 Sep 2008, 14:29
In Windows, printing is quite similar as painting to the screen. You open a DC and starting drawing your output. Of course you have to select the desired printer before you can open the DC but there are helper functions for this. Have a look at PrintDlg.
|
|||
06 Sep 2008, 14:29 |
|
Crinan 06 Sep 2008, 22:06
Thanks for your reply. I have only used GUI for the screen, never painting it.
Following Win32Hlp, I get as far as trying to define DOCINFO, but DOCINFO doesn't appear anywhere in my fasm directory. I have tried to set it up as a standard data definition, but then StartDoc returns error code 6, which presumably says it doesn't like it. |
|||
06 Sep 2008, 22:06 |
|
revolution 07 Sep 2008, 00:18
Error code 6: ERROR_INVALID_HANDLE
So the DC handle is not valid. |
|||
07 Sep 2008, 00:18 |
|
Crinan 07 Sep 2008, 05:20
Right, if you say so.
PrintDlg returns different values of pd.hDC every time I run it - numbers such as 3572076 and even greater. I do have pd.Flags set to PD_RETURNDC. |
|||
07 Sep 2008, 05:20 |
|
revolution 07 Sep 2008, 05:33
You need to use the DC returned from CreateDC.
|
|||
07 Sep 2008, 05:33 |
|
madmatt 07 Sep 2008, 05:38
Crinan wrote: I tried downloading Matt's rar but it wouldn't open - said there were errors in it. Which rar file was that? I downloaded the Charles Petzold file and it opened fine for me. Is your Winrar extractor up to date? The Charles Petzold contains some printing examples in Chapters 13, 17. _________________ Gimme a sledge hammer! I'LL FIX IT! |
|||
07 Sep 2008, 05:38 |
|
Crinan 07 Sep 2008, 07:20
Reply to Revolution
I have been following the procedure in Win32hlp and it uses pd.hDC. I quote: Unlike a display DC, printer DCs are not owned by the window management component, and they cannot be obtained by calling the GetDC function. Instead, an application must call the CreateDC or PrintDlg function. When an application calls CreateDC, it must supply a driver and port name. So I used PrintDlg because I don't know what the driver and port name are. Reply to madmatt: I have never used rar files before so I had just downloaded wrar38b5.exe and your file was FASMW16726.rar In the meantime, I have discovered fairly detailed examples of complete printing routines in masm32, so I might be able to convert these and use their logic. At least they are complete routines. Thanks anyway. |
|||
07 Sep 2008, 07:20 |
|
Alphonso 07 Sep 2008, 12:32
Is this any help to you?
A 'Hello Printer' program that uses the default printer. That's if I have understood Revolution correctly. Code: format PE GUI 4.0 include 'win32a.inc' struct DOCINFO .cbSize dd ? .lpszDocName dd ? .lpszOutput dd ? .lpszDatatype dd ? .fwType dd ? ends section '.code' code readable executable invoke GetDefaultPrinter,PrinterName,PrinterNameSize ;use GetProfileString for <w2k or eax,eax jz exit invoke CreateDC,Driver,PrinterName,0,0 or eax,eax jz exit mov [hDC],eax ;Maybe set up fonts etc.. invoke StartDoc,[hDC],Dinfo invoke StartPage,[hDC] add [PrinterNameSize],HelloLen-1 ;Hello + name of printer invoke TextOut,[hDC],100,100,Hello,[PrinterNameSize] ;a 100,100 offset from top left corner of page invoke EndPage,[hDC] invoke EndDoc,[hDC] invoke DeleteDC,[hDC] exit: invoke ExitProcess,0 ;-- ------------------------------------ section '.data' data readable writeable PrinterNameSize dd 256 ;Should work this out, see below hDC dd ? Dinfo DOCINFO 20,DocName,0,0,0 DocName db 'FasmDoc',0 Driver db 'WINSPOOL',0 Hello db 'Hello printer ' HelloLen=$-Hello PrinterName rb 256 ;-------------------------------------- section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ gdi,'GDI32.DLL',\ winspool,'WINSPOOL.DRV' import kernel,\ ExitProcess,'ExitProcess' import gdi,\ CreateDC,'CreateDCA',\ DeleteDC,'DeleteDC',\ StartDoc,'StartDocA',\ EndDoc,'EndDoc',\ StartPage,'StartPage',\ EndPage,'EndPage',\ TextOut,'TextOutA' import winspool,\ GetDefaultPrinter,'GetDefaultPrinterA' ;GetDefaultPrinter,NULL,PrinterNameSize will return number of bytes required for printer name |
|||
07 Sep 2008, 12:32 |
|
Crinan 08 Sep 2008, 05:36
Many thanks Alphonso
That's just the sort of thing I was hoping for. I'll work along with that and see where I get to. Thanks again. |
|||
08 Sep 2008, 05:36 |
|
madmatt 08 Sep 2008, 14:35
Crinan wrote:
I'm using winrar 3.7, so looks like he changed the algorithm used in compressing the files using the "best" method. In the next update, I'll upload standard zip files using standard compression to try and prevent problems like this. Oh, and thanks for informing about this problem. madmatt _________________ Gimme a sledge hammer! I'LL FIX IT! |
|||
08 Sep 2008, 14:35 |
|
revolution 08 Sep 2008, 14:41
I use 7-zip (google it). Supports rar, zip, bz2, etc. all in one program.
|
|||
08 Sep 2008, 14:41 |
|
edfed 08 Sep 2008, 16:17
and free! no winzip's evaluation delay dialogbox.
about printing. on old hardware, or more standard printers, liek serial ones, it is exactlly as a typemachine. you send a char via rs232 port the printer will print it as is. it naturally cares about tabs, CRLF, etc... just hardware manufacturer decided to overcomplicate the process. making them very difficult to access without WINDOW$. how do you print a simple text with modern printers? |
|||
08 Sep 2008, 16:17 |
|
revolution 08 Sep 2008, 16:20
Oh yeah, thanks for reminding me edfed, 7-zip is completely free and open source.
|
|||
08 Sep 2008, 16:20 |
|
revolution 08 Sep 2008, 16:22
edfed wrote: how do you print a simple text with modern printers? If you want graphics and colours then you need to format your data accordingly, just like before. Nothing has changed except for the COM--->USB connector thing. |
|||
08 Sep 2008, 16:22 |
|
farrier 09 Sep 2008, 01:14
Quote: how do you print a simple text with modern printers? The program in the following link: http://board.flatassembler.net/topic.php?p=70211#70211 can send raw text, printer control codes, PCL, ... to any printer on your computer or network. What it doesn't do, is handle all the nice things the windows does for you when you want to print in different font or formats or orientations unless you know the commands that your printer requires to do these things, and you send these commands yourself. hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
09 Sep 2008, 01:14 |
|
Crinan 09 Sep 2008, 05:58
Sometimes things just don't work out.
I'm sure I was holding my mouth right too. About 7-zip: I downloaded jZip v1.3.0.54552 from the 7-zip site and tried to extract FASMW16726.rar: "Jzip does not support the file format of the file you are trying to open" About your program Alphonso: I compiled it and it worked (of course!) I then tried to include an invoke to MessageBox. I thought I should include USER32.DLL in the library statement, but this caused the following error library kenel,'KERNEL32.DLL',/ \Fasm\Include\macro/import32.inc[7]library[2]: if defined name##.redundant error: extra characters on line. Funny, but if I omit "winspool,'WINSPOOL.DRV'" it is ok. I don't understand libraries and library calls, and the manual seems to be written for people who already understand the concepts (not a criticism) so I don't know what this means and how to get over it. As far as I can see, USER32 contains all the calls(?) that I would like to use, but how this affects KERNEL32 ... Up to now I have just used the .end macro and this worked fine for all I wanted to do. I tried writing my own version of the .end macro but this had the same effect. Can you see what I am doing wrong and how to overcome it? |
|||
09 Sep 2008, 05:58 |
|
revolution 09 Sep 2008, 06:20
Jzip, WTF Did you really find that at http://www.7-zip.org/?
|
|||
09 Sep 2008, 06:20 |
|
Crinan 09 Sep 2008, 07:44
Yes, that's where I downloaded jZipV1c.exe from, about 2 hours ago.
|
|||
09 Sep 2008, 07:44 |
|
revolution 09 Sep 2008, 07:56
Just you use 7-Zip Version 4.something. That works perfectly fine for me and is what I recommended.
If jZip doesn't work then delete it and forget about it. BTW: I still can't see any reference to jZip on the 7-zip site |
|||
09 Sep 2008, 07:56 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.