tags:

views:

57

answers:

1

My button has these styles:

WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON

it creates and lights up properly, but in my edit control, when i press ENTER, it does nothing!

Heres the styles of my edit control:

WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_TABSTOP

I am not using a dialog, i have created my windows using CreateWindow() and i have handled tab order in the message loop:

MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
    if (!IsDialogMessage(hActiveWindow, &msg))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}

The "hActiveWindow" is a handle to the window that the user has currently active. tabbing works but i have a feeling this is messing wiht the DEFPUSHBUTTON.

any help?

+1  A: 

It might be that your button is not set to be default. One solution could be to set the default button behavior with the DM_SETDEFID

/*
in: win: HWND of the window you have
in: id: your id of your default button
*/
SendMessage(win, DM_SETDEFID, id, 0);
Default
It seems that when you press enter it sends the loword of wparam as ID 1, so i have been using that :) though i support this sets it to any number you want? thanks for the reply.
yup, the comment I added to your post explained that: the default value is IDOK, which is defined as 1. I'm glad you worked it out though :)
Default