471,350 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

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(ref 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.ToInt32() == HTCLIENT )

m.Result = (IntPtr)HTCAPTION;

}

Nov 28 '05 #1
2 3778
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*******************@news20.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(ref 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.ToInt32() == HTCLIENT )

m.Result = (IntPtr)HTCAPTION;

}

Nov 28 '05 #2
Thanks a lot!

Derrick
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2****************@TK2MSFTNGP11.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*******************@news20.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(ref 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.ToInt32() == HTCLIENT )

m.Result = (IntPtr)HTCAPTION;

}


Nov 28 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jazzkt | last post: by
3 posts views Thread by trialproduct2004 | last post: by
3 posts views Thread by Newbie Coder | last post: by
2 posts views Thread by feltra | last post: by
9 posts views Thread by Ringo | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.