开发者

How to get BS_DEFPUSHBUTTON to work?

开发者 https://www.devze.com 2023-01-11 17:26 出处:网络
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!

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)开发者_如何学Go;
        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?


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消