Solved

Hide in stead of close for CViews

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 87
Execute multiple curl cmds with sleep and send output to file 10 104
wordmultiple challenge 12 140
Problem to App 4 97
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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