DGL
https://delphigl.com/forum/

Full Screen Windows
https://delphigl.com/forum/viewtopic.php?f=19&t=3280
Seite 1 von 1

Autor:  Stucuk [ Fr Sep 24, 2004 16:48 ]
Betreff des Beitrags:  Full Screen Windows

When ever i try n create a window with WS_POPUP it throws out an access violation with address 000000. WS_OVERLAPPEDWINDOW works fine, but the start bar/task bar/wahtever its called, overlaps the window, and the window has a title +border.


Helios:
Code:
  1.  
  2. function glCreateWnd(Width, Height : Integer; PixelDepth, TextureDepth : Integer) : Boolean;
  3. var
  4.   wndClass : TWndClass;         // Window class
  5.   dwStyle : DWORD;              // Window styles
  6.   dwExStyle : DWORD;            // Extended window styles
  7.   PixelFormat : GLuint;         // Settings for the OpenGL rendering
  8.   h_Instance : HINST;           // Current instance
  9.   pfd : TPIXELFORMATDESCRIPTOR;  // Settings for the OpenGL window
  10. begin
  11.   InitOpenGL;
  12.   SCREEN_WIDTH := Width;
  13.   SCREEN_HEIGHT := Height;
  14.  
  15.   AddToConsole('--- Creating Window ---');
  16.  
  17.   h_Instance := GetModuleHandle(nil);       //Grab An Instance For Our Window
  18.   ZeroMemory(@wndClass, SizeOf(wndClass));  // Clear the window class structure
  19.  
  20.   with wndClass do  begin                  // Set up the window class
  21.     style         := CS_HREDRAW or    // Redraws entire window if length changes
  22.                      CS_VREDRAW or    // Redraws entire window if height changes
  23.                      CS_OWNDC;        // Unique device context for the window
  24.     lpfnWndProc   := @WndProc;        // Set the window procedure to our func WndProc
  25.     hInstance     := h_Instance;
  26.     hCursor       := LoadCursor(0, IDC_ARROW);
  27.     hIcon         := LoadIcon(hInstance, 'MAINICON');
  28.     lpszClassName := 'OpenGL';
  29.   end;
  30.  
  31.   if (RegisterClass(wndClass) = 0) then  begin// Attemp to register the window class
  32.     AddToConsole('Failed to register the window class!');
  33.     Result := False;
  34.     Exit
  35.   end;
  36.  
  37.   AddToConsole('Registered Class...');
  38.  
  39.   //ChangeToFullScreen;
  40.  
  41.   // If we are still in fullscreen then
  42.   if (Fullscreen) then begin
  43.     dwStyle := WS_POPUP or                // Creates a popup window
  44.                WS_CLIPCHILDREN            // Doesn't draw within child windows
  45.                or WS_CLIPSIBLINGS;        // Doesn't draw within sibling windows
  46.     dwExStyle := WS_EX_APPWINDOW;         // Top level window
  47.     //ShowCursor(false);                    // Turn of the cursor (gets in the way)
  48.   end
  49.   else begin
  50.        dwStyle := WS_OVERLAPPEDWINDOW or     // Creates an overlapping window
  51.                WS_CLIPCHILDREN or         // Doesn't draw within child windows
  52.                WS_CLIPSIBLINGS;           // Doesn't draw within sibling windows
  53.  
  54.     dwExStyle := WS_EX_APPWINDOW or       // Top level window
  55.                  WS_EX_WINDOWEDGE;        // Border with a raised edge
  56.     //ShowCursor(false);                    // Turn of the cursor (gets in the way)
  57.   end;
  58.  
  59.   // Attempt to create the actual window
  60.   h_Wnd := CreateWindowEx(dwExStyle,      // Extended window styles
  61.                           'OpenGL',       // Class name
  62.                           WND_TITLE,      // Window title (caption)
  63.                           dwStyle,        // Window styles
  64.                           0, 0,           // Window position
  65.                           Width, Height,  // Size of window
  66.                           0,              // No parent window
  67.                           0,              // No menu
  68.                           h_Instance,     // Instance
  69.                           nil);           // Pass nothing to WM_CREATE
  70.   if h_Wnd = 0 then begin
  71.     AddToConsole('Unable to create window!');
  72.     glKillWnd(False);                // Undo all the settings we've changed
  73.     Result := False;
  74.     Exit;
  75.   end;
  76.  


Q3MapView:
Code:
  1.  
  2. function glCreateWnd(Width, Height : Integer; Fullscreen : Boolean; PixelDepth, TextureDepth : Integer) : Boolean;
  3. var
  4.   wndClass : TWndClass;         // Window class
  5.   dwStyle : DWORD;              // Window styles
  6.   dwExStyle : DWORD;            // Extended window styles
  7.   dmScreenSettings : DEVMODE;   // Screen settings (fullscreen, etc...)
  8.   PixelFormat : GLuint;         // Settings for the OpenGL rendering
  9.   h_Instance : HINST;           // Current instance
  10.   pfd : TPIXELFORMATDESCRIPTOR;  // Settings for the OpenGL window
  11. begin
  12.   InitOpenGL;
  13.  
  14.   h_Instance := GetModuleHandle(nil);       //Grab An Instance For Our Window
  15.   ZeroMemory(@wndClass, SizeOf(wndClass));  // Clear the window class structure
  16.  
  17.   with wndClass do  begin                  // Set up the window class
  18.     style         := CS_HREDRAW or    // Redraws entire window if length changes
  19.                      CS_VREDRAW or    // Redraws entire window if height changes
  20.                      CS_OWNDC;        // Unique device context for the window
  21.     lpfnWndProc   := @WndProc;        // Set the window procedure to our func WndProc
  22.     hInstance     := h_Instance;
  23.     hCursor       := LoadCursor(0, IDC_ARROW);
  24.     hIcon         := LoadIcon(hInstance, 'MAINICON');
  25.     lpszClassName := 'OpenGL';
  26.   end;
  27.  
  28.   if (RegisterClass(wndClass) = 0) then  begin// Attemp to register the window class
  29.     MessageBox(0, 'Failed to register the window class!', 'Error', MB_OK or MB_ICONERROR);
  30.     Result := False;
  31.     Exit
  32.   end;
  33.  
  34.   // Change to fullscreen if so desired
  35.   if Fullscreen then begin
  36.     ZeroMemory(@dmScreenSettings, SizeOf(dmScreenSettings));
  37.     with dmScreenSettings do begin              // Set parameters for the screen setting
  38.       dmSize       := SizeOf(dmScreenSettings);
  39.       dmPelsWidth  := Width;                    // Window width
  40.       dmPelsHeight := Height;                   // Window height
  41.       dmBitsPerPel := PixelDepth;               // Window color depth
  42.       dmFields     := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL;
  43.     end;
  44.  
  45.     // Try to change screen mode to fullscreen
  46.     if (ChangeDisplaySettings(dmScreenSettings, CDS_FULLSCREEN) = DISP_CHANGE_FAILED) then begin
  47.       MessageBox(0, 'Unable to switch to fullscreen!', 'Error', MB_OK or MB_ICONERROR);
  48.       Fullscreen := False;
  49.     end;
  50.   end;
  51.  
  52.   // If we are still in fullscreen then
  53.   if (Fullscreen) then begin
  54.     dwStyle := WS_POPUP or                // Creates a popup window
  55.                WS_CLIPCHILDREN            // Doesn't draw within child windows
  56.                or WS_CLIPSIBLINGS;        // Doesn't draw within sibling windows
  57.     dwExStyle := WS_EX_APPWINDOW;         // Top level window
  58.     ShowCursor(false);                    // Turn of the cursor (gets in the way)
  59.   end
  60.   else begin
  61.        dwStyle := WS_OVERLAPPEDWINDOW or     // Creates an overlapping window
  62.                WS_CLIPCHILDREN or         // Doesn't draw within child windows
  63.                WS_CLIPSIBLINGS;           // Doesn't draw within sibling windows
  64.  
  65.     dwExStyle := WS_EX_APPWINDOW or       // Top level window
  66.                  WS_EX_WINDOWEDGE;        // Border with a raised edge
  67.     ShowCursor(false);                    // Turn of the cursor (gets in the way)
  68.   end;
  69.  
  70.   // Attempt to create the actual window
  71.   h_Wnd := CreateWindowEx(dwExStyle,      // Extended window styles
  72.                           'OpenGL',       // Class name
  73.                           WND_TITLE,      // Window title (caption)
  74.                           dwStyle,        // Window styles
  75.                           0, 0,           // Window position
  76.                           Width, Height,  // Size of window
  77.                           0,              // No parent window
  78.                           0,              // No menu
  79.                           h_Instance,     // Instance
  80.                           nil);           // Pass nothing to WM_CREATE
  81.   if h_Wnd = 0 then begin
  82.     glKillWnd(Fullscreen);                // Undo all the settings we've changed
  83.     MessageBox(0, 'Unable to create window!', 'Error', MB_OK or MB_ICONERROR);
  84.     Result := False;
  85.     Exit;
  86.   end;
  87.  

Autor:  Stucuk [ Fr Sep 24, 2004 20:42 ]
Betreff des Beitrags: 

Fixed. WndProc was at fault.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/