Hello all;
I'm trying to create a UI that's a little atypical. In the main form's
Paint event handler, I draw an image on the form - this is what I want to by
my "real" UI. I turned off the form border, and set the form's background
and transparency key to be the same value. As you know, because of this
there is no sign of the form, just the image I painted. So far, so good.
Since the form border - and hence the title bar - is gone, there was no way
to move (drag) the UI around on screen. To accomplish this, I did a bit of
Googling and found an override for WndProc that seems to do the trick (see
code snippet below). Trouble is, now if you double-click on the UI graphic,
the form seems to maximize - i.e., the form border reappears, explodes to
its maximized state (and also moves my graphic along with it), then the
border disappears again. When you double-click while maximized, the reverse
happens, and the form restores to its original size (and again, my graphic
moves as a result).
Looking at the WndProc code, I understand why this happens - I'm just
catching a click in the client area and telling the system that the click
occured on the titlebar. But I've never had to deal with these low level
Windows messages before, and I'm not sure how to get rid of this
double-click behavior while keeping the ability to drag my image around the
screen.
Any help is greatly appreciated!
Derrick
Here is the WndProc code that I have on my form:
// This function allows the user to move the form around even though the
border is off
protected override void WndProc(ref Message m)
{
// Let the base class have first crack
base.WndProc(re f m);
int WM_NCHITTEST = 0x84; // winuser.h
if( m.Msg != WM_NCHITTEST ) return;
// If the user clicked on the client area,
// ask the OS to treat it as a click on the caption
// i.e., allow relocation
int HTCLIENT = 1;
int HTCAPTION = 2;
if( m.Result.ToInt3 2() == HTCLIENT )
m.Result = (IntPtr)HTCAPTI ON;
} 2 3928
Hi,
I won't like the way you implement it, IIRC a much easier way to implement
this is to simply to intercept the mouse events , move, down, etc there is
no need to use any WM_**
Take a look at http://www.thescarms.com/dotnet/IrregularForm.asp
chgeers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Derrick" <de***********@ hotmail.com> wrote in message
news:8J******** ***********@new s20.bellglobal. com... Hello all;
I'm trying to create a UI that's a little atypical. In the main form's Paint event handler, I draw an image on the form - this is what I want to by my "real" UI. I turned off the form border, and set the form's background and transparency key to be the same value. As you know, because of this there is no sign of the form, just the image I painted. So far, so good.
Since the form border - and hence the title bar - is gone, there was no way to move (drag) the UI around on screen. To accomplish this, I did a bit of Googling and found an override for WndProc that seems to do the trick (see code snippet below). Trouble is, now if you double-click on the UI graphic, the form seems to maximize - i.e., the form border reappears, explodes to its maximized state (and also moves my graphic along with it), then the border disappears again. When you double-click while maximized, the reverse happens, and the form restores to its original size (and again, my graphic moves as a result).
Looking at the WndProc code, I understand why this happens - I'm just catching a click in the client area and telling the system that the click occured on the titlebar. But I've never had to deal with these low level Windows messages before, and I'm not sure how to get rid of this double-click behavior while keeping the ability to drag my image around the screen.
Any help is greatly appreciated!
Derrick
Here is the WndProc code that I have on my form:
// This function allows the user to move the form around even though the border is off
protected override void WndProc(ref Message m)
{
// Let the base class have first crack
base.WndProc(re f m);
int WM_NCHITTEST = 0x84; // winuser.h
if( m.Msg != WM_NCHITTEST ) return;
// If the user clicked on the client area,
// ask the OS to treat it as a click on the caption
// i.e., allow relocation
int HTCLIENT = 1;
int HTCAPTION = 2;
if( m.Result.ToInt3 2() == HTCLIENT )
m.Result = (IntPtr)HTCAPTI ON;
}
Thanks a lot!
Derrick
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Hi,
I won't like the way you implement it, IIRC a much easier way to implement this is to simply to intercept the mouse events , move, down, etc there is no need to use any WM_**
Take a look at http://www.thescarms.com/dotnet/IrregularForm.asp
chgeers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Derrick" <de***********@ hotmail.com> wrote in message news:8J******** ***********@new s20.bellglobal. com... Hello all;
I'm trying to create a UI that's a little atypical. In the main form's Paint event handler, I draw an image on the form - this is what I want to by my "real" UI. I turned off the form border, and set the form's background and transparency key to be the same value. As you know, because of this there is no sign of the form, just the image I painted. So far, so good.
Since the form border - and hence the title bar - is gone, there was no way to move (drag) the UI around on screen. To accomplish this, I did a bit of Googling and found an override for WndProc that seems to do the trick (see code snippet below). Trouble is, now if you double-click on the UI graphic, the form seems to maximize - i.e., the form border reappears, explodes to its maximized state (and also moves my graphic along with it), then the border disappears again. When you double-click while maximized, the reverse happens, and the form restores to its original size (and again, my graphic moves as a result).
Looking at the WndProc code, I understand why this happens - I'm just catching a click in the client area and telling the system that the click occured on the titlebar. But I've never had to deal with these low level Windows messages before, and I'm not sure how to get rid of this double-click behavior while keeping the ability to drag my image around the screen.
Any help is greatly appreciated!
Derrick
Here is the WndProc code that I have on my form:
// This function allows the user to move the form around even though the border is off
protected override void WndProc(ref Message m)
{
// Let the base class have first crack
base.WndProc(re f m);
int WM_NCHITTEST = 0x84; // winuser.h
if( m.Msg != WM_NCHITTEST ) return;
// If the user clicked on the client area,
// ask the OS to treat it as a click on the caption
// i.e., allow relocation
int HTCLIENT = 1;
int HTCAPTION = 2;
if( m.Result.ToInt3 2() == HTCLIENT )
m.Result = (IntPtr)HTCAPTI ON;
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sshuangw |
last post by:
Hello:
I am encountering a very weird issue with MDI child, Overriden WndProc
function and hidden form.
Basically, the application has two forms, Form1(parent form),
Form2(Child form), Form2's WndProc method is overriden, if the message
is CLOSE message, just hide the form. I first initialize and show the
child form, then close it by clicking the Close(X) button, the
overriden WndProc method gets invoked, and the form is hidden. Then
|
by: mikelostcause |
last post by:
Is there anyway to hold the base.WndProc(ref m) until after the Logout()
function finishes loading a webpage??
I'm working on shutting down an app that runs in the system tray, I have no
problems shutting down, but I have problems saving data first.
if the base.WndProc(ref m) is placed at the top, it closes, but the system
does not continue to shutdown and it does not save the data via the Logout()
funtion.
If the base.WndProc(ref m)...
|
by: Jazzkt |
last post by:
Hello, Folks,
I am new to VC++ and I just added a form to my application. The GUI has a
group of checkboxes, a combo box, a text box and two buttons.
Will someone please walk me through getting the form to load and displayed
on my screen?
I greatly appreciate the help.
|
by: Colin McGuire |
last post by:
I apologize for posting yet another scrollbar question. Here is my
code. All I want is for a diagonal line to appear from coordinates
(0,0) to (width,height) in a usercontrol regardless of whether the
user autoscrolls the usercontrol (other things that are on the
usercontrol I want to scroll, but haven't included any here).
Here are the steps to reproduce my problem.
1. Launch Visual Studio and create a new Windows
application with...
|
by: trialproduct2004 |
last post by:
Hi all
i am having error is multi threaded application.
I have function in which i am opening form and starting thread.
But while doing this i am getting following error.
This exception is getting catched in main.
Does anyone know what is nativewindow.
Error:-
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
| |
by: geneb |
last post by:
I've got a number of tabs with text boxes on them. When you hit the
last textbox on a tab, it checks to see if the next tab is a valid
destination, then goes to it if so.
Unfortunately, when this happens, both the Enter _and_ Leave events of
the first textbox control are fired, causing all sorts of mayhem.
On a related note, I have another textbox that has it's Enter/Leave
events fired when other controls are changing focus...
|
by: Newbie Coder |
last post by:
I am trying to override WndProc like I would in this VB.NET sub. How do I do
it?
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissi
ons.SecurityAction.Demand, Name:="FullTrust")_
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
ShutDownWindows = True
End If
MyBase.WndProc(m)
|
by: feltra |
last post by:
Hi,
The following is from my friend, who has some technical problem at
present in accessing the web... I am writing for him... Kindly
request your inputs ASAP, as he has some kind of deadline tomorrow.
..........................................................................................
I am having an issue with MDI form. I have an MDI form and some Child
forms. In order to enable for a choice, I am displaying a message box
in...
|
by: Ringo |
last post by:
the LeafProject http://www.leafproject.org has a DLL for Face
recognition. it is written in C++ but they interface to it from Lisp.
I want to interface to it from C#.
Their Lisp definitions looks like this.
;;;; REGISTER THE VISION FACE RECOGNITION
DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(fli:register-module "FaceRecog.dll")
; an interface function:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |