printing under MFC & VC++ 6.0

John Biddiscombe j.biddiscombe at rl.ac.uk
Fri Jun 18 11:05:59 EDT 1999


I haven't used MFC or anything like that, but I wanted a clipboard copy for
my program and I tried this, it works fine. Ought to work for a printer
canvas too.

C++Builder code, only TBitmap is different from MFC I expect.

Hope this helps

John B

menu pops up with options for bitmap size, I found that making reports look
consistent is nice if the image is always the same size. Sender in this
routine is the menu option selected. Process is..setup memory redering.
Render. BitBlt, resume screen rendering. It even works in the middle of an
animation which surprised me.

Not sure why the bitblt is necessary, ought to render direct to our bitmap
DC, but it doesn't much matter to me.

    vtkWin32OpenGLRenderWindow *oglrw = (vtkWin32OpenGLRenderWindow
*)(vtkWindow1->GetRenderWindow());
    Graphics::TBitmap *bitmap = new Graphics::TBitmap();
    if (Sender==Currentscreensizebitmap1) {
        bitmap->Width   = vtkWindow1->Width;
        bitmap->Height  = vtkWindow1->Height;
    } else if (Sender==N256x256bitmap1) {
        bitmap->Width   = 256;
        bitmap->Height  = 256;
    } else if (Sender==N320x200bitmap1) {
        bitmap->Width   = 320;
        bitmap->Height  = 200;
    } else if (Sender==N512x512bitmap1) {
        bitmap->Width   = 512;
        bitmap->Height  = 512;
    } else if (Sender==N640x480bitmap1) {
        bitmap->Width   = 640;
        bitmap->Height  = 480;
    } else if (Sender==N1024x7681) {
        bitmap->Width   = 1024;
        bitmap->Height  = 768;
    } else if (Sender==N1024x1024bitmap1) {
        bitmap->Width   = 1024;
        bitmap->Height  = 1024;
    }
    oglrw->SetupMemoryRendering(bitmap->Width, bitmap->Height,
bitmap->Canvas->Handle);
    oglrw->Render();
    HDC memDC = oglrw->GetMemoryDC();
    BitBlt(bitmap->Canvas->Handle,
        0, 0, bitmap->Width, bitmap->Height, memDC,
        0, 0, SRCCOPY
    );
    oglrw->ResumeScreenRendering();
    Clipboard()->Assign(bitmap);
    delete bitmap;



-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list