Author Topic: Printing operation  (Read 992 times)

jj2007

  • Member
  • *****
  • Posts: 11051
  • Assembler is fun ;-)
    • MasmBasic
Re: Printing operation
« Reply #30 on: December 27, 2020, 04:20:33 AM »
   Hi. Are you sure it can't be done like this:

There are apparently several ways to print from a richedit control. Mine works fine.

xandaz

  • Member
  • ***
  • Posts: 334
  • I luv you babe
Re: Printing operation
« Reply #31 on: December 27, 2020, 06:56:35 AM »
   Yeah JJ. Your way seems to work fine. The problem is that your code is too complex for my peanut-sized mind. Thanks anyway
nothing to report.

jj2007

  • Member
  • *****
  • Posts: 11051
  • Assembler is fun ;-)
    • MasmBasic
Re: Printing operation
« Reply #32 on: December 27, 2020, 08:05:21 AM »
I can't help you much because I did this almost 4 years ago and have forgotten the details. However, StartDoc, StartPage, EndPage, EndDoc and the EM_FORMATRANGE message are all well documented... maybe the source posted by Hutch is clearer.

deeR44

  • Regular Member
  • *
  • Posts: 39
Re: Printing operation
« Reply #33 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.

xandaz

  • Member
  • ***
  • Posts: 334
  • I luv you babe
Re: Printing operation
« Reply #34 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.
nothing to report.

xandaz

  • Member
  • ***
  • Posts: 334
  • I luv you babe
Re: Printing operation
« Reply #35 on: December 29, 2020, 08:55:58 AM »
   Hutch. could you post the charfill routine. Thanks
nothing to report.

TimoVJL

  • Member
  • ****
  • Posts: 668
Re: Printing operation
« Reply #36 on: December 29, 2020, 09:24:57 AM »
You can use stosb
May the source be with you

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8027
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Printing operation
« Reply #37 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 11051
  • Assembler is fun ;-)
    • MasmBasic
Re: Printing operation
« Reply #38 on: December 29, 2020, 08:16:40 PM »
I 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

TouEnMasm

  • Member
  • *****
  • Posts: 1531
    • EditMasm
Fa is a musical note to play with CL

deeR44

  • Regular Member
  • *
  • Posts: 39
Re: Printing operation
« Reply #40 on: January 13, 2021, 05:05:31 PM »
Quote
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.

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

  • Member
  • *****
  • Posts: 11051
  • Assembler is fun ;-)
    • MasmBasic
Re: Printing operation
« Reply #41 on: January 13, 2021, 07:50:53 PM »
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.

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

  • Administrator
  • Member
  • ******
  • Posts: 8027
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Printing operation
« Reply #42 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: