Solved

Hide in stead of close for CViews

Posted on 1998-07-14
4
611 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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