Bit map viewer

This is a discussion on Bit map viewer within the Windows Programming forums, part of the Platform Specific Boards category; I am having a problem with the BitMapViewer tutorial from: http://sunlightd.virtualave.net/Windows/GUI/ If you take a look at my screen shot, ...

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Bit map viewer

    I am having a problem with the BitMapViewer tutorial from: http://sunlightd.virtualave.net/Windows/GUI/

    If you take a look at my screen shot, youíll see that the bmp I load into my static group box IDC_VIEW isnít staying within its border it runs on through to the edge of the window.

    Looking at the following code I see how it finds the top and left coords but how does it know where the lower left of the view is supposed to be?




    Code:
    void MainDialog_OnPaint(HWND hWnd, HDC hDC)
    {
    	if (hBitmap == NULL)
    		return;
    
    	RECT	r;
    	POINT	p;
    
    	GetClientRect(GetDlgItem(hWnd, IDC_VIEW), &r);
    	p.x = r.left;
    	p.y = r.top;
    	ClientToScreen(GetDlgItem(hWnd, IDC_VIEW), &p);
    	ScreenToClient(hWnd, &p);
    
    DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, p.x, p.y, 0, 0,   DST_BITMAP | DSS_NORMAL);
    }

  2. #2
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Where did my attachment go?

    Here is my attachment it was lost somehow.
    Attached Images Attached Images  

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Try this:
    Code:
    GetClientRect(GetDlgItem(hWnd, IDC_VIEW), &r);
    
    DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, r.x, r.y, r.width, r.height,   DST_BITMAP | DSS_NORMAL);
    (Why do you transform local coordinates to global, then back again?)
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Registered User MicroFiend's Avatar
    Join Date
    Nov 2002
    Posts
    80
    Wouldnt it be easier to directly blit the image using the stretchblt API call to the desired device context?

  5. #5
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    ???

    I have absolutely no Idea I am just doing the tutorial at: http://sunlightd.virtualave.net/Windows/GUI/


    Then I'll mess around with other API calls. If I remember correctly the tutorial said for simplicity nothing beats: DrawState.

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    stretchblt will resize the image if the destination rectangle is larger/smaller than the source, unlike DrawState which will clip the image.
    Which you choose to use depends on your intentions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 07:02 PM
  3. Searching STL Map Inside STL Map Object :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2002, 08:11 AM
  4. my map is showing up 90 degrees turned!
    By frenchfry164 in forum C++ Programming
    Replies: 8
    Last Post: 03-28-2002, 01:32 PM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21