How to prevent main frame movement and movement visual clue
Ari Villaca -- villaca@correionet.com.br
Thursday, February 06, 1997
Environment: MSVC 4.0/Win95
I want to prevent a main frame window movement.
I have overridden=20
void CMyMainFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)=20
and was able to prevent the main frame movement.
I was unable to prevent the movement visual clue: the window border is
still drawn according to the mouse movement.
So my application has a weird behaviour, the user sees a movement
indication, the visual clue, but the main frame movement doesn't happen.
I want to eliminate that visual clue to have a behaviour similar to movin=
g
a maximized frame window, ie, nothing happens and there is no movement
visual clue.
What am I missing here?
Thanks in advance,
Ari
-------------------------------------------------------------------------=
---
Ari de Moura Villa=E7a
e-Mail: villaca@correionet.com.br
Av. Moraes Sales, 987 Apto.113 fone: +55 19 232-2440
13010-001 - Campinas, SP fax: +55 19 232-2440
Brasil
-------------------------------------------------------------------------=
---
Brad Wilson/Crucial Software -- crucial@pobox.com
Saturday, February 08, 1997
[Mini-digest: 3 responses]
> I want to prevent a main frame window movement.
Try overriding WM_NCLBUTTONDOWN. Send the WM_NCHITTEST message to the =
window to determine if they're clicking on the caption, and eat the =
mouse message if they are.
--
Brad Wilson, Objectivist, Software Engineer http://www.thebrads.com
bradw@cisco.com bradw@thebrads.com crucial@pobox.com
"I owe nothing to my brothers, nor do I gather debts from them. I ask
none to live for me, nor do I live for any others. I covet no man's
soul, nor is my soul theirs to covet." -- From Anthem by Ayn Rand
-----From: "=?ISO-8859-1?Q?Ignacio_Nicol=E1s_Rodr=EDguez?="
Hi!
I think you'd do better by, instead of preventing the window from
WindowPosChanging, just make your window do nothing when the user wants t=
o
drag the caption or choose SystemMenu|Move.
You'd map WM_SYSCOMMAND to something like:
void CDontMoveDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) =3D=3D SC_MOVE)
{
::MessageBeep(MB_ICONEXCLAMATION);
// Daddy told me not to move
return;
}
CDialog::OnSysCommand(nID, lParam);
}
and WM_NCLBUTTONDOWN to:
void CDontMoveDlg::OnNcLButtonDown( UINT nHitTest, CPoint point )
{
if (nHitTest =3D=3D HTCAPTION)
::MessageBeep(MB_ICONEXCLAMATION);
else
CWnd::OnNcLButtonDown(nHitTest, point);
}
Hope this helps. By the way, I'm so sad about Chico Science ; the guy was=
a
great musician.
Ignacio Nicol=E1s Rodr=EDguez
irodriguez@envirolink.org
Nothing more powerfull, nothing easier than OLE/COM, except ICE HOCKEY.
----------
From: Ari Villaca
Date: Thursday, February 06, 1997 4:46 PM
Environment: MSVC 4.0/Win95
I want to prevent a main frame window movement.
I have overridden=20
void CMyMainFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)=20
Ari de Moura Villa=E7a
Brasil
----------
-----From: "Serge Wautier"
>From: Ari Villaca
>Subject: How to prevent main frame movement and movement visual clue
>I want to prevent a main frame window movement.
>I have overridden
>void CMyMainFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
>and was able to prevent the main frame movement.
>I was unable to prevent the movement visual clue: the window border is
>still drawn according to the mouse movement.
>So my application has a weird behaviour, the user sees a movement
>indication, the visual clue, but the main frame movement doesn't happen.
>I want to eliminate that visual clue to have a behaviour similar to
moving
>a maximized frame window, ie, nothing happens and there is no movement
>visual clue.
Add a handler for WM_GETMINMAXINFO.
--
Serge Wautier,
Techno Trade sa,
Belgium.
serge.wautier@ontonet.be
http://www.tbox.fr
Paul Martinsen -- pmartinsen@hort.cri.nz
Monday, February 10, 1997
Environment: MSVC 4.0/Win95
>
> I want to prevent a main frame window movement.
>
> I have overridden
> void CMyMainFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
> and was able to prevent the main frame movement.
>
> I was unable to prevent the movement visual clue: the window border is
> still drawn according to the mouse movement.
>
Maybe you could try intercepting OnNcHitTest & never return
HTCAPTION, or perhaps OnNcLButtonDown, and don't call the default
handler if the hit is HTCAPTION.
Paul Martinsen
Philip Beck -- splinta@cix.compulink.co.uk
Monday, February 10, 1997
[Mini-digest: 2 responses]
In-Reply-To: <199702062148.RAA35290@guttenberg.correionet.com.br>
>So my application has a weird behaviour, the user sees a movement
>indication, the visual clue, but the main frame movement doesn't happen.
I prevented my SDI frame from moving by handling :
void CMainFrame::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
TRACE("Hit Test = %d\n", nHitTest); // to figure out the code
for // each region
if(nHitTest == 2) // clicked on caption bar
return;
CFrameWnd::OnNcLButtonDown(nHitTest, point);
}
Cheers,
Phil.
-----From: Mihir Dalal
On Thu, 6 Feb 1997, Ari Villaca wrote:
> Environment: MSVC 4.0/Win95
>=20
> I want to prevent a main frame window movement.
>=20
> I have overridden=20
> void CMyMainFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)=20
> and was able to prevent the main frame movement.
>=20
> I was unable to prevent the movement visual clue: the window border is
> still drawn according to the mouse movement.
>=20
> So my application has a weird behaviour, the user sees a movement
> indication, the visual clue, but the main frame movement doesn't happen.
>=20
> I want to eliminate that visual clue to have a behaviour similar to movin=
g
> a maximized frame window, ie, nothing happens and there is no movement
> visual clue.
>=20
> What am I missing here?
>=20
> Thanks in advance,
>=20
> Ari
> -------------------------------------------------------------------------=
---
>=20
> Ari de Moura Villa=E7a
> =09=09=09=09=09e-Mail:=09villaca@correionet.com.br
>=20
> Av. Moraes Sales, 987 Apto.113=09=09fone:=09+55 19 232-2440
> 13010-001 - Campinas, SP=09=09fax:=09+55 19 232-2440
> Brasil
> -------------------------------------------------------------------------=
---
Adding the following code in your CMainFrame::OnCreate() removes both=20
sizing and moving of the mainframe.=20
// Create the mainframe of the application
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
.....
.....
// Delete control-menu box items (8 to 0) =3D> Remove sizing & moving=
=20
// of mainfrm
HMENU hSystemMenu =3D ::GetSystemMenu(m_hWnd, 0);
for (int iT =3D 2; iT > 0; iT--) // delete items 2 & 1
::RemoveMenu(hSystemMenu, iT, MF_BYPOSITION); =20
.....
.....
}
Mihir.=20
__________________________________________________________________________=
_
Mihir Dalal , M.Engg. (Electrical) Student
Department of Electrical and Computer Engineering
Concordia University, Montreal, Canada
http://www.ECE.Concordia.CA/~m_dalal/addr.html
Become an MFC-L member
| Вернуться в корень Архива
|