After some research to find out how, thanks to the
tclplugin, these special windows messages need to be
handled by a window that will act as a container:
// --------- Begin Tk container specials ----------
#define TK_CLAIMFOCUS (WM_USER)
#define TK_GEOMETRYREQ (WM_USER+1)
#define TK_ATTACHWINDOW (WM_USER+2)
#define TK_DETACHWINDOW (WM_USER+3)
case TK_CLAIMFOCUS:
if (wParam || (GetFocus() != NULL)) {
::SetFocus(pBlank->hAttach);
}
return 0;
case TK_GEOMETRYREQ:
::SetWindowPos(hwnd, NULL, 0, 0, wParam,
lParam,
SWP_NOMOVE | SWP_NOZORDER
| SWP_NOACTIVATE);
return 0;
case TK_ATTACHWINDOW:
pBlank->hAttach = (HWND)wParam;
::SetParent(pBlank->hAttach, hwnd);
return 0;
case TK_DETACHWINDOW:
pBlank->hAttach = NULL;
::PostMessage(hwnd, WM_CLOSE, 0, 0);
return 0;
// --------- End Tk container specials ----------
And this is working fine for me with:
package require Tk
toplevel .mdi -use [IRC::makeblank]
text .mdi.t
pack .mdi.t
Yet, I can't resize the window. For each size change
change sent, an equal TK_GEOMETRYREQ sent back to
return it to where it was. There is no message interface
for me to tell it to resize.
case WM_SIZE:
if (wParam != SIZE_MINIMIZED && pBlank-
>hAttach) {
goes bang-> //::SendMessage(pBlank->hAttach,
TK_GEOMETRYREQ,
// LOWORD(lParam), HIWORD
(lParam));
forced back-> //::SetWindowPos(pBlank->hAttach,
NULL, 0, 0,
// LOWORD(lParam), HIWORD
(lParam),
// SWP_NOMOVE |
SWP_NOZORDER | SWP_NOACTIVATE);
NO!!!-> //Tk_GeometryRequest
(Tk_HWNDToWindow(pBlank->hAttach),
// LOWORD(lParam), HIWORD
(lParam));
}
// must fall to DefMDIChildProc(), or bad
things happen.
//
break;
I can't call any Tk functions or my app becomes
dependant on it. I am in the same process and could
call Tk functions, but if this window was out-of-process,
this would not work and is useless.
The ability to send a message to the attached window
to tell the geometry manager to resize is required.
test case
Logged In: YES
user_id=7549
uploaded isolated test case.
Resizing is very unfriendly.
Logged In: YES
user_id=7549
To use the test app,
1) start it up and the messagebox will display the "window id"
2) from a wish process do:
toplevel .a -use <window id>
text .a.t
pack .a.t
3) click the ok on the messagebox, then manipulate
the container's size. Resizing is very bouncy and unclean.
What's happening is Tk is trying to force it back to where it
wants it instead of accepting the size change.
4) now do:
destroy .a
Notice the container is not told of the unattach. If it was
told, the app would close.
Logged In: YES
user_id=7549
Played with the example and got it to work. By selectively
turning off TK_GEOMETRYREQ when the user is changing the
size, the application now works.
But.. Here's where it gets strange.. in-process embedding
doesn't behave the same way. Although the example is now
working, the same logic doesn't work in-process (??).
I'd upload an example, but would too large. I'm at a loss for
how to solve this.
example that works out-of-process.
Logged In: YES
user_id=191079
The bug has been fixed for a Tk container. The following files
have been changed: tkWinX.c, tkWinEmbed.c, tkWinWm.c
and tkWindow.c to process the TK_GEOMETRYREQ message
and cleanup container list properly.
Logged In: YES
user_id=6544
I notice in CVS head that your changes to tkWinEmbed.c did
not involve including the TK_CLAIMFOCUS code from the above
original bug report. I think that code will fix the focus
bug described in bugs 220851 and 480158. I checked out CVS
head and added the following to TkWinEmbeddedEventProc and
it seemed to fix the focus problem in embedded windows.
case TK_CLAIMFOCUS:
if (wParam || (GetFocus() != NULL)) {
SetFocus(containerPtr->embeddedHWnd);
}
return 0;
I use the following code to test the focus before and after
the above code change:
package require Tk
pack [frame .f -container 1]
interp create s
s eval [list set argv [list -use [winfo id .f]]]
s eval {
package require Tk
pack [text .t]
}
Before adding the TK_CLAIMFOCUS change, clicking on the text
widget and typing have no effect. After adding the change,
the focus moves to the embedded text widget no problem.
Any chance you can checkin the CLAIMFOCUS code as well?
Logged In: YES
user_id=191079
I just checked in additional code for feature implemetation of
embedded/embedding, including the code that handles
TK_CLAIMFOCUS. Focus including input from keyboard should
work now.