I want to make the tab button work on my app , so when I press tab, it will change from one edit box to another, these are the edit box codes:
case WM_CREATE:
TextBox = CreateWindow("EDIT",
"",
WS_BORDER|WS_CHILD|WS_VISIBLE|WS_EX_LAYERED|WS_TABSTOP|WS_GROUP,
60,50,200,20,
hwnd,NULL,NULL,NULL);
DataBox = CreateWindow("EDIT",
"",
WS_BORDER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP,
60,72,200,20,
hwnd,NULL,NULL,NULL);
MotivBox = CreateWindow("EDIT",
"",
WS_BORDER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP,
60,92,200,20,
hwnd,NULL,NULL,NULL);
PretBox = CreateWindow("EDIT",
"",
WS_BORDER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_GROUP,
60,112,200,20,
hwnd,NULL,NULL,NULL);
A tab control is analogous to the dividers in a notebook or the labels in a file cabinet. By using a tab control, an application can define multiple pages for the same area of a window or dialog box.
To retrieve all text from an edit control, first use the GetWindowTextLength function or the WM_GETTEXTLENGTH message to determine the size of buffer needed to contain the text. Next, retrieve the text by using the GetWindowText function, the GetDlgItemText function, or the WM_GETTEXT message.
1. In computer software (e.g., Internet browser), a tab is a clickable area at the top of a window that shows another page or area. When a tab is clicked, the tab's contents are shown, and any other open tab is hidden. Tabs allow you to switch between options in a program, separate documents, or web pages.
Virtual-key codes are device-independent. Pressing the A key on any keyboard generates the same virtual-key code. In general, virtual-key codes do not correspond to ASCII codes or any other character-encoding standard.
The fix is quite simple. Given the fact you're handling the WM_CREATE message, rather than the WM_INITDIALOG message, it seems safe to assume that you're adding the controls to a 'standard' window, rather than a 'dialog'.
With that in mind, I expect you've got something like the following in your winmain:
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
However, the documentation for IsDialogMessage
states:
"Although the IsDialogMessage function is intended for modeless dialog boxes, you can use it with any window that contains controls, enabling the windows to provide the same keyboard selection as is used in a dialog box. When IsDialogMessage processes a message, it checks for keyboard messages and converts them into selection commands for the corresponding dialog box. For example, the TAB key, when pressed, selects the next control or group of controls, and the DOWN ARROW key, when pressed, selects the next control in a group.
Because the IsDialogMessage function performs all necessary translating and dispatching of messages, a message processed by IsDialogMessage must not be passed to the TranslateMessage or DispatchMessage function."
So, you can change your message pump to resemble the following:
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
if (IsDialogMessage(hwnd, &messages) == 0)
{
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
}
As far as I remember, you should use WS_GROUP
only on the first entry. All following childwindows will be added to this group. When you create a new group, you use WS_GROUP
again on the first window being created.
So keep the WS_GROUP
on TextBox
and remove it form the other windows.
You can read about this here on MSDN.
You also should use the IsDialogMessage
in your message loop. You can see an example here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With