Direct3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
          

resentParams.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING,
          @PresentParams, Direct3DDevice);
    Direct3DDevice.SetDialogBoxMode(true);
  case Msg.message of
    WM_IME_NOTIFY:
      begin
        case Msg.wParam of
          IMN_OPENCANDIDATE, IMN_CHANGECANDIDATE:
            GetCandList(Msg.hwnd);
          IMN_CLOSECANDIDATE:
            begin
              m_strCandList := ''; m_str := '';
            end;
        end;
        caption := m_str + ' ' + m_strCandList;
      end;
  end;
//GetCandList函数  获得候选字列表
function TMainForm.GetCandList(WinHandle: HWND): boolean;
var
  hHimc: HIMC;
  dwSize, i: Integer;
  pcan: 

CandidateList;
  temp: array of tagCANDIDATELIST;
  buf: array[0..20] of char;
begin
  Result := False;
  if GetKeyboardLayout(0) = 0 then
    Exit;
  hHimc := ImmGetContext(WinHandle); //取得输入上下文
  if hHimc = 0 then
    Exit;
//获取键盘输入字符  
fillchar(buf, 20, 0);
  ImmGetCompositionString(hHimc, GCS_COMPSTR, @buf, 20);
  m_str := buf;
 //获取输入汉字提示字串
  dwSize := ImmGetCandidateList(hHimc, 0, nil, 0);
  if dwSize > 0 then
  begin
    SetLength(temp, dwSize);
    pcan := @temp[0];
    ImmGetCandidateList(hHimc, 0, pcan, dwSize);
    if pcan.dwCount > 0 then
    begin
      i := 1;
      m_strCandList := '';
      while (i < pcan.dwCount - pcan.dwSelection + 1) and (i < pcan.dwPageSize + 1) do
      begin
        m_strCandList := m_strCandList + ' ' + Format('%d.%s', [i, 

Char(PChar(pcan) +
          pcan.dwOffset[pcan.dwSelection + i])]);
        i := i + 1;
      end;
    end;
  end;
  ImmReleaseContext(WinHandle, hHimc);
  Result := True;
end;