2010-07-18 23 views
16

Pencerelerin kenarlarını sürükleyerek yeniden boyutlandırmayı nasıl devre dışı bırakabilirim?Pencereyi Yeniden Boyutlandırmayı Devre Dışı Bırakma Win32

İşte benim pencere oluşturma kodu

bool CreateGLWindow(char* title, int width, int height) 
{ 
GLuint  PixelFormat;   // Holds The Results After Searching For A Match 
WNDCLASS wc;      // Windows Class Structure 
DWORD  dwExStyle;    // Window Extended Style 
DWORD  dwStyle;    // Window Style 
RECT  WindowRect;    // Grabs Rectangle Upper Left/Lower Right Values 
WindowRect.left=(long)0;   // Set Left Value To 0 
WindowRect.right=(long)width;  // Set Right Value To Requested Width 
WindowRect.top=(long)0;    // Set Top Value To 0 
WindowRect.bottom=(long)height;  // Set Bottom Value To Requested Height 

hInstance   = GetModuleHandle(NULL);    // Grab An Instance For Our Window 
wc.style   = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window. 
wc.lpfnWndProc  = (WNDPROC) WndProc;     // WndProc Handles Messages 
wc.cbClsExtra  = 0;         // No Extra Window Data 
wc.cbWndExtra  = 0;         // No Extra Window Data 
wc.hInstance  = hInstance;       // Set The Instance 
wc.hIcon   = LoadIcon(NULL, IDI_WINLOGO);   // Load The Default Icon 
wc.hCursor   = LoadCursor(NULL, IDC_ARROW);   // Load The Arrow Pointer 
wc.hbrBackground = NULL;         // No Background Required For GL 
wc.lpszMenuName  = NULL;         // We Don't Want A Menu 
wc.lpszClassName = "OpenGL";        // Set The Class Name 

if (!RegisterClass(&wc))         // Attempt To Register The Window Class 
{ 
    MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;           // Return FALSE 
} 

dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;   // Window Extended Style 
dwStyle=WS_OVERLAPPEDWINDOW;       // Windows Style 

AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);  // Adjust Window To True Requested Size 

// Create The Window 
if (!(hWnd=CreateWindowEx( dwExStyle,       // Extended Style For The Window 
          "OpenGL",       // Class Name 
          title,        // Window Title 
          dwStyle |       // Defined Window Style 
          WS_CLIPSIBLINGS |     // Required Window Style 
          WS_CLIPCHILDREN,     // Required Window Style 
          0, 0,        // Window Position 
          WindowRect.right-WindowRect.left, // Calculate Window Width 
          WindowRect.bottom-WindowRect.top, // Calculate Window Height 
          NULL,        // No Parent Window 
          NULL,        // No Menu 
          hInstance,       // Instance 
          NULL)))        // Dont Pass Anything To WM_CREATE 
{ 
    KillGLWindow();        // Reset The Display 
    MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;        // Return FALSE 
} 

static PIXELFORMATDESCRIPTOR pfd=    // pfd Tells Windows How We Want Things To Be 
{ 
    sizeof(PIXELFORMATDESCRIPTOR),    // Size Of This Pixel Format Descriptor 
    1,           // Version Number 
    PFD_DRAW_TO_WINDOW |      // Format Must Support Window 
    PFD_SUPPORT_OPENGL |      // Format Must Support OpenGL 
    PFD_DOUBLEBUFFER,       // Must Support Double Buffering 
    PFD_TYPE_RGBA,        // Request An RGBA Format 
    24,          // Select Our Color Depth 
    0, 0, 0, 0, 0, 0,       // Color Bits Ignored 
    0,           // No Alpha Buffer 
    0,           // Shift Bit Ignored 
    0,           // No Accumulation Buffer 
    0, 0, 0, 0,         // Accumulation Bits Ignored 
    24,           // 24Bit Z-Buffer (Depth Buffer) 
    0,           // No Stencil Buffer 
    0,           // No Auxiliary Buffer 
    PFD_MAIN_PLANE,        // Main Drawing Layer 
    0,           // Reserved 
    0, 0, 0          // Layer Masks Ignored 
}; 

if (!(hDC=GetDC(hWnd)))       // Did We Get A Device Context? 
{ 
    KillGLWindow();        // Reset The Display 
    MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;        // Return FALSE 
} 

if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? 
{ 
    KillGLWindow();        // Reset The Display 
    MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;        // Return FALSE 
} 

if(!SetPixelFormat(hDC,PixelFormat,&pfd))  // Are We Able To Set The Pixel Format? 
{ 
    KillGLWindow();        // Reset The Display 
    MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;        // Return FALSE 
} 

if (!(hRC=wglCreateContext(hDC)))    // Are We Able To Get A Rendering Context? 
{ 
    KillGLWindow();        // Reset The Display 
    MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;        // Return FALSE 
} 

if(!wglMakeCurrent(hDC,hRC))     // Try To Activate The Rendering Context 
{ 
    KillGLWindow();        // Reset The Display 
    MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); 
    return false;        // Return FALSE 
} 

ShowWindow(hWnd,SW_SHOW);      // Show The Window 
SetForegroundWindow(hWnd);      // Slightly Higher Priority 
SetFocus(hWnd);         // Sets Keyboard Focus To The Window 
reshape(width, height);     // Set Up Our Perspective GL Screen 

init(); 

return true;         // Success 
} 

cevap

46

WS_OVERLAPPEDWINDOW tarzı, bence, pencerenizi resizeable yapmak için responslible olan WS_THICKFRAME stili içerir olduğunu.

düşünün WS_OVERLAPPEDWINDOW gelen

dwStyle=(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX); 
+0

arasında, 'AdjustWindowRectEx' WS_THICKFRAME' tarzının parçası olmayan' eğer düzgün çalışması için görünmüyor çünkü arada , WS_SIZEBOX WS_THICKFRAME aynıdır. –

+1

Bunun neden benim için çalışmadığı için bir yanıt olarak işaretlendiğinden emin değil (Windows 10). Diğer cevap, aşağıdaki kod satırı ile bir çekicilik gibi çalıştı: ':: SetWindowLong (hWnd, GWL_STYLE, GetWindowLong (hWnd, GWL_STYLE) & ~ WS_SIZEBOX);' – YePhIcK

+1

@YePhIcK, ben bu cevabı neredeyse 7 yıl önce verdim, NT 5.1 - 6.1'de sorulan soru, OP'nin sorduğu soru üzerine iyi çalıştı. Daha yeni sürümlerde denemedim ve o zamandan beri Windows üzerinde çalışmıyorum, bu yüzden bazı bitlerin bu arada değiştiğine dair iyi bir şans var. – thatsdisgusting

4

değiştirin pencere tarzı gibi bir şey için, diyelim ki, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX. Başka bir deyişle, kalın çerçeve (yeniden boyutlandırılabilir kenarlık) ve maxbox eksi kaplıdır.

0

WM_SIZING iletisini işleyin ve pencerenin dikdörtgeni değiştirmeye yönelik tüm girişimleri geçersiz kılın. ancak bunun yerine sadece

WS_OVERLAPPEDWINDOW 
-2

XOR WS_THICKFRAME

hariç WS_OVERLAPPEDWINDOW her şeyi tutacak

+0

Yeniden boyutlandırmayı devre dışı bırakmıyor. Yeniden boyutlandırmayı devre dışı bırakmak için, yanıtı @thatsdisgusting ile takip edin. WS_OPERLAPPEDWINDOW^WS_THICKFRAME işlevini kullanın. –

17

Sen WS_OVERLAPPEDWINDOW^WS_THICKFRAME kullanabilirsiniz

WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME 

kullanımını kullanmak yerine, benim için çalışıyor

+0

Bu, en üst düzeye çıkarmayı engellemez. –

3

WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU kullanırsanız, bu di hem maksimize hem de yeniden boyutlandırılabilir.

11

Böyle bir şey deneyebilirsiniz:

::SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)&~WS_SIZEBOX); 

Sadece pencerelerin kenarına sürükleyerek yeniden boyutlandırma devre dışı bırakın. Ancak

#define WS_SIZEBOX WS_THICKFRAME 
İlgili konular