how can I fully disable resizing a window including the resize icon when the mouse hovers the border?
Qt has a windowFlag called Qt::MSWindowsFixedSizeDialogHint
for that. Depending on what you exactly want, you want to combine this flag with Qt::Widget
, Qt::Window
or Qt::Dialog
.
void MyDialog::MyDialog()
{
setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
...
}
How to move and resize a form without a border?
Some sample code that allow moving and resizing the form:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.DoubleBuffered = true;
this.SetStyle(ControlStyles.ResizeRedraw, true);
}
private const int cGrip = 16; // Grip size
private const int cCaption = 32; // Caption bar height;
protected override void OnPaint(PaintEventArgs e) {
Rectangle rc = new Rectangle(this.ClientSize.Width - cGrip, this.ClientSize.Height - cGrip, cGrip, cGrip);
ControlPaint.DrawSizeGrip(e.Graphics, this.BackColor, rc);
rc = new Rectangle(0, 0, this.ClientSize.Width, cCaption);
e.Graphics.FillRectangle(Brushes.DarkBlue, rc);
}
protected override void WndProc(ref Message m) {
if (m.Msg == 0x84) { // Trap WM_NCHITTEST
Point pos = new Point(m.LParam.ToInt32());
pos = this.PointToClient(pos);
if (pos.Y < cCaption) {
m.Result = (IntPtr)2; // HTCAPTION
return;
}
if (pos.X >= this.ClientSize.Width - cGrip && pos.Y >= this.ClientSize.Height - cGrip) {
m.Result = (IntPtr)17; // HTBOTTOMRIGHT
return;
}
}
base.WndProc(ref m);
}
}
How to create a WPF Window without a border that can be resized via a grip only?
If you set the AllowsTransparency
property on the Window
(even without setting any transparency values) the border disappears and you can only resize via the grip.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="640" Height="480"
WindowStyle="None"
AllowsTransparency="True"
ResizeMode="CanResizeWithGrip">
<!-- Content -->
</Window>
Result looks like:
How to add an element over the border and have it maintain the position when resizing the window?
You can do this by adding "position-relative" to the container.
<div class="container-fluid info-div position-relative">
<div class="row">
<div class="col-12 col-sm-6 col-md-3">
<div class="box"></div>
</div>
<p class="col-12 col-sm-6 col-md-9">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolorem odio porro
obcaecati id ad illo
accusantium maxime, corrupti deleniti doloremque.
</p>
</div>
</div>
Then you need to modify the bottom arrow css from right:0% to left: 100%
.info-div:before {
bottom: -13px;
left: 100%;
border-top: 11px solid transparent;
border-left: 20px solid black;
border-bottom: 11px solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
And the top arrow:
.info-div:after {
top: -16px;
left: -13px;
border-left: 11px solid transparent;
border-right: 11px solid transparent;
border-bottom: 20px solid black;
content: " ";
height: 0;
width: 0;
position: absolute;
}
Let user grab the window to resize, outside the window
Visual Studio's main window is a WPF window, but it doesn't use the default window chrome provided by the OS.
Instead, it creates a custom glow effect: actually, the effect is implemented by four native windows (each with its own HWND
) which are placed around the main (WPF) window and which render themselves using bitmaps for the glow/shadow effects.
Since these windows can handle the mouse input, they are able to switch the mouse cursor to the resize mode even before the cursor reaches the border of the main window.
If you think that the effort of creating a custom chrome window is worth it, you could try to re-implement this functionality.
You could also try third-party components for this, either by using them as-is or by creating your own fork based on the source code provided. E.g. take a look on a custom chrome window from the ControlzEx library.
Otherwise, if you think that this small feature is not worth any additional effort - well, maybe it is better to just accept the default functionality.
Related Topics
Looking for a CSS Parser in Java
Spring Security Does Not Allow CSS or Js Resources to Be Loaded
Compound Class Names Are Not Supported Error in Webdriver
Add Buttons to Tabs and Tab Area Javafx
How to List Target Platforms. Please Make Sure the Android Sdk Path Is Correct
When Exactly Is It Leak Safe to Use (Anonymous) Inner Classes
Android: How to Enable/Disable Wifi or Internet Connection Programmatically
How to Parse a Dynamic JSON Key in a Nested JSON Result
Android Listview Selected Item Stay Highlighted
Maximum Length of Intent Putextra Method? (Force Close)
Why Does Arrayindexoutofboundsexception Occur and How to Avoid It in Android
How to Parse a Local JSON File from Assets Folder into a Listview
Replacing a Fragment with Another Fragment Inside Activity Group