By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,907 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,907 IT Pros & Developers. It's quick & easy.

Edit control tab / child windows / tabstop

P: 48
Hi,

I'm working with win32API c++. I added the WS_TABSTOP to the edit windows, as well as the WS_EX_CONTROLPARENT and DS_CONTROL to the parent window. Yet any numerous times of punching the tab key does nothing.

Anyone have sample code that works? I've searched for acouple hours and couldnt find anything without MFC. I refuse to use Visual products, hence my problem with the tab key not working.

Any help would be super,
Thanks,
Quincy
May 30 '07 #1
Share this Question
Share on Google+
10 Replies


Banfa
Expert Mod 5K+
P: 8,916
What product are you using then?

For that matter what type of container are you using? Dialogue box or a window?

Are you sure that you have set the focus onto one of the controls in the first place (using SetFocus).
May 30 '07 #2

P: 48
I'm using gcc to compile without MFC.

I want to tab through edit windows (text boxes)

...| WS_TABSTOP | WM_SETFOCUS is in my styles for the edit window I want to be focused first.


All my edit windows are created in some fashion close to this:

Expand|Select|Wrap|Line Numbers
  1. CreateWindow(
  2.                                 "EDIT",
  3.                                 "CY",
  4.                                 WS_VISIBLE | WS_CHILD | ES_LEFT | WS_BORDER | WS_TABSTOP| WM_SETFOCUS,
  5.                                 110,
  6.                                 25,
  7.                                 350,
  8.                                 20, 
  9.                                 hWnd, 
  10.                                 (HMENU)IDE_TITLE,
  11.                                 hInstance,
  12.                                 NULL);
  13.  
May 30 '07 #3

Banfa
Expert Mod 5K+
P: 8,916
OK, but are you placing these edit boxes on a Window or on a Dialogue box?

In response to which message to the parent window are you creating these edit boxes, or where with-in the structure of your code?

If you don't wish to use MS software but do wish to write windows programs you may wish to consider using the Dev-C++ which comes with resource editors allowing you to create dialogue boxes in the normal way, as a resource, rather than creating them on the fly at runtime.
May 30 '07 #4

P: 48
O a Dialogue Box is made from a resource?

and a Window is made from code?

If that is true, then I just learned that lingo. Since I like code more than
pretty pictures dragging on items, I've only used code (windows) in this
project. My parent window was created like this:
Expand|Select|Wrap|Line Numbers
  1. hwndMain = CreateWindowEx(0, //Extended window style
  2.                 ClassName, // Window class name
  3.                 WindowTitle, // Window title
  4.                 dwStyles, // Window style:WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_EX_CONTROLPARENT|DS_CONTROL
  5.                 desktopRect->top, desktopRect->left, // (x,y) pos of the window
  6.                 desktopRect->right, desktopRect->bottom, // Width and height of the window
  7.                 NULL, // HWND of the parent window (can be null also)
  8.                 NULL, // Handle to menu
  9.                 g_hInstance, // Handle to application instance
  10.                 (void*)this); // Pointer to window creation data
  11.  
And my tab key works, though instead of it jumping to a new text box it indents inside the text box. I would like for it to jump.

Thanks.
May 31 '07 #5

P: 48
so basically i'm asking how to tab across these child windows(text boxes), if it is possible.
Jun 1 '07 #6

Banfa
Expert Mod 5K+
P: 8,916
You still have not explicitly said if you are trying to create a window or a dialogue box.

However assuming from the DS_CONTROL in this

Expand|Select|Wrap|Line Numbers
  1. hwndMain = CreateWindowEx(0, //Extended window style
  2.                 ClassName, // Window class name
  3.                 WindowTitle, // Window title
  4.                 dwStyles, // Window style:WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_EX_CONTROLPARENT|DS_CONTROL
  5.                 desktopRect->top, desktopRect->left, // (x,y) pos of the window
  6.                 desktopRect->right, desktopRect->bottom, // Width and height of the window
  7.                 NULL, // HWND of the parent window (can be null also)
  8.                 NULL, // Handle to menu
  9.                 g_hInstance, // Handle to application instance
  10.                 (void*)this); // Pointer to window creation data
  11.  
that you are trying to create a dialog box then you should not be calling CreateWindowEx (or CreateWindow) because these create windows.

You need to look up and call

DialogBoxIndirect - if you wish to create a modal dialogue box

CreateDialogIndirect - if you wish to create a modeless dialogue box


These 2 functions do not use a dialogue resource to create the dialogue box so you will be able to create your edit boxes in them once they are created.

If the dialogue box layout is fixed it is normal to create a dialog resource to define them, then you could use

DialogBox - if you wish to create a modal dialogue box

CreateDialog - if you wish to create a modeless dialogue box

to create them at runtime.
Jun 1 '07 #7

P: 48
I made a window inside a window. I don't know how else to explain except for saying I want to be able to tab between child windows which are in this case edit windows.
Jun 5 '07 #8

P: 3
I don't know if it helps, but I'm exploring the same issue except I'm using VC++ 5 (stop laughing at the back, I've had it for years and it was cheap.)

Anyway, I've got a class derived from CView which has a number of objects embedded in it representing "lines" of information. Each "line" is itself a class derived from plain old CWnd that contains static text, two CButton controls and two "custom" controls derived from CEdit.

I spite of defining all the controls with WS_TABSTOP & WS_EX_CONTROLPARENT I can't tab between the controls unless I add handlers to look for the "tab" keystrokes in my CEdit derived controls, and I can't do anything with the standard CButtons (and don't really want to create by own simply to handle the tab key.)

So in my case it's definitely CWnd's within CWnd's and not a CDialog box anywhere.

Any help would be much appreciated since I can't find anything in the VC++ online manuals.

Mick
Jun 21 '07 #9

P: 3
Aha: I think I've found the answer to my own problem: Take a look at...

.... http://www.microsoft.com/mind/0499/faq/faq0499.asp

and

.... http://support.microsoft.com/?kbid=165074

... for a description of what's up with tabbing between CWnd child window controls. The first article is specific to "web browsers within other windows" but the descriptions contained of how Windows handles tab keystrokes should prove illumunating.

And just in case anyone's reading this years after it was posted and the links have gone dead, look up "IsDialogMessage" and "PreTranslateMessage" functions in your favourite search engine and hopefully you should find some useful information.

If your problems are inside Dialog boxes, hopefully the original respondant to this post can help you out.

Good Luck

Mick
Jun 21 '07 #10

P: 3
More info:

If you want to control the order in which you tab through controls at run time, use the SetWindowPos function. My (MFC) code fragment for doing this is...

// From the parent window of the the controls...

CWnd* pWnd; // Ptr to window we're changing.
CWnd* pAfter; // Ptr to window we want pWnd after.
UINT nFlags=SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE; // Ignore window size and position parameters in SetWindowPos calls.

pAfter =GetDlgItem(1STCONTROL);
pAfter->SetWindowPos(&wndTopMost,0,0,0,0,nFlags);
pWnd =GetDlgItem(2NDCONTROL);
pWnd->SetWindowPos(pAfter,0,0,0,0,nFlags);
pAfter =pWnd;
pWnd =GetDlgItem(3RDCONTROL);
pWnd->SetWindowPos(pAfter,0,0,0,0,nFlags);
pAfter =pWnd;
pWnd =GetDlgItem(4THCONTROL);
pWnd->SetWindowPos(pAfter,0,0,0,0,nFlags);

etc.

As mentioned, this is MFC code, but the MFC calls are more or less just wrappers to API calls of the same name, so you'll need to use Window handles insteand of CWnd pointers.

Hope that helps.

Mick
Jun 22 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.