Original Post
I have a problem with a DelphiX component that I wanted to use.
It''s taking care of creating all the network interface stuff so I pretty much save a lot of work when I manage to use it.
But comonents actually require a form to drop on (unless you create them yourself).
Because I don''t have a form I have problems with the following procedure :
DXPlay.Create( AOwner : TComponent )
I CANT FIND the suitable component for it. I expected a TObject as parameter but TComponent is something I have no idea about...
So here''s my window function: (maybe you can find something to put in there)
function glCreateWnd(Width, Height : Integer; Fullscreen : Boolean; PixelDepth : Integer) : Boolean;
var
wndClass : TWndClass; // Window class
dwStyle : DWORD; // Window styles
dwExStyle : DWORD; // Extended window styles
dmScreenSettings : DEVMODE; // Screen settings
(fullscreen,etc...)
PixelFormat : GLuint; // Settings for the OpenGL
rendering
h_Instance : HINST; // Current instance
pfd : TPIXELFORMATDESCRIPTOR; // Settings for the OpenGL
window
begin
h_Instance := GetModuleHandle(nil); //Grab An Instance
For Our Window
ZeroMemory(@wndClass, SizeOf(wndClass)); // Clear the window
class structure
with wndClass do // Set up the window class
begin
style := CS_HREDRAW or // Redraws entire window
if length changes
CS_VREDRAW or // Redraws entire window
if height changes
CS_OWNDC; // Unique device context
for the window
lpfnWndProc := @WndProc; // Set the window
procedure to our func WndProc
hInstance := h_Instance;
hCursor := LoadCursor(0, IDC_ARROW);
lpszClassName := ''OpenGL'';
end;
if (RegisterClass(wndClass) = 0) then // Attemp to register
the window class
begin
MessageBox(0, ''Failed to register the window
class!'', ''Error'', MB_OK or MB_ICONERROR);
Result := False;
Exit
end;
// Change to fullscreen if so desired
if Fullscreen then
begin
ZeroMemory(@dmScreenSettings, SizeOf(dmScreenSettings));
with dmScreenSettings do begin // Set
parameters for the screen setting
dmSize := SizeOf(dmScreenSettings);
dmPelsWidth := Width; // Window width
dmPelsHeight := Height; // Window height
dmBitsPerPel := PixelDepth; // Window color depth
dmFields := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL;
end;
// Try to change screen mode to fullscreen
if (ChangeDisplaySettings(dmScreenSettings, CDS_FULLSCREEN) = DISP_CHANGE_FAILED) then
begin
MessageBox(0, ''Unable to switch to fullscreen!'', ''Error'', MB_OK or MB_ICONERROR);
Fullscreen := False;
end;
end;
// If we are still in fullscreen then
if (Fullscreen) then
begin
dwStyle := WS_POPUP or // Creates a popup window
WS_CLIPCHILDREN // Doesn''t draw within child windows
or WS_CLIPSIBLINGS; // Doesn''t draw within sibling windows
dwExStyle := WS_EX_APPWINDOW; // Top level window
ShowCursor(False); // Turn of the cursor (gets in the way)
end
else
begin
dwStyle := WS_OVERLAPPEDWINDOW or // Creates an overlapping window
WS_CLIPCHILDREN or // Doesn''t draw within child windows
WS_CLIPSIBLINGS; // Doesn''t draw within sibling windows
dwExStyle := WS_EX_APPWINDOW or // Top level window
WS_EX_WINDOWEDGE; // Border with a raised edge
end;
// Attempt to create the actual window
h_Wnd := CreateWindowEx(dwExStyle, // Extended window styles
''OpenGL'', // Class name
WND_TITLE, // Window title (caption)
dwStyle, // Window styles
0, 0, // Window position
Width, Height, // Size of window
0, // No parent window
0, // No menu
h_Instance, // Instance
nil); // Pass nothing to WM_CREATE
if h_Wnd = 0 then
begin
glKillWnd(Fullscreen); // Undo all the settings we''ve changed
MessageBox(0, ''Unable to create window!'', ''Error'', MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;
// Try to get a device context
h_DC := GetDC(h_Wnd);
if (h_DC = 0) then
begin
glKillWnd(Fullscreen);
MessageBox(0, ''Unable to get a device context!'', ''Error'', MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;
// Initializes the timer used to calculate the FPS
SetTimer(h_Wnd, FPS_TIMER, FPS_INTERVAL, nil);
// Settings to ensure that the window is the topmost window
ShowWindow(h_Wnd, SW_SHOW);
SetForegroundWindow(h_Wnd);
SetFocus(h_Wnd);
Result := True;
end;
**********************************************
Is there anything of the window creation that could be regarded as DXPlay`parent component?
thanx