I created a TMSQuery component in my subthread,
when I press Ctrl + Shift or Ctrl + Space (input method switching), will cause the program to stops responding.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ActiveX, StdCtrls, DB, MemDS, DBAccess, MSAccess;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TDBThread = class(TThread)
private
protected
procedure Execute; override;
public
constructor Create;
end;
var
Form1: TForm1;
DBThread: TDBThread;
implementation
{$R *.dfm}
constructor TDBThread.Create;
begin
inherited Create(False);
FreeOnTerminate := True;
end;
procedure TDBThread.Execute;
var
DBQuery: TMSQuery;
begin
if CoInitializeEx(nil, COINIT_APARTMENTTHREADED) S_OK then
raise Exception.Create(SysErrorMessage(GetLastError));
DBQuery := TMSQuery.Create(nil);
try
while not Terminated do
Sleep(500);
finally
DBQuery.Free;
CoUninitialize;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DBThread := TDBThread.Create;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DBThread.Terminate;
end;
end.
I used Spy++ found that when creating TMSQuery components, will create an implied "TOraAlerterWindow" Window and a "Default IME" window.
, Windows will send a series of WM_IME_* messages to IME window(by SendMessage) When I press Ctrl + Shift or Ctrl + Space.
My OS: Windows XP Pro + SP2 (Simplified Chinese version)
Regards
Visli