Can you make a Borderless Application Main Window in Windows, without WS_POPUP style?

后端 未结 3 652
灰色年华
灰色年华 2020-12-05 12:35

I want to create a window that will be the main window and that Windows itself recognizes as a main application window. However, when I make my window borderless, and witho

相关标签:
3条回答
  • 2020-12-05 12:53

    The following gets the job done:

    hWnd = CreateWindow(...);
    SetWindowLong(hWnd, GWL_STYLE, WS_POPUP | WS_MINIMIZEBOX);
    SetWindowLong(hWnd, GWL_EXSTYLE, 0);
    ShowWindow(hWnd, ...);
    

    You were probably missing WS_MINIMIZEBOX.

    0 讨论(0)
  • 2020-12-05 13:00

    A bit icky, but you can set the window region by putting this in YourForm.OnShow event:

    var
      r: TRect;
    begin
      r := ClientRect;
      OffsetRect(r, 0, GetSystemMetrics(SM_CYCAPTION));
      OffsetRect(r, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME));
      SetWindowRgn(Handle, 
          CreateRectRgn(
              r.Left, r.Top, 
              ClientWidth + r.Left, ClientHeight + r.Top), True);
    
    0 讨论(0)
  • 2020-12-05 13:00

    You need to override TForm.CreateParams and set or remove any style that you are interest in

    procedure TYourForm.CreateParams(var Params: TCreateParams);
    begin
      inherited CreateParams(Params);
      Params.Style := Params.Style and
      Params.ExStyle := Params.ExStyle or ;
    end;
    
    0 讨论(0)
提交回复
热议问题