Original Post
could anyone help me with this. i'm trying to setup directdraw, but i get various errors, eg access violation or invalid property. how can i fix this. sometimes i does run without any errors but then i get a white screen and nothing is drawn :S Why? any help is appreciated! :D here's my source code, written in delphi: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DirectDraw; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Draw(Sender: TObject; var Done: Boolean); private DD: IDIRECTDRAW7; primary: IDIRECTDRAWSURFACE7; back: IDIRECTDRAWSURFACE7; ddsd: DDSURFACEDESC2; ddscaps: DDSCAPS2; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var res: HRESULT; begin res := DirectDrawCreateEx(nil, DD, IID_IDirectDraw7, nil); if not(res = dd_OK) then Close; res := DD.SetCooperativeLevel(Handle,DDSCL_EXCLUSIVE or DDSCL_FULLSCREEN or DDSCL_ALLOWREBOOT ); if not(res = DD_OK) then Close; res := DD.SetDisplayMode(800,600,16,0,0); if not(res = DD_OK) then Close; ZeroMemory(@ddsd, SizeOf(ddsd)); ddsd.dwSize := SizeOf(ddsd); ddsd.dwFlags := DDSD_CAPS or DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps := DDSCAPS_PRIMARYSURFACE or DDSCAPS_FLIP or DDSCAPS_COMPLEX; ddsd.dwBackBufferCount := 1; res := DD.CreateSurface(ddsd, primary, nil); if not(res = DD_OK) or (primary <> nil) then Close; res := primary.GetAttachedSurface(ddscaps, back); if not(res = DD_OK) or (back <> nil) then Close; Application.OnIdle := Draw; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin back._Release; back := nil; primary._Release; primary := nil; DD._Release; DD := nil; end; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if(Key = VK_ESCAPE) then Application.Terminate; end; procedure TForm1.Draw(Sender: TObject; var Done: Boolean); var ddbltfx: _DDBLTFX; begin if back = nil then begin ShowMessage('back surface pointer error'); Close; end else begin ddbltfx.dwSize := sizeof(ddbltfx); ddbltfx.dwFillColor := 0; back.Blt(nil,nil,nil,DDBLT_COLORFILL, @ddbltfx); end; end; end. Thanx