Solved

Hide in stead of close for CViews

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 85
if loop in java 3 138
My project did see openJDK that I installed. What could be the problem 7 140
Problem to open Excel file 15 128
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 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

8 Experts available now in Live!

Get 1:1 Help Now