Hide window contents while dragging

A

aagarwal8

hi,

Currently i am using the following code to move my borderless form,
where i have my own titlebar using a panel.

private const int WM_NCLBUTTONDOWN = 0xA1;
private const int HTCAPTION = 0x2;

[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);

private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}

This code picks up the Windows setting of whether to show the window
contents while dragging or not.

However, i want to always hide the contents of my window while
dragging. Is there a way to achieve this?

Also, with this code when i try to hook the MouseUp event of my
panel1, i am not able to do so. After i perform a mouse click, the
control doesnt transfer to the event handler.

Solution to either of the problems will be of great help

Regards,
Ankit!
 
M

Mick Doherty

Why are my messages appearing in this MS hosted Web based newsreader, but not
through the newsgroup readers (Outlook Express, Windows Live Mail)?

This appears to have happened several times in the last week or so!

--
http://dotnetrix.co.uk/nothing.html


Mick Doherty said:
Hi Ankit,

That looks very much like the first example on my Forms tips page, which is
just a quick hack.
You'll need to override WndProc() and look for the message you sent, which
will actually be recieved when the mouse button is released.

--8<----------------------

protected override void WndProc(ref Message m)
{
base.WndProc(ref m);

if (m.Msg == WM_NCLBUTTONDOWN)
{
//This will actually occur at MouseUp
Point pt = this.PointToClient(Cursor.Position);
MouseEventArgs mev = new MouseEventArgs(MouseButtons.Left,
0, pt.X, pt.Y, 0);
OnNonClientMouseUp(this, mev);
}
}

private void OnNonClientMouseUp(object sender, MouseEventArgs e)
{
//Your Non-ClientRectangle MouseUp code goes here
MessageBox.Show(e.Location.ToString());
}

--8<----------------------

It's a little more work, but you'd be better off using the last example on
the same page.

http://dotnetrix.co.uk/form.htm

--
Mick Doherty
http://dotnetrix.co.uk/nothing.htm

hi,

Currently i am using the following code to move my borderless form,
where i have my own titlebar using a panel.

private const int WM_NCLBUTTONDOWN = 0xA1;
private const int HTCAPTION = 0x2;

[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);

private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}

This code picks up the Windows setting of whether to show the window
contents while dragging or not.

However, i want to always hide the contents of my window while
dragging. Is there a way to achieve this?

Also, with this code when i try to hook the MouseUp event of my
panel1, i am not able to do so. After i perform a mouse click, the
control doesnt transfer to the event handler.

Solution to either of the problems will be of great help

Regards,
Ankit!
 
H

Herfried K. Wagner [MVP]

Mick Doherty said:
Why are my messages appearing in this MS hosted Web based newsreader, but
not
through the newsgroup readers (Outlook Express, Windows Live Mail)?

This appears to have happened several times in the last week or so!

I don't know, but I have heard of others experiencing similar problems using
OE and WM. However, I can confirm that your message is available on
'news.microsoft.com'.
 
M

Mick Doherty

Hi Herfried,

I posted the previous response to my reply via the web based newsreader so I
know it's there, but it appears as though nearly every message that I
respond to via WLM is unavailable anywhere but via the web based newsreader.

I'm just wondering how many people are not seeing my responses or how many
messages are not being seen due to this error.

Are MS aware of this issue and are they tackling it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top