Solved

Hide in stead of close for CViews

Posted on 1998-07-14
4
600 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now