C
czw6296
Unregistered / Unconfirmed
GUEST, unregistred user!
以下程序来自C++Builder6的示例程序。
ddrval = DirectDrawCreate(NULL, &lpDD, NULL);
if(ddrval == DD_OK)
{
ddrval = lpDD->SetCooperativeLevel(Handle,DDSCL_NORMAL);
//Handle改为PaintBox1->Canvas->Handle就出错,为什么
if(ddrval == DD_OK)
{
ddrval = lpDD->SetDisplayMode(1024, 768, 24);
if(ddrval == DD_OK)
{
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
ddrval = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
if(ddrval == DD_OK)
{
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps,
&lpDDSBack);
if(ddrval == DD_OK)
{
if (lpDDSPrimary->GetDC(&DC) == DD_OK)
{
SetBkColor(DC, RGB(0, 0, 255));
SetTextColor(DC, RGB(255, 255, 0));
TextOut(DC, 0, 0, FrontMsg.c_str(), FrontMsg.Length());
lpDDSPrimary->ReleaseDC(DC);
}
if (lpDDSBack->GetDC(&DC) == DD_OK)
{
SetBkColor(DC, RGB(0, 0, 255));
SetTextColor(DC, RGB(255, 255, 0));
TextOut(DC, 0, 0, BackMsg.c_str(), BackMsg.Length());
lpDDSBack->ReleaseDC(DC);
}
Timer1->Enabled = True;
bActive = True;
return;
}
}
}
}
}
wsprintf(buf, "Direct Draw Init Failed (%08lx)/n", ddrval);
MessageBox(Handle, buf, "ERROR", MB_OK);
}
ddrval = DirectDrawCreate(NULL, &lpDD, NULL);
if(ddrval == DD_OK)
{
ddrval = lpDD->SetCooperativeLevel(Handle,DDSCL_NORMAL);
//Handle改为PaintBox1->Canvas->Handle就出错,为什么
if(ddrval == DD_OK)
{
ddrval = lpDD->SetDisplayMode(1024, 768, 24);
if(ddrval == DD_OK)
{
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
ddrval = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
if(ddrval == DD_OK)
{
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps,
&lpDDSBack);
if(ddrval == DD_OK)
{
if (lpDDSPrimary->GetDC(&DC) == DD_OK)
{
SetBkColor(DC, RGB(0, 0, 255));
SetTextColor(DC, RGB(255, 255, 0));
TextOut(DC, 0, 0, FrontMsg.c_str(), FrontMsg.Length());
lpDDSPrimary->ReleaseDC(DC);
}
if (lpDDSBack->GetDC(&DC) == DD_OK)
{
SetBkColor(DC, RGB(0, 0, 255));
SetTextColor(DC, RGB(255, 255, 0));
TextOut(DC, 0, 0, BackMsg.c_str(), BackMsg.Length());
lpDDSBack->ReleaseDC(DC);
}
Timer1->Enabled = True;
bActive = True;
return;
}
}
}
}
}
wsprintf(buf, "Direct Draw Init Failed (%08lx)/n", ddrval);
MessageBox(Handle, buf, "ERROR", MB_OK);
}