I think you might have to pass the handle to the main window, and in wParam pass the handle to the button.