Tk Source Code

View Ticket
Login
Ticket UUID: 1024364
Title: option -use does not work properly under Windows
Type: Bug Version: None
Submitter: arjenmarkus Created on: 2004-09-08 13:04:14
Subsystem: 68. Win Window Operations Assigned To: hobbs
Priority: 8 Severity:
Status: Closed Last Modified: 2004-12-20 01:34:29
Resolution: Accepted Closed By: chengyemao
    Closed on: 2004-12-19 18:34:29
Description:
I was exploring the possibility to embed a Tk window in
a window owned by another program and so I first tried
the following script:

exec wish -use [winfo id .] &

in the console window under Windows 98 and Windows XP
(using 8.4.1 repsectively 8.4.5).

This causes a crash (a messagebox with an application
error comes up - memory referenced at some invalid
address or a message of similar wordings)
User Comments: chengyemao added on 2004-12-20 01:34:29:
Logged In: YES 
user_id=191079

With the latest change in Tk85, a warning dialog box will pop 
up to indicate a failure of container identification if the use-
window is not a container.  It is up to the user to choose 
either proceeding for attachment or cancel since we can't 
expect all Tk container applications will be able to do or have 
done the identification correctly in processing attach 
request.  In the latest Tk85, I'm not able to duplicate the 
crash with a use-id of a non-container Tk window. I did my 
tests in Windows XP Pro (SP2)

dgp added on 2004-10-27 05:47:30:
Logged In: YES 
user_id=80530

backport.

dkf added on 2004-09-09 19:18:32:
Logged In: YES 
user_id=79902

Clarified wish.1; leaving bug open as we might wish to
consider whether we can to things to stop the crash from
happening.

arjenmarkus added on 2004-09-09 18:57:35:
Logged In: YES 
user_id=400048

Yes, that does indeed do the trick. Thanks. 
The remaining problem now is: how can I embed a Tk window in
another application? (Well, that is a different question
altogether.)

Okay, the code fragment I found in the book by Brent Welch
was not very explicit about the frame (it is there, but I
overlooked that line and it is not clear that this is
essential). More importantly: the man page for wish does not
mention a container at all

beric added on 2004-09-09 18:41:46:
Logged In: YES 
user_id=493507

I think you don't use the fonctionnality well.
Try:

frame .f -container 1
pack .f
exec wish -use [winfo id .f]  &

The second wish will be displayed inside .f.

Anyway, this shouldn't crash.
The code responsible of the crash is in TkWinEmbed.c (1.7),
at the start of TkWinEmbeddedEventProc(), when the Container
structure is searched.
tsdPtr->firstContainerPtr is NULL.