mfc >> Drawing bitmap on the dialog itself

by Sam » Tue, 21 Mar 2006 19:53:07 GMT

I want to draw a bitmap on dialog itself but only upto specified points
if bitmap size goes beyond that then scroll bar should be displayed and
it should let me scroll the bitmap

How can display and restrict the size of bitmap on the dialog
Can someone provide me sample code

Thanking in anticipation !



mfc >> Drawing bitmap on the dialog itself

by Ajay Kalra » Tue, 21 Mar 2006 22:09:50 GMT


You will need to do all of scrolling and drawing yourself. You will
need to attach the scrollbar(and handle its events) to the dialog and
draw the bitmap yourself. There are several samples which show how to
draw bitmap in a dialog. Here is one:

http://www.codeproject.com/dialog/bmpdlg01.asp

You should also look and see if CScrollView does what you want. That
may be easy way out.

--------
Ajay Kalra
XXXX@XXXXX.COM




Similar Threads

1. Draw a BITMAP on a Dialog box

Hi Folks,


I am working on ATL dialogbox programming.
I have to place a bitmap image on my dialogbox at run time on a specific 
location.
I had done same for icon of the title bar using HICON.
I had made the HBITMAP handle for the bitmap, but I dont know how to treat 
it to draw it on dialogbox.

Small code snippet is most welcome,

Regards
Rakesh 


2. Is the way a picurebox draws itself different from how a panel does it - CSharp/C#

3. CDialog doesn't draw itself

Hi
I don't understand this. I created a Dialog App with one
Button(IDC_GETIMAGE) for testing reasons.
When you click on the button the following function is called:

void CTest1Dlg::OnGetimage()
{
 CDC* pDC = GetDC();
 Print(pDC, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT |
PRF_OWNED);
 ReleaseDC(pDC);
}


This works perfect: the dialog "renders" itself into itself (for testing
reasons).
This means that the CDialog class supports the WM_PRINT message

Then I created another Dialog App (title="Test2") with no controls on it.
I compiled it, started it and changed the code of my 1. app:

void CTest1Dlg::OnGetimage()
{
 CWnd* pWnd = CWnd::FindWindow(NULL, "Test2");
 if(pWnd == NULL)
 {
  MessageBox("\"Test2\" Window not found");
  return;
 }
 CDC* pDC = GetDC();
 pWnd->Print(pDC, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT
| PRF_OWNED);
 ReleaseDC(pDC);
}


There is no "Window not found" message when I click on the button, but the
"Test2" window doesn't draw itself into the DC
Where is the problem? I can't get it

Thank you for your help

greetings leo


4. CustomDrawn ActiveX control on CPropertyPage fails to draw itself

5. How to bring a dialog itself to top?

I have a dialog based MFC application. In this app, there is only dialog, 
and there is a textbox on the dialog. Also there a thread in this app that 
receives data from IP intranet. If the thread receive some message, then I 
need the user to input something in the textbox. At that time, I want to 
bring the dialog to top and put input focus to the textbox.

I use the folloing code in CMyDialog:

void CMyDialog::BringMeToTop()
{
    WINDOWPLACEMENT pl;
    pl.length = sizeof(pl);
    GetWindowPlacement(&pl);
    if (pl.showCmd == SW_SHOWMINIMIZED)
    {
        pl.showCmd = SW_RESTORE;
        SetWindowPlacement(&pl);
    }

    SetForegroundWindow();
    BringWindowToTop();

    m_edtCode.SetFocus();
}

But it seems to not work. With this code, the dialog can be brought to top, 
but it's not actived, it's title bar is still gray, and the previous top 
window's title bar is still blue. So that the text box cannot get input 
focus.

By the way, I am working on Win XP.

Any answer will be greatly appreciated.

Evan


6. Drawing to Bitmap using C++ MFC dll

7. Copy pixel data from System.Drawing.Bitmap

Hi.

I use System.Drawing.Bitmap to copy bitmap pixel data.
I use LockBits to retrieve a BitmapData which in turn provides me with the
Scan0 property which i then use to loop the pixel data using a byte *.
I am aware of that internally GDI+ stores RGB as BGR,
therefore i have to manually swap the R and B components of each
pixel.
Since GDI+ internally stores the components in BGR order, there is'nt a
way to copy the entire pixel data directly without looping the pixels, is
it?


Thank you!
MVH Dennis



8. Transparency problem drawing bitmap - CSharp/C#