Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Arno Garrels
Francois PIETTE wrote:
 You must map
 old message numbers to the new message numbers before posting them to
 the new window.

I do not see how to map those numbers on a low level easily :( any idea? 


 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 
 
 - Original Message -
 From: Arno Garrels [EMAIL PROTECTED]
 To: ICS support mailing twsocket@elists.org
 Sent: Sunday, June 11, 2006 3:18 PM
 Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods
 
 
 Francois PIETTE wrote:
 In V6, how can I extract messages of the to be detached socket
 only? Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt,
 PM_REMOVE)? 
 
 No. This would retrieve all messages for all component sharing the
 same TIcsWndHandler.
 It is necessary to iterate thru FMsgMap to find all occurence of
 self and get the corresponding message numbers (see
 TIcsWndHandler.AllocateMsgHandler) to use in PeekMessage. It is not
 guaranteed that all messages numbers for a given component are
 contiguous altough it will most of the time.
 
 The problem is to retrieve all message from the old queue and post
 them in the new queue in the same order. This can be solved by
 examining the time member in TMsg record.
 
 Can you please help me? Something like below, or do I still haven't
 got it fully?
 
 procedure TIcsWndControl.MoveQueuedMessages(NewHwnd: HWND);
 var
I   : UINT;
Idx : Integer;
Msg : tagMsg;
P   : PMsg;
L   : TList;
 
function CmpFunc(Item1: Pointer; Item2: Pointer): Integer;
begin
if PMsg(Item1)^.time = PMsg(Item2)^.time then
Result := 0
else if PMsg(Item1)^.time  PMsg(Item2)^.time then
Result := 1
else
Result := -1;
end;
 
 begin
L := TList.Create;
try
I := 0;
while I  WH_MAX_MSG do
begin
if FWndHandler.FMsgMap[I] = Self then
begin
while PeekMessage(Msg, Handle, I +
 FWndHandler.FMsgLow,  I +
 FWndHandler.FMsgLow, PM_REMOVE) dobegin
New(P);
//P^.hwnd  := Msg.hwnd;
P^.message   := Msg.message;
P^.wParam:= Msg.wParam;
P^.lParam:= Msg.lParam;
P^.time  := Msg.time;
L.Add(P);
end;
end;
Inc(I);
end;
L.Sort(@CmpFunc);
for Idx := 0 to L.Count - 1 do
PostMessage(NewHwnd, PMsg(L[Idx])^.message,
 PMsg(L[Idx])^.wParam,
PMsg(L[Idx])^.lParam);
finally
for Idx := 0 to L.Count - 1 do
System.Dispose(L[IDX]);
L.Free;
end;
 end;
 
 
 
 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 
 
 
 - Original Message -
 From: Arno Garrels [EMAIL PROTECTED]
 To: ICS support mailing twsocket@elists.org
 Sent: Sunday, June 11, 2006 9:49 AM
 Subject: Re: [twsocket] Enhancements for Thread Attach/Detach
 methods 
 
 
 Francois PIETTE wrote:
 AFAIK winsock API function WSAAsyncSelect() is a common, blocking
 function. In this case it's called to disable winsock
 notifications. Because the window is detached/destroyed in
 subsequent lines. BTW: Same is done in V5.
 So for a short while the detached socket is windowless, that's
 why I suggested to wait w/o processing messages until it is
 attached again (not nice but worked for me).
 
 To be safe, the order should be:
 1) Stop notifications from winsock (WSAAsyncSelect) to the current
 (old) hidden window
 2) Create the new hidden window
 3) Extract all messages from old hidden window queue and push them
 to the new queue
 
 In V6, how can I extract messages of the to be detached socket
 only? Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt,
 PM_REMOVE)? 
 
 ---
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 
 4) Restart notifications from winsock to the new hidden window
 
 Probably a good idea to post a FD_READ message in the new queue
 between 3 and 4 above. Because it may happend that data has been
 received during the time interval when notifications have been
 disabled.
 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Francois Piette
No genius idea pops up from my head :-(
--
[EMAIL PROTECTED]
http://www.overbyte.be

- Original Message - 
From: Arno Garrels [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Monday, June 12, 2006 12:29 PM
Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods


 Francois PIETTE wrote:
  You must map
  old message numbers to the new message numbers before posting them to
  the new window.
 
 I do not see how to map those numbers on a low level easily :( any idea? 
 
 
  
  --
  [EMAIL PROTECTED]
  http://www.overbyte.be
  
  
  - Original Message -
  From: Arno Garrels [EMAIL PROTECTED]
  To: ICS support mailing twsocket@elists.org
  Sent: Sunday, June 11, 2006 3:18 PM
  Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods
  
  
  Francois PIETTE wrote:
  In V6, how can I extract messages of the to be detached socket
  only? Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt,
  PM_REMOVE)? 
  
  No. This would retrieve all messages for all component sharing the
  same TIcsWndHandler.
  It is necessary to iterate thru FMsgMap to find all occurence of
  self and get the corresponding message numbers (see
  TIcsWndHandler.AllocateMsgHandler) to use in PeekMessage. It is not
  guaranteed that all messages numbers for a given component are
  contiguous altough it will most of the time.
  
  The problem is to retrieve all message from the old queue and post
  them in the new queue in the same order. This can be solved by
  examining the time member in TMsg record.
  
  Can you please help me? Something like below, or do I still haven't
  got it fully?
  
  procedure TIcsWndControl.MoveQueuedMessages(NewHwnd: HWND);
  var
 I   : UINT;
 Idx : Integer;
 Msg : tagMsg;
 P   : PMsg;
 L   : TList;
  
 function CmpFunc(Item1: Pointer; Item2: Pointer): Integer;
 begin
 if PMsg(Item1)^.time = PMsg(Item2)^.time then
 Result := 0
 else if PMsg(Item1)^.time  PMsg(Item2)^.time then
 Result := 1
 else
 Result := -1;
 end;
  
  begin
 L := TList.Create;
 try
 I := 0;
 while I  WH_MAX_MSG do
 begin
 if FWndHandler.FMsgMap[I] = Self then
 begin
 while PeekMessage(Msg, Handle, I +
  FWndHandler.FMsgLow,  I +
  FWndHandler.FMsgLow, PM_REMOVE) dobegin
 New(P);
 //P^.hwnd  := Msg.hwnd;
 P^.message   := Msg.message;
 P^.wParam:= Msg.wParam;
 P^.lParam:= Msg.lParam;
 P^.time  := Msg.time;
 L.Add(P);
 end;
 end;
 Inc(I);
 end;
 L.Sort(@CmpFunc);
 for Idx := 0 to L.Count - 1 do
 PostMessage(NewHwnd, PMsg(L[Idx])^.message,
  PMsg(L[Idx])^.wParam,
 PMsg(L[Idx])^.lParam);
 finally
 for Idx := 0 to L.Count - 1 do
 System.Dispose(L[IDX]);
 L.Free;
 end;
  end;
  
  
  
  
  --
  [EMAIL PROTECTED]
  http://www.overbyte.be
  
  
  
  - Original Message -
  From: Arno Garrels [EMAIL PROTECTED]
  To: ICS support mailing twsocket@elists.org
  Sent: Sunday, June 11, 2006 9:49 AM
  Subject: Re: [twsocket] Enhancements for Thread Attach/Detach
  methods 
  
  
  Francois PIETTE wrote:
  AFAIK winsock API function WSAAsyncSelect() is a common, blocking
  function. In this case it's called to disable winsock
  notifications. Because the window is detached/destroyed in
  subsequent lines. BTW: Same is done in V5.
  So for a short while the detached socket is windowless, that's
  why I suggested to wait w/o processing messages until it is
  attached again (not nice but worked for me).
  
  To be safe, the order should be:
  1) Stop notifications from winsock (WSAAsyncSelect) to the current
  (old) hidden window
  2) Create the new hidden window
  3) Extract all messages from old hidden window queue and push them
  to the new queue
  
  In V6, how can I extract messages of the to be detached socket
  only? Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt,
  PM_REMOVE)? 
  
  ---
  Arno Garrels [TeamICS]
  http://www.overbyte.be/eng/overbyte/teamics.html
  
  
  
  4) Restart notifications from winsock to the new hidden window
  
  Probably a good idea to post a FD_READ message in the new queue
  between 3 and 4 above. Because it may happend that data has been
  received during the time interval when notifications have been
  disabled.
  
  --
  [EMAIL PROTECTED]
  http://www.overbyte.be
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org/mailman/listinfo/twsocket
  Visit our website at http://www.overbyte.be
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org

Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Stadin, Benjamin

 I do not see how to map those numbers on a low level easily :( any idea?

I'm trying to follow. How do the old and the new message numbers differ?
What do the old and new numbers look like, can you maybe give a small
example list?
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Francois PIETTE
 I do not see how to map those numbers on a low level easily :( any idea?

 I'm trying to follow. How do the old and the new message numbers differ?
 What do the old and new numbers look like, can you maybe give a small
 example list?

There can be no relation at all between the two sets ! Of course with simple 
case, the two sets will looks the same. But it will not be the case when 
component are destroyed and other created, specially when there are several 
component types involeved, having each one a different number of message 
numbers.

--
[EMAIL PROTECTED]
http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Stadin, Benjamin
Francois PIETTE schrieb:

  I do not see how to map those numbers on a low level easily :( any
idea?
 
  I'm trying to follow. How do the old and the new message numbers differ?
  What do the old and new numbers look like, can you maybe give a small
  example list?

 There can be no relation at all between the two sets ! Of course with
simple
 case, the two sets will looks the same. But it will not be the case when
 component are destroyed and other created, specially when there are
several
 component types involeved, having each one a different number of message
 numbers.

So what kind of mapping are you looking for? Which relationship do you need
to preserve?
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Francois PIETTE
 So what kind of mapping are you looking for?
 Which relationship do you need to preserve?

A component has allocated a number of message numbers (the messages are now 
identified by variables since a lot of components share the same hidden 
window). When the component is attached to another thread, any message still 
in the old message queue has to be pulled out and posted into the new queue. 
Before being posted to the new queue, the old messages numbers have to be 
mapped to the new ones. See TCustomWSocket.AllocateMsgHandlers for 
reference.

I think we don't have enough information saved to do this mapping. Probably 
TIcsWndHandler.AllocateMsgHandler sould take one more argument to permit the 
mapping. This argument would be saved in TIcsWndHandler.FMsgMap so that it 
is available afterward to do the mapping.

--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: Stadin, Benjamin [EMAIL PROTECTED]
To: twsocket@elists.org
Sent: Monday, June 12, 2006 8:58 PM
Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods


 Francois PIETTE schrieb:

  I do not see how to map those numbers on a low level easily :( any
 idea?
 
  I'm trying to follow. How do the old and the new message numbers 
  differ?
  What do the old and new numbers look like, can you maybe give a small
  example list?

 There can be no relation at all between the two sets ! Of course with
 simple
 case, the two sets will looks the same. But it will not be the case when
 component are destroyed and other created, specially when there are
 several
 component types involeved, having each one a different number of message
 numbers.

 So what kind of mapping are you looking for? Which relationship do you 
 need
 to preserve?
 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Stadin, Benjamin
Francois PIETTE schrieb:

  So what kind of mapping are you looking for?
  Which relationship do you need to preserve?

 A component has allocated a number of message numbers (the messages are
now
 identified by variables since a lot of components share the same hidden
 window). When the component is attached to another thread, any message
still
 in the old message queue has to be pulled out and posted into the new
queue.
 Before being posted to the new queue, the old messages numbers have to be
 mapped to the new ones. See TCustomWSocket.AllocateMsgHandlers for
 reference.


Would it be possible to have one prime number per component, and the message
numbers the component allocates are a multiple of this prime?


 I think we don't have enough information saved to do this mapping.
Probably
 TIcsWndHandler.AllocateMsgHandler sould take one more argument to permit
the
 mapping. This argument would be saved in TIcsWndHandler.FMsgMap so that it
 is available afterward to do the mapping.

 -- 
 [EMAIL PROTECTED]
 http://www.overbyte.be

 - Original Message -
 From: Stadin, Benjamin [EMAIL PROTECTED]
 To: twsocket@elists.org
 Sent: Monday, June 12, 2006 8:58 PM
 Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods

  Francois PIETTE schrieb:
 
   I do not see how to map those numbers on a low level easily :( any
  idea?
  
   I'm trying to follow. How do the old and the new message numbers
   differ?
   What do the old and new numbers look like, can you maybe give a small
   example list?
 
  There can be no relation at all between the two sets ! Of course with
  simple
  case, the two sets will looks the same. But it will not be the case
when
  component are destroyed and other created, specially when there are
  several
  component types involeved, having each one a different number of
message
  numbers.
 
  So what kind of mapping are you looking for? Which relationship do you
  need
  to preserve?
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org/mailman/listinfo/twsocket
  Visit our website at http://www.overbyte.be

 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-12 Thread Francois PIETTE
 A component has allocated a number of message numbers (the messages are
 now identified by variables since a lot of components share the same 
 hidden
 window). When the component is attached to another thread, any message
 still in the old message queue has to be pulled out and posted into the 
 new
 queue.

 Before being posted to the new queue, the old messages numbers have to be
 mapped to the new ones. See TCustomWSocket.AllocateMsgHandlers for
 reference.

 Would it be possible to have one prime number per component, and the 
 message
 numbers the component allocates are a multiple of this prime?

Would be very difficult.
Message numbers are given by the TIcsWndHandler class, not the component nor 
his derived.
Messages numbers are 16 bit integers. Available numbers start at WM_USER.
The handler allocate at most WH_MAX_MSG (currently 100) message be hidden 
window.

--
[EMAIL PROTECTED]
http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-11 Thread Arno Garrels
Francois PIETTE wrote:
 AFAIK winsock API function WSAAsyncSelect() is a common, blocking
 function. In this case it's called to disable winsock notifications.
 Because the window is detached/destroyed in subsequent lines.
 BTW: Same is done in V5.
 So for a short while the detached socket is windowless, that's
 why I suggested to wait w/o processing messages until it is
 attached again (not nice but worked for me).
 
 To be safe, the order should be:
 1) Stop notifications from winsock (WSAAsyncSelect) to the current
 (old) hidden window
 2) Create the new hidden window
 3) Extract all messages from old hidden window queue and push them to
 the new queue

In V6, how can I extract messages of the to be detached socket only?
Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt, PM_REMOVE)?  

---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html



 4) Restart notifications from winsock to the new hidden window
 
 Probably a good idea to post a FD_READ message in the new queue
 between 3 and 4 above. Because it may happend that data has been
 received during the time interval when notifications have been
 disabled. 
 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-11 Thread Francois PIETTE
 In V6, how can I extract messages of the to be detached socket only?
 Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt, PM_REMOVE)?

No. This would retrieve all messages for all component sharing the same 
TIcsWndHandler.
It is necessary to iterate thru FMsgMap to find all occurence of self and 
get the corresponding message numbers (see 
TIcsWndHandler.AllocateMsgHandler) to use in PeekMessage. It is not 
guaranteed that all messages numbers for a given component are contiguous 
altough it will most of the time.

The problem is to retrieve all message from the old queue and post them in 
the new queue in the same order. This can be solved by examining the time 
member in TMsg record.

--
[EMAIL PROTECTED]
http://www.overbyte.be



- Original Message - 
From: Arno Garrels [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Sunday, June 11, 2006 9:49 AM
Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods


 Francois PIETTE wrote:
 AFAIK winsock API function WSAAsyncSelect() is a common, blocking
 function. In this case it's called to disable winsock notifications.
 Because the window is detached/destroyed in subsequent lines.
 BTW: Same is done in V5.
 So for a short while the detached socket is windowless, that's
 why I suggested to wait w/o processing messages until it is
 attached again (not nice but worked for me).

 To be safe, the order should be:
 1) Stop notifications from winsock (WSAAsyncSelect) to the current
 (old) hidden window
 2) Create the new hidden window
 3) Extract all messages from old hidden window queue and push them to
 the new queue

 In V6, how can I extract messages of the to be detached socket only?
 Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt, PM_REMOVE)?

 ---
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html



 4) Restart notifications from winsock to the new hidden window

 Probably a good idea to post a FD_READ message in the new queue
 between 3 and 4 above. Because it may happend that data has been
 received during the time interval when notifications have been
 disabled.

 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-11 Thread Arno Garrels
Francois PIETTE wrote:
 In V6, how can I extract messages of the to be detached socket only?
 Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt, PM_REMOVE)?
 
 No. This would retrieve all messages for all component sharing the
 same TIcsWndHandler.
 It is necessary to iterate thru FMsgMap to find all occurence of self
 and get the corresponding message numbers (see
 TIcsWndHandler.AllocateMsgHandler) to use in PeekMessage. It is not
 guaranteed that all messages numbers for a given component are
 contiguous altough it will most of the time.
 
 The problem is to retrieve all message from the old queue and post
 them in the new queue in the same order. This can be solved by
 examining the time member in TMsg record.

Can you please help me? Something like below, or do I still haven't
got it fully?

procedure TIcsWndControl.MoveQueuedMessages(NewHwnd: HWND);
var
I   : UINT;
Idx : Integer;
Msg : tagMsg;
P   : PMsg;
L   : TList;

function CmpFunc(Item1: Pointer; Item2: Pointer): Integer;
begin
if PMsg(Item1)^.time = PMsg(Item2)^.time then
Result := 0
else if PMsg(Item1)^.time  PMsg(Item2)^.time then
Result := 1
else
Result := -1;
end;

begin
L := TList.Create;
try
I := 0;
while I  WH_MAX_MSG do
begin
if FWndHandler.FMsgMap[I] = Self then
begin
while PeekMessage(Msg, Handle, I + FWndHandler.FMsgLow,
  I + FWndHandler.FMsgLow, PM_REMOVE) do
begin
New(P);
//P^.hwnd  := Msg.hwnd;
P^.message   := Msg.message;
P^.wParam:= Msg.wParam;
P^.lParam:= Msg.lParam;
P^.time  := Msg.time;
L.Add(P);
end;
end;
Inc(I);
end;
L.Sort(@CmpFunc);
for Idx := 0 to L.Count - 1 do
PostMessage(NewHwnd, PMsg(L[Idx])^.message, PMsg(L[Idx])^.wParam,
PMsg(L[Idx])^.lParam);
finally
for Idx := 0 to L.Count - 1 do
System.Dispose(L[IDX]);
L.Free;
end;
end;



 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 
 
 
 - Original Message -
 From: Arno Garrels [EMAIL PROTECTED]
 To: ICS support mailing twsocket@elists.org
 Sent: Sunday, June 11, 2006 9:49 AM
 Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods
 
 
 Francois PIETTE wrote:
 AFAIK winsock API function WSAAsyncSelect() is a common, blocking
 function. In this case it's called to disable winsock
 notifications. Because the window is detached/destroyed in
 subsequent lines. BTW: Same is done in V5.
 So for a short while the detached socket is windowless, that's
 why I suggested to wait w/o processing messages until it is
 attached again (not nice but worked for me).
 
 To be safe, the order should be:
 1) Stop notifications from winsock (WSAAsyncSelect) to the current
 (old) hidden window
 2) Create the new hidden window
 3) Extract all messages from old hidden window queue and push them
 to the new queue
 
 In V6, how can I extract messages of the to be detached socket only?
 Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt, PM_REMOVE)?
 
 ---
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 
 4) Restart notifications from winsock to the new hidden window
 
 Probably a good idea to post a FD_READ message in the new queue
 between 3 and 4 above. Because it may happend that data has been
 received during the time interval when notifications have been
 disabled.
 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Enhancements for Thread Attach/Detach methods

2006-06-11 Thread Arno Garrels
Francois PIETTE wrote:
 Can you please help me? Something like below,
 or do I still haven't got it fully?
 
 Looks partially good.
 The problem, if I understand your code correctly, is that for the new
 window, the message numbers have not the same numbers. You must map
 old message numbers to the new message numbers before posting them to
 the new window.

Your are right, it can't be done in a single method, probably there
should be a helper function to return queued messages in a Tlist, so 
they can be posted later after the thread has been attached again.

 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 
 
 - Original Message -
 From: Arno Garrels [EMAIL PROTECTED]
 To: ICS support mailing twsocket@elists.org
 Sent: Sunday, June 11, 2006 3:18 PM
 Subject: Re: [twsocket] Enhancements for Thread Attach/Detach methods
 
 
 Francois PIETTE wrote:
 In V6, how can I extract messages of the to be detached socket
 only? Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt,
 PM_REMOVE)? 
 
 No. This would retrieve all messages for all component sharing the
 same TIcsWndHandler.
 It is necessary to iterate thru FMsgMap to find all occurence of
 self and get the corresponding message numbers (see
 TIcsWndHandler.AllocateMsgHandler) to use in PeekMessage. It is not
 guaranteed that all messages numbers for a given component are
 contiguous altough it will most of the time.
 
 The problem is to retrieve all message from the old queue and post
 them in the new queue in the same order. This can be solved by
 examining the time member in TMsg record.
 
 Can you please help me? Something like below, or do I still haven't
 got it fully?
 
 procedure TIcsWndControl.MoveQueuedMessages(NewHwnd: HWND);
 var
I   : UINT;
Idx : Integer;
Msg : tagMsg;
P   : PMsg;
L   : TList;
 
function CmpFunc(Item1: Pointer; Item2: Pointer): Integer;
begin
if PMsg(Item1)^.time = PMsg(Item2)^.time then
Result := 0
else if PMsg(Item1)^.time  PMsg(Item2)^.time then
Result := 1
else
Result := -1;
end;
 
 begin
L := TList.Create;
try
I := 0;
while I  WH_MAX_MSG do
begin
if FWndHandler.FMsgMap[I] = Self then
begin
while PeekMessage(Msg, Handle, I +
 FWndHandler.FMsgLow,  I +
 FWndHandler.FMsgLow, PM_REMOVE) dobegin
New(P);
//P^.hwnd  := Msg.hwnd;
P^.message   := Msg.message;
P^.wParam:= Msg.wParam;
P^.lParam:= Msg.lParam;
P^.time  := Msg.time;
L.Add(P);
end;
end;
Inc(I);
end;
L.Sort(@CmpFunc);
for Idx := 0 to L.Count - 1 do
PostMessage(NewHwnd, PMsg(L[Idx])^.message,
 PMsg(L[Idx])^.wParam,
PMsg(L[Idx])^.lParam);
finally
for Idx := 0 to L.Count - 1 do
System.Dispose(L[IDX]);
L.Free;
end;
 end;
 
 
 
 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 
 
 
 - Original Message -
 From: Arno Garrels [EMAIL PROTECTED]
 To: ICS support mailing twsocket@elists.org
 Sent: Sunday, June 11, 2006 9:49 AM
 Subject: Re: [twsocket] Enhancements for Thread Attach/Detach
 methods 
 
 
 Francois PIETTE wrote:
 AFAIK winsock API function WSAAsyncSelect() is a common, blocking
 function. In this case it's called to disable winsock
 notifications. Because the window is detached/destroyed in
 subsequent lines. BTW: Same is done in V5.
 So for a short while the detached socket is windowless, that's
 why I suggested to wait w/o processing messages until it is
 attached again (not nice but worked for me).
 
 To be safe, the order should be:
 1) Stop notifications from winsock (WSAAsyncSelect) to the current
 (old) hidden window
 2) Create the new hidden window
 3) Extract all messages from old hidden window queue and push them
 to the new queue
 
 In V6, how can I extract messages of the to be detached socket
 only? Is it Peekmessage(Msg, OldHWnd, MsgLow, MsgLow + MsgCnt,
 PM_REMOVE)? 
 
 ---
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 
 4) Restart notifications from winsock to the new hidden window
 
 Probably a good idea to post a FD_READ message in the new queue
 between 3 and 4 above. Because it may happend that data has been
 received during the time interval when notifications have been
 disabled.
 
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
-- 
To unsubscribe