Discussion:
SC_RESTORE
(too old to reply)
Steve Russell
2006-09-11 18:19:44 UTC
Permalink
I am getting acquainted with handling some WM_SYSCOMMAND messages and would
appreciate it if someone would tell me how to handle the restore message
upon double-clicking the title bar. How does that differ from clicking the
Restore box?

void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);

CFrameWnd::OnSysCommand(nID, lParam);
}
Jonathan Wood
2006-09-11 18:55:54 UTC
Permalink
My guess is that double clicking the title bar would produce the same
message.

Looks like you implemented a handler. Are you saying it was not called when
the title bar was double clicked?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and would
appreciate it if someone would tell me how to handle the restore message
upon double-clicking the title bar. How does that differ from clicking the
Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Steve Russell
2006-09-11 22:37:45 UTC
Permalink
I can say this: In the handler, I added a TRACE of nID. The Restore box
delivers 61728 (F120), which is SC_RESTORE, of course. But doubleclicking
on the title bar gives me 61730 (F122), which I do not recognize. When the
window is in restored size and I maximize it, the first click on the title
bar gives me 61458 (F012); . the second reads 61490 (F032).

However, Spy++ displays the WM_SYSCOMMAND message with SC_RESTORE, when I
doubleclick the title bar.
--------------
Post by Jonathan Wood
My guess is that double clicking the title bar would produce the same
message.
Looks like you implemented a handler. Are you saying it was not called
when the title bar was double clicked?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and
would appreciate it if someone would tell me how to handle the restore
message upon double-clicking the title bar. How does that differ from
clicking the Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Steve Russell
2006-09-11 22:58:37 UTC
Permalink
Combining 0xFFF0 with nID has straightened everything out.

if( (nID & 0xFFF0) == SC_RESTORE)
---------------
Post by Steve Russell
I can say this: In the handler, I added a TRACE of nID. The Restore box
delivers 61728 (F120), which is SC_RESTORE, of course. But doubleclicking
on the title bar gives me 61730 (F122), which I do not recognize. When the
window is in restored size and I maximize it, the first click on the title
bar gives me 61458 (F012); . the second reads 61490 (F032).
However, Spy++ displays the WM_SYSCOMMAND message with SC_RESTORE, when I
doubleclick the title bar.
--------------
Post by Jonathan Wood
My guess is that double clicking the title bar would produce the same
message.
Looks like you implemented a handler. Are you saying it was not called
when the title bar was double clicked?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and
would appreciate it if someone would tell me how to handle the restore
message upon double-clicking the title bar. How does that differ from
clicking the Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Jonathan Wood
2006-09-12 00:50:06 UTC
Permalink
Ah... Sounds like you got it then. Good.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Steve Russell
Combining 0xFFF0 with nID has straightened everything out.
if( (nID & 0xFFF0) == SC_RESTORE)
---------------
Post by Steve Russell
I can say this: In the handler, I added a TRACE of nID. The Restore box
delivers 61728 (F120), which is SC_RESTORE, of course. But doubleclicking
on the title bar gives me 61730 (F122), which I do not recognize. When
the window is in restored size and I maximize it, the first click on the
title bar gives me 61458 (F012); . the second reads 61490 (F032).
However, Spy++ displays the WM_SYSCOMMAND message with SC_RESTORE, when I
doubleclick the title bar.
--------------
Post by Jonathan Wood
My guess is that double clicking the title bar would produce the same
message.
Looks like you implemented a handler. Are you saying it was not called
when the title bar was double clicked?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and
would appreciate it if someone would tell me how to handle the restore
message upon double-clicking the title bar. How does that differ from
clicking the Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Jonathan Wood
2006-09-12 00:49:38 UTC
Permalink
Steve,
Post by Steve Russell
I can say this: In the handler, I added a TRACE of nID. The Restore box
delivers 61728 (F120), which is SC_RESTORE, of course. But doubleclicking
on the title bar gives me 61730 (F122), which I do not recognize. When the
window is in restored size and I maximize it, the first click on the title
bar gives me 61458 (F012); . the second reads 61490 (F032).
However, Spy++ displays the WM_SYSCOMMAND message with SC_RESTORE, when I
doubleclick the title bar.
This is the behavior I would expect. I would make absolutely certain this is
not happening before moving on.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Joseph M. Newcomer
2006-09-12 03:08:23 UTC
Permalink
The rule is that ;you must ignore the low-order 4 bits of the WM_SYSCOMMAND message, so
the correct test is always something of the form
switch(nID & ~0xF)
so F122 is a perfectly valid representation of SC_RESTORE. Check the "remarks" section on
OnSysCommand.
joe
Post by Steve Russell
I can say this: In the handler, I added a TRACE of nID. The Restore box
delivers 61728 (F120), which is SC_RESTORE, of course. But doubleclicking
on the title bar gives me 61730 (F122), which I do not recognize. When the
window is in restored size and I maximize it, the first click on the title
bar gives me 61458 (F012); . the second reads 61490 (F032).
However, Spy++ displays the WM_SYSCOMMAND message with SC_RESTORE, when I
doubleclick the title bar.
--------------
Post by Jonathan Wood
My guess is that double clicking the title bar would produce the same
message.
Looks like you implemented a handler. Are you saying it was not called
when the title bar was double clicked?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and
would appreciate it if someone would tell me how to handle the restore
message upon double-clicking the title bar. How does that differ from
clicking the Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Tom Serface
2006-09-11 19:19:08 UTC
Permalink
My guess is that it sends a SC_RESTORE if the windows is maximized and an
SC_MAXIMIZE if it is not maximized.

Tom
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and would
appreciate it if someone would tell me how to handle the restore message
upon double-clicking the title bar. How does that differ from clicking the
Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Joseph M. Newcomer
2006-09-12 03:09:16 UTC
Permalink
No, he was testing the wrong value. It should have been

if( (nID & ~0xF) == SC_RESTORE)

joe
Post by Tom Serface
My guess is that it sends a SC_RESTORE if the windows is maximized and an
SC_MAXIMIZE if it is not maximized.
Tom
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and would
appreciate it if someone would tell me how to handle the restore message
upon double-clicking the title bar. How does that differ from clicking the
Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Jonathan Wood
2006-09-12 16:35:10 UTC
Permalink
Not sure why you started that sentence with "no". Turns out, both me and Tom
were correct that this notification IS sent when window is restored by
having the title bar clicked. So, that should've been a "yes".

Looks like we just both failed to recall the issue with the low bits (which
I'm sure Tom's dealt with before as have I).
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Joseph M. Newcomer
No, he was testing the wrong value. It should have been
if( (nID & ~0xF) == SC_RESTORE)
joe
Post by Tom Serface
My guess is that it sends a SC_RESTORE if the windows is maximized and an
SC_MAXIMIZE if it is not maximized.
Tom
Post by Steve Russell
I am getting acquainted with handling some WM_SYSCOMMAND messages and would
appreciate it if someone would tell me how to handle the restore message
upon double-clicking the title bar. How does that differ from clicking the
Restore box?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_RESTORE)
::Beep(500,100);
CFrameWnd::OnSysCommand(nID, lParam);
}
Joseph M. Newcomer [MVP]
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Loading...