( Index )

Brief Information about the June 2001 CSIG Meeting

Print Screen --- Windows API Printing

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Program Icon

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Printing will be demonstrated with an Print Screen program called "PScreen".

Microsoft Visual C++ and MFC have an unbelievably large number of functions related to graphical programming. This month we will consider bitmaps.

Splash Bitmap

The subject is an print screen program. Ever since the days of DOS, there has always been a PrintScreen button on everyone's keyboard. When we went to Windows 3.1, 95, 98, 2000, ME, XP, etc., the functionality became lost. When you hit the PrintScreen key, the only thing that happens is that the screen image is copied to the ClipBoard. Wouldn't it be nice if a program could watch for this event and automatically send the image to the printer, just like the good old DOS days.

At the meeting on Tuesday night we will be discussing the utility and the source code.

void CPScrDlg::OnDrawClipboard() 
    int code;
    // TODO: Add your message handler code here

    if (still_initializing) return;


    for (code=EnumClipboardFormats(0); code; code=EnumClipboardFormats(code))
        if (code == CF_DIB) break;      // Future: handle CF_TEXT
    if (code)
        LONG DibHeight, DibWidth;
        HBITMAP hBmp = (HBITMAP) ::GetClipboardData(code);
        GetDIBResolution(hBmp, &DibWidth, &DibHeight);
        if (DibWidth > 99 || DibHeight > 99) 
            // Notify the user that something is happening.

            CDialog dlg;                    // Display small Printer bitmap.
            dlg.Create(IDD_DIALOG1);        // Dialog was set 'Hidden', 'Set Foreground'.
            Sleep(100);                     // Wait for window update
            dlg.SetWindowPos(NULL, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOMOVE);
            dlg.ShowWindow(SW_SHOW);        // Now unhide it.
            dlg.UpdateWindow();             // Send paint message

            Bmpprint(hBmp);                 // Now call the print routine

    ::SendMessage(nextWindow, WM_DRAWCLIPBOARD, (WPARAM) 0, (LPARAM) 0);

"Random Access" questions start at 7:30 Tuesday night.


Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page