Announcement

Collapse
No announcement yet.

BS_OWNERDRAW

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • BS_OWNERDRAW

    Hi,
    ich bin gerade dabei einen BS_OWNERDRAW Button zu erstellen.
    Nun habe ich folgende Routinen in mein Programm eingebaut:
    ...
    static HBITMAP hbm1,hbm2;
    HDC hdcMem1,hdcMem2;
    ...
    hwndStart=CreateWindow("BUTTON", "Start",
    WS_VISIBLE|WS_CHILD|BS_OWNERDRAW ,
    10, 80, 89, 33, // Positionen auf dem Elternfenster
    hwnd, (HMENU)ID_START, hInstance, 0);
    hwndExit=CreateWindow("BUTTON", "Exit",
    WS_VISIBLE|WS_CHILD|BS_OWNERDRAW ,
    10, 180, 89, 33, // Positionen auf dem Elternfenster
    hwnd, (HMENU)ID_EXIT, hInstance, 0);
    ...

    case WM_DRAWITEM:
    hdcMem2 = BeginPaint(hwnd,&ps);
    hdcMem1 = CreateCompatibleDC(hdcMem2);
    SelectObject(hdcMem1, hbm1);
    StretchBlt(hdcMem2,
    0,
    0,
    89,
    33,
    hdcMem1, // source device context
    0, 0, // x and y upper left
    89, // source bitmap width
    33, // source bitmap height
    SRCCOPY); // raster operation
    EndPaint(hwnd,&ps);
    DeleteDC(hdcMem1);
    DeleteDC(hdcMem2);
    return TRUE;

    Aber irgendwie klappt es nicht den Buttons verschiedene Bilder zuzuweisen.
    Was mache ich falsch?

  • #2
    bevor ich anfange viel zu erlären, einfach zwei Links <p>
    http://msdn.microsoft.com/library/psdk/winui/buttons_4icz.htm <p>
    http://www.bendlins.de/nico/delphi/ DelphUBBsrc.zip <p>

    Du solltest Dir mal die Beschreibung von WM_DRAWITEM ansehen,<br>
    dann wird klar, das Du in den falschen Geräte-Kontext zeichnest.<br>
    über PDrawItemStruct(LParam) bekomt man auch die ID des Controls.<p>
    (und andere wichtige Daten - Selektions-, Fokus-Status...)<p>

    Gruß Nic

    Comment

    Working...
    X