how add images to button with text?

i don't want lose the button style. but how can i add an image and don't lose the text?
(i can do it with menus, why not with another controls?)
i must use the BS_OWNERDRAW style, when i create the button.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
case WM_DRAWITEM:
            // drawing code goes here
            //getting the Draw Item structure
            LPDRAWITEMSTRUCT b;
            b = (LPDRAWITEMSTRUCT) lParam;

            //Getting the button visual theme(i get the xp style)
            HTHEME hTheme;
            hTheme = OpenThemeData(hButton, L"button");

            //translate the LPDRAWITEMSTRUCT->itemState to DrawThemeBackground int id state
            int c=0;
            UINT g=0;
            //testing the button state
            if(b->itemState & ODS_HOTLIGHT)
            {
                c=PBS_HOT;
                g=DFCS_HOT;
            }
            else if (b->itemState & ODS_DEFAULT)
            {
                c=PBS_DEFAULTED;
                g=DFC_BUTTON;
            }
            else if (b->itemState & ODS_DISABLED)
            {
                c=PBS_DISABLED;
                g=DFCS_INACTIVE;
            }
            else if (b->itemState & ODS_SELECTED)
            {
                c=PBS_PRESSED;
                g=DFCS_PUSHED;
            }
            else
            {
                c=PBS_NORMAL;
                g=DFC_BUTTON;
            }

            //draw the button with right state
            //the state is what the button action can draw to us(click,disable and others)
            //DrawThemeBackground(hTheme, b->hDC, BP_PUSHBUTTON, c, &b->rcItem, 0);
            DrawFrameControl(b->hDC, &b->rcItem, DFC_BUTTON |DFCS_ADJUSTRECT, g);
            //getting and draw icon
            HICON hicon;
            hicon=LoadIcon(NULL,IDI_EXCLAMATION);
            DrawIcon(b->hDC,5,5, hicon);

            SelectObject(b->hDC,CreatePen(PS_DOT,1,GetSysColor(COLOR_3DSHADOW)));
            LineTo(b->hDC,100,0);
            //before show the text, i need put it transparent(hide the text backcolor)
            SetBkMode(b->hDC,TRANSPARENT);

            //i can draw the text with prefix('&')
            //the DT_EXPANDTABS is for show us the '\t' and others
           if(b->itemState & ODS_NOACCEL)//if the menu key is pressed then
                DrawText(b->hDC,caption.c_str(),-1,&b->rcItem,DT_EXPANDTABS| DT_CENTER | DT_HIDEPREFIX);
            else
                DrawText(b->hDC,caption.c_str(),-1,&b->rcItem,DT_EXPANDTABS| DT_CENTER);
            return 0;

i'm confused with some button states :(
how i can draw the get focus state?
i found 1 way:
if(b->itemState & ODS_FOCUS) DrawFocusRect(b->hDC,&b->rcItem);
these line works, but it's with button border rect :(
so did these code:
1
2
3
4
5
6
7
RECT m;
            m.left=b->rcItem.right +5;
            m.right=b->rcItem.right -5;
            m.top=b->rcItem.top +5;
            m.bottom=b->rcItem.bottom -5;

            if(b->itemState & ODS_FOCUS) DrawFocusRect(b->hDC,&m);

theres no error message, but why the focusRect isn't showed?
maybe my problem is the convertion between the b->rcItem and m... i even used the SetRect() for these and nothing... what i'm doing wrong?
Topic archived. No new replies allowed.