Another way is to create button window with id. button1 = ::CreateWindowEx(WS_EX_LEFT,L"button",L"Button1", WS_CHILD ,50,50,50,50,parent,(HMENU)100,::GetModuleHandle(NULL),NULL); button2 = ::CreateWindowEx(WS_EX_LEFT,L"button",L"Button2", WS_CHILD ,125,50,50,50,parent,(HMENU)200,::GetModuleHandle(NULL),NULL); Now you can distinguish which is which. case WM_COMMAND: if ((UINT)HIWORD(wParam) == BN_CLICKED) { switch (int)LOWORD(wParam): { case 100: Triggered(L"1"); //Shows a messagebox. break; case 200: Triggered(L"2"); //Shows a messagebox. break; } } break;