CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2001
    Posts
    199

    Question SDI CFormView App

    Hi,

    I have a SDI App where the view is based on CFormView, I have successfully put a bitmap in the background of the CFormView by using the following code in the OnPaint Function:

    Code:
    	CDC memDC;
    	memDC.CreateCompatibleDC(&dc);
    
    	CBitmap bitmap;
    	CBitmap * pbitmap;
    
    	bitmap.LoadBitmap(IDB_OVERALL);
    
    	pbitmap = memDC.SelectObject(&bitmap);
    
    	CRect Rect;
    	GetClientRect(&Rect);
    
    	int iDeltaX = 0;
    	dc.BitBlt(iDeltaX, 0, Rect.Width(), Rect.Height(), &memDC, 0, 0, SRCCOPY);
    
    	memDC.SelectObject(pbitmap);
    This is fine however it is set against the left side and I want the bitmap centered. In order to do this I need the width of the bitmap, any ideas?

    Also if possible I would like to disable the window from being resized, I want the app to remain maximised, is this possible?

    Thanks in advance.

    KnNeeded.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398
    I need the width of the bitmap, any ideas?
    To get a bitmap size use CBitmap::GetBitmap method:
    Code:
       BITMAP bm;
       VERIFY(bitmap.GetBitmap(&bm));
       int height = bm.bmHeight; 
       int width = bm.bmWidth,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured