DrawTextW( hdc, strText, -1, rectB, DT_SINGLELINE);
 
Hi,
I have a peice of a code for loading a icon and draw the text below
the icon on the same button...
i was sucessful in loading an icon but when tried with the DrawText()
to insert a text, its not working and the problem is with the hdc
parameter of DrawText function.
void CNewButtonDlg::CallButton()
{
    CString strText("");
                //To place the text on the button
    RECT rectA = {180, 20, 270, 90};  //left, top, right, bottom
                //To nullify the error that parameter must be a LPRECT
and not RECT type i have done so
    LPRECT rectB = &rectA;
    CDC my_newButton;
    HDC hdc;
    CWnd *pParent = pParent->GetSafeOwner();
    RECT rect = {180, 10, 270, 80};
    my_Button.Create(_T("&Button"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
| BS_ICON /*| BS_TOP | BS_TEXT*/,
        rect, this, IDC_BUTTON_NEW);
    if(my_Button.GetIcon() == NULL)
my_Button.SetIcon(::LoadIcon(AfxGetInstanceHandle( ),MAKEINTRESOURCE(IDI_ICON_NEW)));
    //CDC *pMyCDC  = pButtonWnd->GetDC();
    my_Button.GetWindowText(strText);
                //This function will remove the ampersand present in
the button text.
    DelAmpersand(strText);
    hdc = ::GetDC(m_hWnd);
                //problem with the parameters, even i tried with the
                //CDC::DrawText(4 - parameters, its not working);
    DrawTextW( hdc, strText, -1, rectB, DT_SINGLELINE); /*| TA_UPDATECP*/
}
Help me out to draw a text on the button after loading a icon on a
button.