isgbuddy wrote: > Hoho, > > Many thanks. These code exactly worked. > > Why the same code don't have problem in Delphi 7? Can you fix these > code to ICS source?
My code below does not work with Delphi 7 as well. You probably used ICS V5 with Delphi 7. I guess that the V5 components did not create their hidden window in the constructor but later when the window is actually needed. Using ICS in a thread anyway requires a working message pump, so I don't know whether it was a real improvement if we created the hidden window at some later time. Note that ICS creates one or more hidden windows and once a window is created there must exist a working message pump, otherwise entire application may freeze. -- Arno Garrels > > Arno Garrels wrote: >> isgbuddy wrote: >> >> >>> You don't need a Chinese windows. You just install East Asian input >>> method in your windows. Then you will get this issue. >>> >> >> Ok, finally it repeated. The problem is that the thread requires >> a message pump if it owns a window. It is _neither_ a problem related >> to ICS nor to Delphi! You'll see the same freeze when you create a >> window >> by calling Classes.AllocateHwnd(). Uncomment the commented lines >> below >> to make it working: >> >> unit Unit1; >> >> interface >> >> uses >> Windows, Messages, SysUtils, Variants, Classes, Graphics, >> Controls, Forms, Dialogs, StdCtrls; >> >> type >> TForm1 = class(TForm) >> Button1: TButton; >> Edit1: TEdit; >> procedure FormCreate(Sender: TObject); >> private >> { Private declarations } >> public >> { Public declarations } >> end; >> >> TTestThread = class(TThread) >> private >> FHandle : HWND; >> procedure WndProc(var MsgRec: TMessage); >> protected >> procedure Execute;override; >> end; >> >> var >> Form1: TForm1; >> >> implementation >> >> {$R *.dfm} >> >> { TTestThread } >> procedure TTestThread.WndProc(var MsgRec: TMessage); >> begin >> MsgRec.Result := DefWindowProc(FHandle, MsgRec.Msg, MsgRec.wParam, >> MsgRec.lParam); end; >> >> procedure TTestThread.Execute; >> var >> Msg: TMsg; >> begin >> // PeekMessage(Msg, 0, 0, 0, PM_NOREMOVE); // Initialize thread's >> message queue >> >> FHandle := Classes.AllocateHWnd(WndProc); // Create a hidden window >> >> {while not Terminated do >> begin >> while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do >> begin >> if Msg.message = WM_QUIT then >> Terminate >> else begin >> TranslateMessage(Msg); >> DispatchMessage(Msg); >> end; >> end;} >> >> Sleep(1000); >> end; >> end; >> >> >> procedure TForm1.FormCreate(Sender: TObject); >> begin >> with TTestThread.Create(true) do Resume; >> end; >> >> end. >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be