|
-
Jul 22nd, 2006, 09:31 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Move borderless form question [urgent]
Hi,
I have this code to move a borderless form which it works great. However when I double click the form it maximizes the form which I don't want.
I really need to disable the maximizing on double-click.
VB Code:
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if (m.Result.ToInt32() == HTCLIENT) m.Result = new IntPtr(HTCAPTION);
break;
//If m.Result.ToInt32 = HTCLIENT Then m.Result = IntPtr.op_Explicit(HTCAPTION) 'Try this in VS.NET 2002/2003 if the latter line of code doesn't do it... thx to Suhas for the tip.
default:
//Make sure you pass unhandled messages back to the default message handler.
base.WndProc(ref m);
break;
}
}
BTW, this is VS2003
-
Jul 22nd, 2006, 11:54 PM
#2
Re: Move borderless form question [urgent]
The WM_NCHITTEST message is only trapping the clicking of the titlebar wether its a single or a double click. Perhaps you should also trap for the maximize message and cancel it out.
WM_NCLBUTTONDBLCLK or WM_SIZING?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 22nd, 2006, 11:58 PM
#3
Thread Starter
Hyperactive Member
Re: Move borderless form question [urgent]
I'd love to do that Rob, would appreciate if you show me how...
-
Jul 23rd, 2006, 12:01 AM
#4
Re: Move borderless form question [urgent]
Ok, got it I think. Its the WM_NCLBUTTONDBLCLK message with the wParam of 00000002. 2 is the value for maximize. Trap that message and either cancel out the call or change the wParam to 0 or Normal windowstate.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 23rd, 2006, 12:10 AM
#5
Re: Move borderless form question [urgent]
Just free hand replying...
add another case to your switch block but I think the first case may cause an issue for the WM_NCBUTTONDBLCLK...
VB Code:
case WM_NCLBUTTONDBLCLK:
base.WndProc(ref m);
if (m.Result.ToInt32() == HTCAPTION) m.Result = new IntPtr(HTCLIENT);
break;
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 23rd, 2006, 12:24 AM
#6
Re: Move borderless form question [urgent]
Not sure if that the correct way to cancel it out but here is the other option of the WM_SYSCOMMAND withthe SC_MAXIMIZE wParam.
VB Code:
case WM_SYSCOMMAND:
base.WndProc(ref m);
if (m.Result.ToInt32() == SC_MAXIMIZE) m.Result = new IntPtr(SC_RESTORE);
break;
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 23rd, 2006, 03:50 PM
#7
Thread Starter
Hyperactive Member
Re: Move borderless form question [urgent]
Thanks for your efforts, but I can still maximize by double-clicking the form...
-
Jul 23rd, 2006, 04:26 PM
#8
Re: Move borderless form question [urgent]
I really think it has to do with the WM_NCHITTEST way of handling is bypassing the message or such. I see someone that may know is online. Let me send a PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 23rd, 2006, 04:32 PM
#9
Thread Starter
Hyperactive Member
Re: Move borderless form question [RESOLVED-I hope]
Well, I came accross the following and it seems to work. Let me know if you find a bug or a better solution as I don't really know how it works...
VB Code:
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
private const int WM_NCLBUTTONDBLCLK = 0xA3;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if (m.Result.ToInt32() == HTCLIENT) m.Result = new IntPtr(HTCAPTION);
break;
[B] case WM_NCLBUTTONDBLCLK:
m.Msg=0; //Discard double-click
break;[/B]
default:
//Make sure you pass unhandled messages back to the default message handler.
base.WndProc(ref m);
break;
}
}
-
Jul 23rd, 2006, 08:04 PM
#10
Re: [RESOLVED] Move borderless form question [urgent]
Well the click on the form is being aliased to the titlebar so to speak with your other case statrement so it may be registering as a double click on the titlebar which causes the form to resize either max or restore depending on its current state. Trapping the double click and canceling it out is fine as it locks the form in its current state.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|