15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


ListView in Splitter Windows with MFC v3.2

Daniel Keller dkeller@psln1.psln.com -- dkeller@psln.com
Wednesday, May 29, 1996

[Watcom C/C++ 10.6 - Win95 - MFC v3.2]

Hi,
I have created a splitter window and 2 panes, It works fine but when I
move the splitter bar It doesn't erase the old abr. I guess I have to
override the OnDraw function of something similar but I don't know how
to.
Also how do I access the classes in the individual panes?

I have attached my main code file to this message.

All help is greatly appreciated.
Daniel.

--

|"Despite all my rage I am still just a rat in a cage."|
|       Billy Corgan of The Smaphing Pumpkins          |
|------------------------------------------------------|
|dkeller@psln.com                                      |
|------------------------------------------------------|

#include 
#include 
#include 
#include 
#include "splitter.h"
/////////////////////////////////////////////////////////////////////////=
//
class CListView: public CWnd
{
    public:
    DECLARE_DYNCREATE(CListView);
    CListView();
    HWND m_hwnd;
//    Create(CWnd* pParentWnd);
};

class CMainWindow: public CFrameWnd
{
    public:
    DECLARE_DYNCREATE(CMainWindow);
    CSplitterWnd SplitterWnd;       =20
    CMainWindow();
    virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs,
                                 CCreateContext* pContext);
    afx_msg void OnOpen();
    afx_msg void OnExit();
    DECLARE_MESSAGE_MAP()
};

class CTheApp: public CWinApp
{
    public:
    virtual BOOL InitInstance();
};

/////////////////////////////////////////////////////////////////////////=
//
BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd)
    ON_COMMAND(FILE_OPEN,OnOpen)
    ON_COMMAND(FILE_EXIT,OnExit)
END_MESSAGE_MAP();
/////////////////////////////////////////////////////////////////////////=
//
CTheApp TheApp;
/////////////////////////////////////////////////////////////////////////=
//
IMPLEMENT_DYNCREATE(CListView,CWnd);
CListView::CListView()
{
}

IMPLEMENT_DYNCREATE(CMainWindow,CFrameWnd);
CMainWindow::CMainWindow()
{
    LoadFrame(MAIN_RESOURCES);
}

BOOL CMainWindow::OnCreateClient(LPCREATESTRUCT lpcs,
                                 CCreateContext* pContext)
{
    SplitterWnd.CreateStatic(this,1,2);
    SplitterWnd.CreateView(0,0,RUNTIME_CLASS(CListView),
                            CSize(0,0),pContext);
    SplitterWnd.CreateView(0,1,RUNTIME_CLASS(CListView),
                            CSize(130,50),pContext);
                           =20
    return TRUE;                       =20
}                          =20
                                        =20
void CMainWindow::OnOpen()
{
    CFileDialog cDlg(TRUE);
    char FileName[256];
    char Filter[256];
    int i;

    lstrcpy(Filter,"All files (*.*)|*.*|C Files (*.c)|*.c||");
    for(i=3D0;Filter[i]!=3D0;i++)
    {
        if(Filter[i]=3D=3D'|') Filter[i]=3D0;
    }

    FileName[0]=3D0;

    cDlg.m_ofn.lStructSize=3Dsizeof(OPENFILENAME);
    cDlg.m_ofn.hwndOwner=3DNULL;
    cDlg.m_ofn.hInstance=3DAfxGetInstanceHandle();
    cDlg.m_ofn.lpstrFilter=3DFilter;
    cDlg.m_ofn.lpstrFile=3D(LPSTR)FileName;
    cDlg.m_ofn.nMaxFile=3Dsizeof(FileName);
    =
cDlg.m_ofn.Flags=3DcDlg.m_ofn.Flags|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|
                     OFN_HIDEREADONLY|OFN_EXPLORER;
    if(cDlg.DoModal()!=3DIDOK) return;
}

void CMainWindow::OnExit()
{
    TheApp.m_pMainWnd->SendMessage(WM_CLOSE,0,0L);
}

BOOL CTheApp::InitInstance()
{
    Enable3dControls();
    m_pMainWnd=3Dnew CMainWindow;
    m_pMainWnd->ShowWindow(m_nCmdShow);
    m_pMainWnd->UpdateWindow();
    return TRUE;
}



Gordon Weakliem -- gweakl@metronet.com
Sunday, June 02, 1996

At 02:51 PM 5/29/96 -0700, you wrote:
>[Watcom C/C++ 10.6 - Win95 - MFC v3.2]
>
>Hi,
>I have created a splitter window and 2 panes, It works fine but when I
>move the splitter bar It doesn't erase the old abr. I guess I have to
>override the OnDraw function of something similar but I don't know how
>to.

I suspect that you're correct, CListView isn't drawing itself for some
reason.  Initially, I had some problems with CFormView derived classes not
redrawing themselves.  Try creating a class derived from CListView and using
it instead of the raw CListView.  

>Also how do I access the classes in the individual panes?

The view in the top left pane is accessed like this:
CView *pView = (CView*) SplitterWnd.GetPane(0,0);

Also, you can set which pane of the splitter has focus from your CFrameWnd
derived class with this code:
SetActiveView((CView*)SplitterWnd.GetPane(0,1));

>
>I have attached my main code file to this message.
>
>All help is greatly appreciated.
>Daniel.
>
Gordon Weakliem
gweakl@metronet.com




Paul Pettigrew -- chilli@iinet.net.au
Friday, June 07, 1996

>I have created a splitter window and 2 panes, It works fine but when I
>move the splitter bar It doesn't erase the old abr. I guess I have to
>override the OnDraw function of something similar but I don't know how
>to.

Place a call to RecalcLayout() in your frames OnDraw.
I have just gone throught the ropes of CListCrtl's in multiple splitter panes in a single frame.

Email me for code if your still stuck.

--
Paul Pettigrew
chilli@iinet.net.au || pmpet2@mugc.cc.monash.edu.au
http://www.iinet.net.au/~chilli/





| Вернуться в корень Архива |