YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


MFC MDI and SDI Example to create ruler scrollview and splitter

 
 

Sample Image - Mdi.gif

Introduction

Implementing Rulers inside of Splitter Panes - 2. This article provides an example to implementation in an MDI and SDI application.

I have changed the way to create the ruler, add function to Show/Hide the ruler and reformat some part of code.

Implementation

MDI way

Collapse Copy Code
#include "Ruler.h"
class CChildFrame : public CMDIChildWnd
{
    ...
    private: CRulerSplitterWnd m_Rulers; //Ruler object
    public: void ShowRulers(BOOL bShow);//Toggle the ruler
    void UpdateRulersInfo(stRULER_INFO stRulerInfo);//Update the ruler
    ...
};
//Create the ruler

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, 
                                CCreateContext* pContext)
{
    if (!m_Rulers.CreateRulers(this, pContext)) {
        TRACE("Error creation of rulers\n");
        return CMDIChildWnd::OnCreateClient(lpcs, pContext);
    }
    return TRUE;
}

//Toggle the ruler
void CChildFrame::ShowRulers(BOOL bShow)
{
    m_Rulers.ShowRulers(bShow);

}

//Update the ruler

void CChildFrame::UpdateRulersInfo(stRULER_INFO stRulerInfo)
{
    m_Rulers.UpdateRulersInfo(stRulerInfo);
}

SDI way

Collapse Copy Code
#include "Ruler.h"
class CMainFrame : public CFrameWnd
{
    ....

All the rest is the same as MDI implementation.

Interaction

In your view (In this case CScrollView), catch >OnMouseMove, OnVScroll and OnHScroll messages to interact with the ruler.

Collapse Copy Code
//Update mouse position on the ruler

void CDemoView::OnMouseMove(UINT nFlags, CPoint point)
{
    UpdateRulersInfo(RW_POSITION, GetScrollPosition(), point);
    ...
    //Update vertical scroll range and position of the ruler
    void CDemoView::OnVScroll(UINT nSBCode, UINT nPos, 
                                    CScrollBar* pScrollBar)
    {
        UpdateRulersInfo(RW_VSCROLL, GetScrollPosition());
        ...
        //Update horizontal scroll range and position of the ruler
        void CDemoView::OnHScroll(UINT nSBCode, 
                    UINT nPos, CScrollBar* pScrollBar)
        {
            UpdateRulersInfo(RW_HSCROLL, GetScrollPosition());

and finally

Collapse Copy Code
void CDemoView::UpdateRulersInfo(int nMessage, CPoint ScrollPos, CPoint Pos)
{
    stRULER_INFO pRulerInfo;
    pRulerInfo.uMessage = nMessage;
    pRulerInfo.ScrollPos = ScrollPos;
    pRulerInfo.Pos = Pos;
    pRulerInfo.DocSize = m_ImageSize;
    pRulerInfo.fZoomFactor = m_fZoomFactor;
    
    //CMainFrame in SDI
    ((CMainFrame*)GetParentFrame())->UpdateRulersInfo(pRulerInfo);
    //CChildFrame in MDI
    ((CChildFrame*)GetParentFrame())->UpdateRulersInfo(pRulerInfo);
}

 

 

Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net