D
delphi-abc
Unregistered / Unconfirmed
GUEST, unregistred user!
问题见标题。
我的代码如下:
procedure TForm1.FormCreate(Sender: TObject);
begin
dc:=getdc(handle);
setuppixelformat(dc);
end;
procedure TForm1.SetupPixelFormat(dc:HDC);
Const
Pfd : PIXELFORMATDESCRIPTOR = (
nSize : SizeOf (PIXELFORMATDESCRIPTOR);
nVersion : 1;
dwFlags : PFD_DRAW_TO_WINDOW Or PFD_SUPPORT_OPENGL Or PFD_DOUBLEBUFFER;
iPixelType : PFD_TYPE_RGBA;
cColorBits : 32;
cRedBits : 0;
cRedShift : 0;
cGreenBits : 0;
cBlueBits : 0;
cBlueShift : 0;
cAlphaBits : 0;
cAlphaShift : 0;
cAccumBits : 0;
cAccumRedBits : 0;
cAccumGreenBits : 0;
cAccumBlueBits : 0;
cAccumAlphaBits : 0;
cDepthBits : 32;
cStencilBits : 0;
cAuxBuffers : 0;
iLayerType : PFD_MAIN_PLANE;
bReserved : 0;
dwLayerMask : 0;
dwVisibleMask : 0;
dwDamageMask : 0);
Var
PixelFormat : Integer;
begin
PixelFormat:=ChoosePixelFormat(dc,@pfd); //此处PixelFormat的值始终为0
if SetPixelFormat(dc,PixelFormat,@pfd)=false then
begin
messagebox(0,'Set PixelFormat failed!','Error',MB_OK);
exit;
end;
end;
我的代码如下:
procedure TForm1.FormCreate(Sender: TObject);
begin
dc:=getdc(handle);
setuppixelformat(dc);
end;
procedure TForm1.SetupPixelFormat(dc:HDC);
Const
Pfd : PIXELFORMATDESCRIPTOR = (
nSize : SizeOf (PIXELFORMATDESCRIPTOR);
nVersion : 1;
dwFlags : PFD_DRAW_TO_WINDOW Or PFD_SUPPORT_OPENGL Or PFD_DOUBLEBUFFER;
iPixelType : PFD_TYPE_RGBA;
cColorBits : 32;
cRedBits : 0;
cRedShift : 0;
cGreenBits : 0;
cBlueBits : 0;
cBlueShift : 0;
cAlphaBits : 0;
cAlphaShift : 0;
cAccumBits : 0;
cAccumRedBits : 0;
cAccumGreenBits : 0;
cAccumBlueBits : 0;
cAccumAlphaBits : 0;
cDepthBits : 32;
cStencilBits : 0;
cAuxBuffers : 0;
iLayerType : PFD_MAIN_PLANE;
bReserved : 0;
dwLayerMask : 0;
dwVisibleMask : 0;
dwDamageMask : 0);
Var
PixelFormat : Integer;
begin
PixelFormat:=ChoosePixelFormat(dc,@pfd); //此处PixelFormat的值始终为0
if SetPixelFormat(dc,PixelFormat,@pfd)=false then
begin
messagebox(0,'Set PixelFormat failed!','Error',MB_OK);
exit;
end;
end;