News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Re: Printing operation

Started by deeR44, December 28, 2020, 07:05:43 PM

Previous topic - Next topic

deeR44

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.

xandaz

   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.

xandaz

   Hutch. could you post the charfill routine. Thanks

TimoVJL

May the source be with you

hutch--

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.

jj2007

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


deeR44

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.

jj2007

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.

hutch--

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.

deeR44

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.

hutch--

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

TimoVJL

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:
May the source be with you

jj2007

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:

hutch--

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.