Sign in to follow this  
evilsoft

Win32 API TabStop Question

Recommended Posts

evilsoft    122
I am currently putting the finishing touches on a MDI Level editor for my 2D engine, but I ran into a snag with a desired feature...Tab Stops...I have a few controls on one of my MDI Child windows and I want to A) Tab to each and B) Have the ability to alter the tab order at run time (a setting to aid in different approaches at data entry)...I was lead to beleive from MSDN that all I had to do was "or" in WS_TABSTOP in the CreateWindowEx function when creating the controls styles...but it is not working...Any idea's?

Share this post


Link to post
Share on other sites
hunta    188
The problem could be, that you don't use the "IsDialogMessage" function to process the incoming messages in your message-loop. Look for this function, there're tons of examples and discussion...

Share this post


Link to post
Share on other sites
evilsoft    122
Quote:
Original post by Colin Jeanne
Can you be more specific when you say "not working"?


Yes...I can...When I hit Tab...It does not tab to the next field

Quote:
The problem could be, that you don't use the "IsDialogMessage" function to process the incoming messages in your message-loop. Look for this function, there're tons of examples and discussion...


Thought this only applies to when you are using a dialog box...I am creating the conrols(at runtime, no templates) on a MDI child window in my app...I am going to look the function up right now

Here is some source code:

MDI Child Wind Proc:

LRESULT CALLBACK AddFormProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
{
DWORD tempStyle;

//Card Name
tempStyle = (WS_CHILD|WS_VISIBLE|SS_RIGHT);
CreateWindowEx(0,"static","Name:",tempStyle,5,6,75,20,
hwnd,NULL,g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT);
g_hEditAddName = CreateWindowEx(WS_EX_CLIENTEDGE,"edit","<name>",tempStyle,
85,5,200,20,hwnd,(HMENU)IDC_ADD_NAME,
g_hInst,NULL);
//Cost
tempStyle = (WS_CHILD|WS_VISIBLE|SS_RIGHT);
CreateWindowEx(0,"static","Cost:",tempStyle,295,6,75,20,
hwnd,NULL,g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_READONLY);
g_hEditAddCost = CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",tempStyle,
375,5,200,20,hwnd,(HMENU)IDC_ADD_COST,
g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_PUSHBUTTON);
g_hBttnAddCost = CreateWindowEx(WS_EX_CLIENTEDGE,"button","E",tempStyle,
577,5,20,20,hwnd,(HMENU)IDC_ADD_COSTBTN,
g_hInst,NULL);

//Type
tempStyle = (WS_CHILD|WS_VISIBLE|SS_RIGHT);
CreateWindowEx(0,"static","Type:",tempStyle,5,36,75,20,
hwnd,NULL,g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_READONLY);
g_hEditAddType = CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",tempStyle,
85,35,400,20,hwnd,(HMENU)IDC_ADD_TYPE,
g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_PUSHBUTTON);
g_hBttnAddType = CreateWindowEx(WS_EX_CLIENTEDGE,"button","E",tempStyle,
487,35,20,20,hwnd,(HMENU)IDC_ADD_TYPEBTN,
g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|SS_RIGHT);
CreateWindowEx(0,"static","Address:",tempStyle,517,36,45,20,
hwnd,NULL,g_hInst,NULL);
tempStyle = (WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_READONLY);
g_hEditAddType = CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",tempStyle,
602,35,400,20,hwnd,(HMENU)IDC_ADD_TYPE,
g_hInst,NULL);
}
break;

case WM_MDIACTIVATE:
SetFocus(g_hEditAddName);
{
HMENU hMenu,hSubMenu;
hMenu = GetMenu(g_hWnd);
hSubMenu = GetSubMenu(hMenu,0);
BOOL bTest = EnableMenuItem(hSubMenu,0,
MF_BYPOSITION|MF_GRAYED);
if (bTest == -1)
MessageBox(hwnd,"No Menu Exists","Error",MB_OK|MB_YESNO);
}
break;

case WM_COMMAND:
{
if (HIWORD(wParam)==EN_SETFOCUS)
{
switch(LOWORD(wParam))
{
case IDC_ADD_NAME:
SendMessage((HWND)lParam,EM_SETSEL,0,-1);
break;
}
}
}

case WM_CLOSE:
{
HMENU hMenu,hSubMenu;
hMenu = GetMenu(g_hWnd);
hSubMenu = GetSubMenu(hMenu,0);
BOOL bTest;
bTest = EnableMenuItem(hSubMenu,0,
MF_BYPOSITION|MF_ENABLED);
DrawMenuBar(g_hMDIClient);
DefMDIChildProc(hwnd, message, wParam, lParam);
}break;

default:
return DefMDIChildProc(hwnd, message, wParam, lParam);
}

return 0;
}





Hope this helps

Share this post


Link to post
Share on other sites
evilsoft    122
Awesome...that did the trick...due to it being a MDI app, I had to do my message pump as follows:


while (GetMessage (&messages, NULL, 0, 0)>0)
{
if (!TranslateMDISysAccel(g_hMDIClient,&messages) &&
!IsDialogMessage(g_hAdd,&messages))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
}




Thanks a lot...I LOVE the windows API (guess I am a masichist)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this