Solved

Hide in stead of close for CViews

Posted on 1998-07-14
4
608 Views
Last Modified: 2013-11-20
I have a couple of views that I'd like to keep in existance, that is not open en close all the time, in stead I'd like to hide/show them, that part works fine, but I need to handle the system SC_CLOSE command so it hides the window in stead of closing it.
how do I handle the SC_CLOSE message in a CView?
0
Comment
Question by:ffrand
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Norbert
ID: 1319113
The Online help says:
CWnd::OnSysCommand

afx_msg void OnSysCommand( UINT nID, LPARAM lParam );

Parameters

nID   Specifies the type of system command requested. This parameter can be any one of the following values:

SC_CLOSE   Close the CWnd object.

SC_HOTKEY   Activate the CWnd object associated with the application-specified hot key. The low-order word of lParam identifies the HWND of the window to activate.

So simple make a message handler for WM_SYSCOMMAND
class wizzard gives you a function
void CUSLTSVRView::OnSysCommand(UINT nID, LPARAM lParam)
{
      // TODO: Add your message handler code here and/or call default
      
      CScrollView::OnSysCommand(nID, lParam);
}

change it to
void CUSLTSVRView::OnSysCommand(UINT nID, LPARAM lParam)
{
                if(nID==SC_CLOSE)
                                ShowWindow(SW_HIDE);
                else
                                CScrollView::OnSysCommand(nID, lParam);
}
That should do the work
0
 

Author Comment

by:ffrand
ID: 1319114
I tried OnSysCommand() at first, but it does not get called at all.
I've placed a breakpoint in it and it never executes, so I can only guess that the OnSysCommand() I'm overriding is the wrong one, the one on the CView Class, but what other class is there?
0
 
LVL 3

Accepted Solution

by:
Norbert earned 110 total points
ID: 1319115
if it does not work within the View a view is embedded into a frame Try OnSysCommand in the frame of the view
0
 

Author Comment

by:ffrand
ID: 1319116
ok, well, it woked on the childframe, that was staring me right in the face, thanks for taking the time to answer.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Importing Special Characters in Dynamics GP Through Integration Manager 3 88
format the code in java 6 109
fizzArray  challenge 1 107
FizzBuzz challenge 9 84
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question