The MASM Forum

General => The Campus => Topic started by: deeR44 on December 28, 2020, 07:05:43 PM

Title: Re: Printing operation
Post by: deeR44 on December 28, 2020, 07:05:43 PM
Since this is a MASM forum, how come I find stuff like this in here so often?

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commdlg.h>

void GDIDraw_Print(HWND hWnd)
{
   PRINTDLG pd = {0};
   pd.lStructSize = sizeof( pd );
   pd.hwndOwner = hWnd;
   pd.Flags = PD_RETURNDC;
   
   // Retrieves the printer DC
   if (PrintDlg(&pd))
   {
      HDC hdc = pd.hDC;
      StartDoc (hdc, NULL);
      StartPage (hdc);   

      // Drawing code begin
      //   
      RECT rc;
      rc.top = 100;
      rc.left = 100;
      rc.bottom = 300;
      rc.right = 300;

      HBRUSH greenBrush=CreateSolidBrush(RGB(0,255,0));
      FillRect(hdc, &rc, greenBrush);
      DeleteObject(greenBrush);
      //
      // Drawing code end

      EndPage (hdc);
      EndDoc(hdc);
      DeleteObject(hdc);
   }

I can't help wondering.
Title: Re: Re: Printing operation
Post by: xandaz on December 29, 2020, 08:02:09 AM
   yeah get the startdoc,startpage, endpage, enddoc and i can make the printer print. i was just worndering if there was an easier way to do it. Huch's code is good.
Title: Re: Re: Printing operation
Post by: xandaz on December 29, 2020, 08:55:58 AM
   Hutch. could you post the charfill routine. Thanks
Title: Re: Re: Printing operation
Post by: TimoVJL on December 29, 2020, 09:24:57 AM
You can use stosb
Title: Re: Re: Printing operation
Post by: hutch-- on December 29, 2020, 06:34:40 PM
deeR44,

> Since this is a MASM forum, how come I find stuff like this in here so often?

Its mainly because most assembler programmers are multi-lingual and need to be because most reference material for Windows API functions are documented in C, not MASM.

I wonder why you keep bleating about C source code when its the only source of documentation for system functions.
Title: Re: Re: Printing operation
Post by: jj2007 on December 29, 2020, 08:16:40 PM
Quote from: hutch-- on December 29, 2020, 06:34:40 PMI wonder why you keep bleating about C source code when its the only source of documentation for system functions.

Sometimes you find good stuff at the PowerBasic forum. Or at José Roca's site, e.g. for the RichEdit control (http://www.jose.it-berater.org/richedit/iframe/index.htm)
Title: Re: Re: Printing operation
Post by: TouEnMasm on December 30, 2020, 12:45:59 AM
Good samples are often in C,c++ ,like this one:
https://stackoverflow.com/questions/6682286/understanding-a-c-sample-printers-handles-strings (https://stackoverflow.com/questions/6682286/understanding-a-c-sample-printers-handles-strings)
or this one for a richedit:
https://docs.microsoft.com/en-us/windows/win32/controls/printing-rich-edit-controls (https://docs.microsoft.com/en-us/windows/win32/controls/printing-rich-edit-controls)
Title: Re: Re: Printing operation
Post by: deeR44 on January 13, 2021, 05:05:31 PM
QuoteIts mainly because most assembler programmers are multi-lingual and need to be because most reference material for Windows API functions are documented in C, not MASM.

When I see stuff documented in C or C++, I just go someplace else. Here, I just brought it up as a matter of curiosity--to see where this junk comes from. I have been writing stuff in assembly since 1975 and only recently started to look at C.
Title: Re: Re: Printing operation
Post by: jj2007 on January 13, 2021, 07:50:53 PM
Quote from: deeR44 on January 13, 2021, 05:05:31 PMWhen I see stuff documented in C or C++, I just go someplace else. Here, I just brought it up as a matter of curiosity--to see where this junk comes from. I have been writing stuff in assembly since 1975 and only recently started to look at C.

I fully agree that C++ is crap. However, there is no need to insult any of our members here. When Timo, for example, posts some lines of code here, he does it because he wants to help somebody, and has no time to rewrite the code in Assembly. He is an excellent programmer both in Assembler and C. There are other members who happen to be proficient in both languages. None of them has ever tried to play the missionary on us.
Title: Re: Re: Printing operation
Post by: hutch-- on January 14, 2021, 05:55:11 AM
I suggest that our friend deeR44 gets used to the idea that in any version of Windows, the documentation is in C and some of the very late stuff is in C++. I can write C if I can be bothered but the important part with C is that the documentation for all versions of Windows is in C and only C.

Now we would not want to stop you from going elsewhere if you don't like to see C code, we allow it only as reference to those who want to write the same in assembler as this is not a C/C++ forum.

> I have been writing stuff in assembly since 1975

The world has changed a lot since 1975 and the assembler you may have written back then would be useless by any recent version of Windows. MS-DOS assembler was simple 16 bit stuff using a variety of interrupts but from early Windows the interrupt driven model simply does not work.

What I don't understand is your whining about something that you don't appear to understand, C code in Windows is normal as it is written in C/C++, wishing for other documentation is a pipe dream. Like most who write successful Windows assembler in 32 & 64 bit, you choice is to learn how to read the documentation.
Title: Re: Re: Printing operation
Post by: deeR44 on February 03, 2021, 07:03:39 PM
QuoteI wonder why you keep bleating about C source code when its the only source of documentation for system functions.

Because, Hutch, this is a MASM forum and NOT a C printing forum. I'm sure there are plenty of C forums around with taking up page after page of this garbage here.
Title: Re: Re: Printing operation
Post by: hutch-- on February 03, 2021, 07:17:52 PM
 :dazzled:

> Since this is a MASM forum, how come I find stuff like this in here so often?

Because you cannot find it anywhere else. Almost ALL of the 32 and 64 bit MASM code you see has been translated from C documentation but the programmer who used C documentation for reference, and effectively what you are asking for is someone else to do the work for you.

You have to go back to MS-DOS 5.0 to find COMMAND.COM written in MASM and that is only 30 years ago. All Windows versions binary code is written in either C or C++ and all of the Microsoft documentation is in C.

To be honest I find C these day slow and clunky to write but you must know how to read enough of it to understand how the Windows API functions work and to be clear, there has never been a pure assembler app that will run in Windows without the API functions to interact with the operating system.

Even very early MS-DOS used interrupts so the bulk of 16 bit real mode code written in assembler is not pure ASM either.
Title: Re: Re: Printing operation
Post by: TimoVJL on February 03, 2021, 09:36:59 PM
Quote from: deeR44 on February 03, 2021, 07:03:39 PM
I'm sure there are plenty of C forums around with taking up page after page of this garbage here.
And a many of sites just for you :biggrin:
Title: Re: Re: Printing operation
Post by: jj2007 on February 03, 2021, 10:59:26 PM
Quote from: deeR44 on February 03, 2021, 07:03:39 PMI'm sure there are plenty of C forums around with taking up page after page of this garbage here.

Cool down, man :tongue:

While I agree with you that C++ is a really crappy language, the M$ documentation in C is essential for coding in Assembly. Simply get used to it, if you want to be productive :thup:
Title: Re: Printing operation
Post by: hutch-- on February 03, 2021, 11:13:55 PM
Specifically for our friend deeR44, as with others who have to be reminded, the "Campus" is for new members and is subject to restrictions on what gets posted there. Whining about the content that does not conform to your notion of assembler does not fit into the rules of the forum. Any further junk like this dumped into the Campus will be removed and if you persist, you will be set free to post garbage elsewhere.

First and last warning.