473,695 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with WndProc

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;

}

Nov 28 '05 #1
2 3921
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;

}

Nov 28 '05 #2
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;

}


Nov 28 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2505
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
0
1078
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)...
3
1199
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.
22
2348
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...
3
1130
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
1
1529
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...
3
3336
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)
2
1503
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...
9
2723
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:
0
8652
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9140
Oralloy
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...
0
9005
jinu1996
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...
1
8867
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,...
1
6511
isladogs
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...
0
4351
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...
0
4599
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2291
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.