up
我以前也提过这个问题,可是没有解决!

解决方案 »

  1.   

    我没接触过directx编程,只能给你提供个资料了。在DirectX编程中,IDirectDraw2对象有一个方法名为SetCooperativeLevel,功能是指定该对象的性能级别。调用该方法需要指定一个窗口Handle,在C++中可简单地指定为主程序的窗口Handle,而在Delphi中,如果设定的级别为全屏幕独占方式,则这个Handle一定要是Application.Handle而不是MainForm.Handle,这一点在我所见到的所有关于DirectDraw的封装、构件中均未得见。
      在设定为全屏幕独占方式时,还要先使Application.Handle所代表的窗口显示在最前方,否则下一步调用CreateSurface方法就会失败。这一点也是我几经尝试才总结出来的。请见示例代码:function CreateFullScreen(out DDrawObj:IDirectDraw2): HRESULT
    var
      lpDD : IDirectDraw;
    begin
      Result := DirectDrawCreate(nil, lpDD, nil);
      if Result<>DD_OK then
        raise Exception.Create('Failed Create!');
      Result := lpDD.QueryInterface(IID_IDirectDraw2, DDrawObj):
      if Result<>DD_OK then
        raise Exception.Create('Failed QueryInterface!');
      ShowWindow(Application.Handle, SW_SHOWMAXIMIZED);
      Result := DDrawObj.SetCooperativeLevel(
        Application.Handle, {很重要,一定要是Application窗口}
        DDSCL_FULLSCREEN or DDSCL_EXCLUSIVE);
      if Result<>DD_OK then
        raise Exception.Create('Failed SetCooperativeLevel');  Result := DDrawObj.SetDisplayMode(640,480,8,0,0);
    end;