tags:

views:

25

answers:

1

hello all I have a small dialog which I created dynamically, which has a textbox and a button..if the user presses the TAB key it has to switch between the two control(textbox and button)...I tried using SetwindowPos...but it doesnt seem to solve my problem...please give me a solution for this..in the below code..I also tried to include the mainwindow in the taborder..still it doesnt work

//dialog creation

HWND dialogHandle = CreateWindowEx(0,WC_DIALOG,L"Security Alert",WS_OVERLAPPEDWINDOW|WS_VISIBLE,600,300,280,160,NULL,NULL,NULL,NULL);

//create textboxcontrol within the dialog
    HWND textBoxHandle = CreateWindowEx(WS_EX_CLIENTEDGE,L"EDIT",L"",WS_CHILD|WS_VISIBLE |ES_PASSWORD | WS_TABSTOP,123,48,110,25,dialogHandle,(HMENU)IDD_TEXTBOX,NULL,NULL);

    //create button
    HWND buttonHandle  = CreateWindowEx(NULL,L"Button",L"OK",WS_CHILD|WS_VISIBLE| WS_TABSTOP,151,85,85,25,dialogHandle,(HMENU)ID_PASSWORD_OK,NULL,NULL);

//setwindowpos

SetWindowPos(NULL,textBoxHandle,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
SetWindowPos(textBoxHandle,buttonHandle,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
+3  A: 

In your message loop, you need to call IsDialogMessage for keyboard events (such as the tab key) to be processed by the dialog box. This is described here.

Here is an example:

while (GetMessage(&msg, NULL, 0, 0) > 0) {
    if (!IsDialogMessage(dialogHandle, &msg)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}
interjay
i tried the below..it dont seem to workwhile(GetMessage( DispatchMessage( IsDialogMessage(textBoxHandle, IsDialogMessage(buttonHandle, }
kiddo
@Rakesh: You need to pass the dialog handle, not the control handles. I've added an example.
interjay
ya it worked ..thank u dude
kiddo