the RegisterHotKey() is limited?
everytime that i create a button control the RegisterHotKey() id isn't the same.

//on constructor:
++ButtonCount;
altmessage=ButtonCount;

now the hotkey message:

case WM_HOTKEY:
            {
               if (wParam==inst->altmessage)
                {
                    SendMessage(inst->hwnd,WM_COMMAND,BN_CLICKED,lParam);
                }
            }
            break;

and now how i regist the hot key:

case WM_DRAWITEM:
            {
                DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam;
                UnregisterHotKey(inst->hwnd,inst->altmessage);
                RegisterHotKey(inst->hwnd,inst->altmessage,MOD_ALT,inst->altkey);

inst is the button object pointer.
the 1st button that it's created, the alt+altkey is working fine. but the 2nd button is ignored, why?

Why are you unregistering and registering the hotkey everytime the button is drawn? This looks like an owner drawn button but the question stands..

Comments
thanks for all

even so my problem was my own function for get the letter(from button caption). i was doing several errors without notice.
heres my function:

char GettingAltKey(string text)
{
    char altkey=-1;//defauld result
    int textlenght=text.length()-1;
    for(int i=0; i<textlenght;i++)
    {
        if((text[i]=='&') && (i<textlenght) && (text[i+1]!='&'))
        {
            altkey=upper((char)text[i+1]);
            break;
        }
        else if((text[i]=='&') && (i>0) && (text[i-1]!='&')  )
        {
            altkey=upper((char)text[i+1]);
            break;
        }
    }
    return altkey;
}

//button class constructor:
button(string caption="", HWND parent=WindowMain)
    {
        ++ButtonCount;
        if(caption=="")
            strCaption=strCaption + to_string(ButtonCount);
        else
            strCaption=caption;
        setParent(parent);//is where i create the button
        altkey=GettingAltKey(strCaption);
        if(altkey!=-1)
            RegisterHotKey(hwnd,altmessage,MOD_ALT,altkey);
    }

void setText(string text)
    {
        strCaption=text;
        if(altkey!=-1)
            UnregisterHotKey(hwnd,altmessage);
        altkey=GettingAltKey(strCaption);
        if(altkey!=-1)
            RegisterHotKey(hwnd,altmessage,MOD_ALT,altkey);
        InvalidateRect(hwnd,NULL,FALSE);
    }
~button()
    {
        --ButtonCount;
        if(altkey!=-1)
            UnregisterHotKey(hwnd,altmessage);
        DestroyCursor(hCursor);
        DestroyWindow(hwnd);
        hwnd = 0;
    }

now works fine.
thanks for all

This question has already been answered. Start a new discussion instead.