Delphi Multi-threaded switching method after the program suspended animation

Source: Internet
Author: User

http://bbs.csdn.net/topics/390472740

Delphi/pascal Code?
123456789101112131415161718192021222324252627282930313233343536373839 functionTCFADODBStorage.OpenConnection: Boolean;  //线程里打开ADOConnection,在XP下切换输入法程序会死掉  //原因:ADO自动创建一个ADODB.AsyncEventMessenger窗口,然后会有一个对应的IME窗口,但线程里没有消息循环  //     XP下输入法切换时会SendMessage给IME窗口并等待返回,IME窗口并不会处理消息,造成死锁  //这个函数把线程里的IME窗口释放掉,切换输入法时就不会有消息过来了  procedure_FreeIMEWindow;  const    IME_WINDOW_CLASS = ‘IME‘;    IME_WINDOW_TEXT  = ‘Default IME‘;  var    h : HWND;    pid : DWORD;    dh : HWND;  begin    h :=  FindWindow(IME_WINDOW_CLASS, IME_WINDOW_TEXT);    whileIsWindow(h) do    begin      ifGetWindowThreadProcessId(h, pid) = GetCurrentThreadId then        dh  :=  h      else        dh  :=  0;      h :=  FindWindowEx(0, h, IME_WINDOW_CLASS, IME_WINDOW_TEXT);      ifdh <> 0then        DestroyWindow(dh);    end;  end;begin  try    FConnection.ConnectionString  :=  ConnectionString;    FConnection.Connected :=  True;    ifGetCurrentThreadId <> Global.MainThreadID{全局的主线程ID,如果是主线程,不需要Free}then      _FreeIMEWindow;  exceptonE: Exception do    FLastErrorMessage :=  e.Message;  end;  Result  :=  FConnection.Connected;end;
Useful to me [0] throw a brick [0] reference | Report | Management
concern
Ysai
Ysai
This edition level:
#5 Score: 0 replies.: 2013-05-28 17:01:47 This problem I have been looking for a long time reason, landlord earned

Delphi Multi-threaded switching method after the program suspended animation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.