YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   Home Products | Purchase Support | Downloads  
View in English
View in Japanese
View in
참고
View in Français
View in Italiano
View in 中文(繁體)
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
VX++ Cross-Platform C/C++
Overview
Download
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET

OpenGL printing and Print Preview with Visual C++


First time here?

Product Tour
E-XD++ Workflow Component product walkthrough

Screenshots
Applications built on E-XD++ Workflow Component

Product feature comparison

Powerful, flexible, and easy to use Diagram Components.
Powerful and flexible enough to create diagrams exactly the way you want them to appear. So easy to use that you will be able to prototype your application in just a few minutes.

Feature rich.
With features such as automatic layout, multiple layers, collapsible sub-graphs, snap-to connection points, XML, SVG, and more, E-XD++ Have the power and flexibility you need to create sophisticated diagrams, quickly and easily. Events such as click, double-click, hover, select, rubber-band select, copy, delete, resize and move are supported. Operations such as drag-and-drop, unlimited undo/redo, and clipboard operations are common and complex, and are expected by today's sophisticated users. it full supports importing ArcGis, SVG and DXF File format.

Performance and Scalability.
UCanCode E-XD++ Capable of handling many thousands of nodes and edges, up to hundreds of thousands depending upon the complexity of the nodes you wish to draw and the operations you wish to allow. Our graphical classes are extremely lightweight objects enabling outstanding performance.

Save Time and Money and gain Reliability.
A diagram is worth 1,000 words, and E-XD++ is shipped with more than 500,000 lines of well designed and well tested code! It is used by hundreds of the world's most quality conscious companies. It will saves you thousands of hours of complex coding and years of maintenance.

 

  • Download source files - 3 Kb
  • Download demo project - 36 Kb

    The sample

    The demo

    The sample of the print preview

    The print preview

    The article gives a class, CGLMemoryDC, which can support OpenGL printing under Win95/NT

    CGLMemoryDC stores the DIB data for the printer context device.

    //data of DIB
    private:
    	HBITMAP      m_hBitmap;       //handle of bitmap
    	BITMAPINFO   m_DIBInfo;       //infomation about the DIB
    	BYTE*        m_hImage;        //DIB color data
    	DWORD        m_dwDataSize;    //DIB data size 
    

     

    CGLMemoryDC also gives the functions to get DIB data from selected context device or set DIB data to target context device

    /********************************************************************/
    /* Scan the image from the device context   					    */
    /********************************************************************/
    void CGLMemoryDC::CopyDataFromDC(CDC* pDC, CRect& rect)
    {
    	CDC      dcBuffer;       //the compatible DC 
    	CBitmap  bmBitmap;		 //bitmap in memory for retreive data from DC
    	CBitmap* pbmBitmapOld;
    
    	//if the orignal bitmap did not set up
    	if(!m_hBitmap)
            return;
    
    	//create compatible DC to copy image
    	dcBuffer.CreateCompatibleDC(pDC);
    
    	//create memory bitmap 
    	bmBitmap.CreateCompatibleBitmap(pDC,
                      m_DIBInfo.bmiHeader.biWidth,
                      m_DIBInfo.bmiHeader.biHeight);
        
    	//set memory bitmap to memory DC
    	pbmBitmapOld = dcBuffer.SelectObject(&bmBitmap);
        
    	//copy source DC image to memory bitmap
    	dcBuffer.StretchBlt(0, 0,  
    			m_DIBInfo.bmiHeader.biWidth,
    			m_DIBInfo.bmiHeader.biHeight,
    			pDC, 
    			rect.left,
    			rect.top,
    			rect.Width(),
    			rect.Height(),
    			SRCCOPY);
    
    	//restore the orginal object in memory DC
        dcBuffer.SelectObject(pbmBitmapOld);
    
    	//copy image data from memory bitmap
    	GetDIBits(pDC->m_hDC,
    		HBITMAP)bmBitmap, 
    		0, 
    		m_DIBInfo.bmiHeader.biHeight,
    		m_hImage,
    		&m_DIBInfo,
    		DIB_RGB_COLORS);
    }
    
    
    /********************************************************************/
    /* Copy image data to target DC             					    */
    /*                                                                  */ 
    /* This function just support the color printer setting in Text     */
    /* mode																*/
    /********************************************************************/
    void CGLMemoryDC::CopyDataToDC(CDC* pDC, CRect& rect)
    {
        ::StretchDIBits(pDC->m_hDC, 
    			rect.left, 
    			rect.top, 
    			rect.Width(), 
    			rect.Height(),
    			0, 0, 
    			m_DIBInfo.bmiHeader.biWidth, 
    			m_DIBInfo.bmiHeader.biHeight,
    			m_hImage,  
    			&m_DIBInfo, 
    			DIB_RGB_COLORS, 
    			SRCCOPY);
    }
    
    
    /********************************************************************/
    /* Write image data directly to target DC                           */
    /*                                                                  */ 
    /* This function just support the color printer setting in Photo    */
    /* quality mode                                                     */
    /********************************************************************/
    void CGLMemoryDC::WriteDataToDC(CDC* pDC, int startx, int starty)
    {
        ::SetDIBitsToDevice(pDC->m_hDC, 
    				startx, 
    				starty,
    				m_DIBInfo.bmiHeader.biWidth,
    				m_DIBInfo.bmiHeader.biHeight,
    				0, 0, 0,
    				m_DIBInfo.bmiHeader.biHeight,
    				m_hImage, 
    				&m_DIBInfo, 
    				DIB_RGB_COLORS);
               			 
    }
    

     

    The function "WriteDataToDIBfile" in CGLMemoryDC allow to store DIB data to disk file

    The use of CGLMemoryDC in application program to support printing is like

    void CGlprintView::OnDraw(CDC* pDC)
    {
    	CGlprintDoc* pDoc = GetDocument();
    	ASSERT_VALID(pDoc);
    
    	// TODO: add draw code for native data here
    	//if print
    	if(pDC->IsPrinting())
    	{
    		 //draw the image in memory DC to print DC 
    		 CRect      drawRect;
    		 int        cx, cy;
    		 COLORREF	clrOld = pDC->SetTextColor(RGB(250, 10, 10));
    		 pDC->TextOut(450,10, "This is a demo of OpenGL print provided by Zhaohui Xing");
    		 pDC->SetTextColor(RGB(128, 128, 255));
    		 pDC->TextOut(40,80, "Large Size");
    		 drawRect.SetRect(40, 160, 2440, 1960);
    		 pDC->DPtoLP(&drawRect);
    		 m_MemImageDC.CopyDataToDC(pDC, drawRect);
    		 pDC->TextOut(40,1960, "Medium Size");
    		 drawRect.SetRect(500, 2040, 2100, 3240);
    		 pDC->DPtoLP(&drawRect);
    		 m_MemImageDC.CopyDataToDC(pDC, drawRect);
    		 pDC->TextOut(40,3260, "Orignal Size");
    		 m_MemImageDC.GetMemorySize(&cx, &cy);
    		 drawRect.SetRect(1000, 3400, 1000 + cx , 3400 + cy);
    		 pDC->DPtoLP(&drawRect);
    		 m_MemImageDC.CopyDataToDC(pDC, drawRect);
    		 pDC->SetTextColor(clrOld);
    	}
    	else //draw opnGL in current DC
    	{
    		 CPalette* oldPalette;
    
    		 //Set logic palette
    		 oldPalette = m_pDC->SelectPalette(&m_Palette, FALSE);
    		 m_pDC->RealizePalette();
    	
    		 //draw openGL object
    		 wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC);
    		 DrawObject();
    		 SwapBuffers(m_pDC->GetSafeHdc());
    		 wglMakeCurrent(m_pDC->GetSafeHdc(), NULL);
    		 
    		 //Prepare the memory DC 
    		 CRect rect;
    		 GetClientRect(&rect);
    		 m_MemImageDC.SetMemorySize(rect.Width(), rect.Height());
    		 //copy the image data in current DC to memory
    		 m_MemImageDC.CopyDataFromDC(m_pDC, rect);
    
    		 m_pDC->SelectPalette(oldPalette, FALSE);
    	}	     
    }
     
  • News:

    1 UCanCode Advance E-XD++ CAD Drawing and Printing Solution Source Code Solution for C/C++, .NET V2023 is released!

    2 UCanCode Advance E-XD++ HMI & SCADA Source Code Solution for C/C++, .NET V2023 is released!

    3 UCanCode Advance E-XD++ GIS SVG Drawing and Printing Solution Source Code Solution for C/C++, .NET V2023 is released!

     

    Contact UCanCode Software

    To buy the source code or learn more about with:


     

    Ask any questions by MSN: ucancode@hotmail.com Yahoo: ucan_code@yahoo.com


     

    Copyright ?1998-2023 UCanCode.Net Software , all rights reserved.
    Other product and company names herein may be the trademarks of their respective owners.

    Please direct your questions or comments to webmaster@ucancode.net