Click here to Skip to main content
15,914,642 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: public struct in a class Pin
Matthew Faithfull18-Sep-08 6:12
Matthew Faithfull18-Sep-08 6:12 
QuestionBitBlt does not work in print preview Pin
theCPkid18-Sep-08 5:29
theCPkid18-Sep-08 5:29 
AnswerRe: BitBlt does not work in print preview Pin
Mark Salsbery18-Sep-08 5:49
Mark Salsbery18-Sep-08 5:49 
GeneralRe: BitBlt does not work in print preview Pin
theCPkid18-Sep-08 5:54
theCPkid18-Sep-08 5:54 
QuestionRe: BitBlt does not work in print preview Pin
Mark Salsbery18-Sep-08 5:57
Mark Salsbery18-Sep-08 5:57 
AnswerRe: BitBlt does not work in print preview Pin
theCPkid18-Sep-08 6:03
theCPkid18-Sep-08 6:03 
GeneralRe: BitBlt does not work in print preview Pin
Mark Salsbery18-Sep-08 6:34
Mark Salsbery18-Sep-08 6:34 
GeneralRe: BitBlt does not work in print preview [modified] Pin
theCPkid18-Sep-08 7:01
theCPkid18-Sep-08 7:01 
Yes, I get a diagonal line. In fact. there's no problem with drawing directly on print preview dc. I am using memory dc in my code only to avoid flickering (perhaps it was obvious)

The following code draws properly in print preview... by using DIB. But it's heavily slowing down my system. perhaps, I need to create DIB section in more elegant way. DDB provided by create compatible bitmap perhaps does not work. D'Oh! | :doh:
void CMyView::OnDraw(CDC* pDC)
{
    CTestDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
        return;

    CRect rcClient;

    if (pDC->IsPrinting()) 
    {
        rcClient = m_rcPrintRect;
    }
    else
    {
        GetClientRect(&rcClient);
    }    

    HBITMAP bmp;
    BYTE* drawingSurfaceBits;
    BITMAPINFOHEADER            BMIH;
    BMIH.biSize = sizeof(BITMAPINFOHEADER);
    BMIH.biBitCount = 24;
    BMIH.biPlanes = 1;
    BMIH.biCompression = BI_RGB;
    BMIH.biWidth = rcClient.Width();
    BMIH.biHeight = rcClient.Height();
    BMIH.biSizeImage = ((((BMIH.biWidth * BMIH.biBitCount) + 31) & ~31) >> 3) * BMIH.biHeight;
    bmp = CreateDIBSection(pDC->GetSafeHdc(), (CONST BITMAPINFO*)&BMIH, DIB_RGB_COLORS, (void**)&drawingSurfaceBits, NULL, 0);
    if((bmp == NULL) || (drawingSurfaceBits == NULL))
    {
        AfxMessageBox(L"Bitmap not created", MB_OK | MB_ICONSTOP);
        return;
    }

    memDC.CreateCompatibleDC(pDC);
    memDC.SelectObject(bmp);

     memDC.DrawText(L"Hello", &rcClient, DT_CENTER | DT_VCENTER);
     pDC->BitBlt(0,0,rcClient.Width(), rcClient.Height(), &memDC, 0, 0, SRCCOPY);

    return;
}


Also, in print preview mode, the quality of picture shown on screen is extremely poor. I am perhaps using only rgb etc. I need to study bitmapinfoheader further.

Thanks for the precious help. Smile | :)

modified on Thursday, September 18, 2008 1:07 PM

GeneralRe: BitBlt does not work in print preview Pin
Mark Salsbery18-Sep-08 7:25
Mark Salsbery18-Sep-08 7:25 
GeneralRe: BitBlt does not work in print preview Pin
theCPkid18-Sep-08 22:44
theCPkid18-Sep-08 22:44 
GeneralRe: BitBlt does not work in print preview Pin
Mark Salsbery19-Sep-08 5:17
Mark Salsbery19-Sep-08 5:17 
GeneralRe: BitBlt does not work in print preview Pin
theCPkid19-Sep-08 19:49
theCPkid19-Sep-08 19:49 
AnswerRe: BitBlt does not work in print preview Pin
Roger Allen18-Sep-08 14:37
Roger Allen18-Sep-08 14:37 
GeneralRe: BitBlt does not work in print preview Pin
theCPkid18-Sep-08 22:42
theCPkid18-Sep-08 22:42 
QuestionHow can i lock the internet from a C++ program Pin
SNArruda18-Sep-08 5:04
SNArruda18-Sep-08 5:04 
AnswerRe: How can i lock the internet from a C++ program Pin
David Crow18-Sep-08 5:21
David Crow18-Sep-08 5:21 
JokeRe: How can i lock the internet from a C++ program Pin
Iain Clarke, Warrior Programmer18-Sep-08 5:22
Iain Clarke, Warrior Programmer18-Sep-08 5:22 
AnswerRe: How can i lock the internet from a C++ program Pin
Bram van Kampen18-Sep-08 14:55
Bram van Kampen18-Sep-08 14:55 
QuestionRatio result placing a square not working - when resizing window Pin
simon alec smith18-Sep-08 5:01
simon alec smith18-Sep-08 5:01 
QuestionRe: Ratio result placing a square not working - when resizing window Pin
David Crow18-Sep-08 5:26
David Crow18-Sep-08 5:26 
AnswerRe: Ratio result placing a square not working - when resizing window Pin
simon alec smith18-Sep-08 5:30
simon alec smith18-Sep-08 5:30 
AnswerRe: Ratio result placing a square not working - when resizing window [modified] Pin
Iain Clarke, Warrior Programmer18-Sep-08 5:29
Iain Clarke, Warrior Programmer18-Sep-08 5:29 
AnswerRe: Ratio result placing a square not working - when resizing window Pin
Mark Salsbery18-Sep-08 5:56
Mark Salsbery18-Sep-08 5:56 
QuestionWinInet issue Pin
George_George18-Sep-08 4:16
George_George18-Sep-08 4:16 
QuestionDrawing wider dashed lines Pin
softwaremonkey18-Sep-08 2:18
softwaremonkey18-Sep-08 2:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.