Owner Drawn (a few questions)

This is a discussion on Owner Drawn (a few questions) within the Windows Programming forums, part of the Platform Specific Boards category; I've looked over the code available on the forums and the example over at msdn (they're all pretty much the ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252

    Owner Drawn (a few questions)

    I've looked over the code available on the forums and the example over at msdn (they're all pretty much the same), though nothing I found actually covered multiple owner drawn cntls. The code snipet below works, though my question are;

    - is it correct?
    - can I use the same image (depressed state) for several controls, or should each individual control have its own set of bmps (nothing shared).

    Code:
    case WM_DRAWITEM:
    {
     DRAWITEMSTRUCT* lpDrawItem=(DRAWITEMSTRUCT*)lParam;
     HBITMAP hBmp;
    
    if (lpDrawItem->itemState&ODS_SELECTED)
      {
    
        if (LOWORD(wParam)==IDC_BUTTONA){
           hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
            MAKEINTRESOURCE(IDI_NUMONE),
            IMAGE_BITMAP,0,0,
            LR_CREATEDIBSECTION));
            }
            
             if (LOWORD(wParam)==IDC_BUTTONB){
               hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
                MAKEINTRESOURCE(IDI_NUMONE),
                IMAGE_BITMAP,0,0,
                LR_CREATEDIBSECTION));
                }   
             }
             
    else
      {
         if (LOWORD(wParam)==IDC_BUTTONA){
           hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
            MAKEINTRESOURCE(IDI_NUMONEB),
            IMAGE_BITMAP,0,0,
            LR_CREATEDIBSECTION));
            }
            
             if (LOWORD(wParam)==IDC_BUTTONB){
               hBmp=reinterpret_cast<HBITMAP>(LoadImage(GetModuleHandle(0),
                MAKEINTRESOURCE(IDI_NUMTWOB),
                IMAGE_BITMAP,0,0,
                LR_CREATEDIBSECTION));
                }
            }

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use the same image if you intend them to look the same, but load it once and use that one handle wherever it's needed and then dispose of it when done.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Gotcha. The depressed_states are the same, I assumed it redundant to use multiple images, but I wanted to be certain. More times than not, I'm wrong rather than right -

    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems defining classes
    By esmeco in forum C++ Programming
    Replies: 47
    Last Post: 10-24-2007, 01:13 PM
  2. Multiple Owner Drawn buttons
    By budoka in forum Windows Programming
    Replies: 5
    Last Post: 07-20-2005, 12:19 AM
  3. Multiple Owner Drawn buttons
    By budoka in forum C++ Programming
    Replies: 3
    Last Post: 07-12-2005, 02:00 AM
  4. Owner Drawn dynamic menus
    By cpeschke in forum Windows Programming
    Replies: 0
    Last Post: 04-18-2005, 04:55 PM
  5. Owner Drawn Menus
    By Okiesmokie in forum Windows Programming
    Replies: 6
    Last Post: 08-09-2002, 09:39 PM

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