Article View: borland.public.cppbuilder.nativeapi
Article #5077Re: Setting focus onto WS_CHILD type window
From: Pawel Tatera
Date: Tue, 08 Nov 2005 22:15
Date: Tue, 08 Nov 2005 22:15
95 lines
3202 bytes
3202 bytes
Hi.
Well I'm fighting with it wright now ;)
I have a main window proc and inside of it:
...
HWND childW;
switch (message){
case WM_CREATE:
.....
childW=CreateChildWindow(hwnd, hInst);
return 0;
case WM_CHAR:
switch (wParam) {
case 0x09: //TAB KEY
SetFocus(childW);
break;
default:
break;
}
break;
....
The CreateChildWindow(hwnd, hInst) is in another file and looks like this:
CreateChildWindow(HWND hwndParent, HINSTANCE hInstance){
HWND adminbox;
WNDCLASS wcChild;
//MSG msg;
LPCSTR cName="CHILD_BOX";
wcChild.style = CS_HREDRAW | CS_VREDRAW;
wcChild.lpfnWndProc = AdminBoxProc;
wcChild.cbClsExtra = 0;
wcChild.cbWndExtra = 0;
wcChild.hInstance = hInstance;
wcChild.hIcon = NULL;
wcChild.hCursor = LoadCursor (NULL, IDC_ARROW);
wcChild.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1);
wcChild.lpszMenuName = NULL;
wcChild.lpszClassName = cName;
RegisterClass (&wcChild);
adminbox = CreateWindowEx(
NULL,
(LPCSTR) cName,
(LPCSTR) "Window",
TS_ADMINBOX_STYLE, //(WS_CHILD | WS_EX_CONTROLPARENT | WS_CLIPSIBLINGS
| WS_CAPTION | WS_VISIBLE)
0,0,
TS_ADMINBOX_SIZE_X, //200
TS_ADMINBOX_SIZE_Y, //100
(HWND) hwndParent,
(HMENU) TS_ADMINBOX_DLG, //0x105
(HINSTANCE) hInstance,
NULL);
return adminbox;
}
and the AdminBoxProc looks like:
....
LRESULT APIENTRY AdminBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{ switch (message){
case WM_SETFOCUS:
SetForegroundWindow(hwnd);
return 0;
default:
break;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
That's what Ive got. Theres no problem if I switch the focus between the
dialogs created as WS_POPUPWINDOW or WS_OVERLAPPEDWINDOW (SetFocus() is not
even needed for it). But for WS_CHILD .... ???
PawelT
>
> "Pawel Tatera" <paweltatera@pa80.chodziez.sdi.tpnet.pl> wrote in message
> news:4371121c@newsgroups.borland.com...
>
> > My question is how to move the focus from the parent
> > window ... into a child window...?
>
> Did you try passing the client window's HWND to SetFocus()?
>
>
> Gambit
>
>
Technical Details
Message-ID:
<43712453@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4371121c@newsgroups.borland.com> <43711a9d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f21ed145e3c5197a X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Pawel Tatera" <paweltatera@pa80.chodziez.sdi.tpnet.pl> Newsgroups: borland.public.cppbuilder.nativeapi References: <4371121c@newsgroups.borland.com> <43711a9d$1@newsgroups.borland.com> Subject: Re: Setting focus onto WS_CHILD type window Date: Tue, 8 Nov 2005 23:15:05 +0100 Lines: 97 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 217.97.16.80 Message-ID: <43712453@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1131488339 217.97.16.80 (8 Nov 2005 14:18:59 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail