My Buttons cannot get focus!

Hi to all,
I create 2 buttons and one input box dynamically.
I use this code:


HWND hwndG1B1,hwndG1B2,hwndG1B3;
hwndG1B1 = CreateWindow( L"button", L"OK", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, SCALEX(30), SCALEY(172), SCALEX(80), SCALEY(22), hWnd, (HMENU) ID_BUTTON1,g_hInst, NULL );
hwndG1B2 = CreateWindow( L"button", L"Cancel", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, SCALEX(130), SCALEY(172), SCALEX(80), SCALEY(22), hWnd, (HMENU) ID_BUTTON2,g_hInst, NULL );
hwndG1B3 = CreateWindow(_T("EDIT"), L"", WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP, SCALEX(30), SCALEY(140), SCALEX(180), SCALEY(22), hWnd, (HMENU)IDC_EDIT_BOX1, g_hInst, 0);


then if I give

SetFocus(hwndG1B1);
the first button does not get the focus.
But if I give the focus to the input box

SetFocus(hwndG1B3);
it gets the cursor inside as expected.
What am I doing wrong?
Also: How can I make this code so that I can navigate from one button to another using the UP or RIGHT arrow of the Pocket PC? (Something like when you click TAB in the PC)
Thanks a lot.
Giorgos
[1765 byte] By [giorgos_gs] at [2008-2-15]
# 1

Hi,

I created a dialog based MFC application and was able to got focus on the first button by default. I am also able to get the focus and the heavy border move from one button to another usign the WM_NEXTDLGCTL message. You can use the same. Setfocus will not give you the heavy border that is on the default button. You need to use this message for that. An example of its use:

::PostMessage(m_hWnd,WM_NEXTDLGCTL, 0, FALSE);

Thanks

avinashprasad at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...