2016년 4월 25일 월요일

[MFC] How to delete an Icon of toolbar

How to delete an Icon of toolbar?
Delete button cannot remove icon itself.
The way to remove the icon of toolbar is: "Just drag and drop" the icon in toolbar to out of boundary of toolbar.

2016년 3월 14일 월요일

[PCL] Point cloud library install on window 8, msvc2010

1. Download and install files: http://pointclouds.org/downloads/

2. Add environmental variable PATH in MyPC 

3. Open VS 2010

4. Add include directories in Project properties
C:\Program Files\PCL 1.6.0\include\pcl-1.6;
C:\Program Files\PCL 1.6.0\3rdParty\Boost\include;
C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include;
C:\Program Files\PCL 1.6.0\3rdParty\FLANN\include;
C:\Program Files\PCL 1.6.0\3rdParty\Qhull\include;
C:\Program Files\PCL 1.6.0\3rdParty\VTK\include\vtk-5.8;

5. Add library directories in Project properties
C:\Program Files\PCL 1.6.0\lib;
C:\Program Files\PCL 1.6.0\3rdParty\Boost\lib;
C:\Program Files\PCL 1.6.0\3rdParty\FLANN\lib;
C:\Program Files\PCL 1.6.0\3rdParty\Qhull\lib;
C:\Program Files\PCL 1.6.0\3rdParty\VTK\lib\vtk-5.8;

6. Add libraries 
#pragma comment(lib, "pcl_apps_debug.lib")
#pragma comment(lib, "pcl_common_debug.lib")
#pragma comment(lib, "pcl_features_debug.lib")
#pragma comment(lib, "pcl_filters_debug.lib")
#pragma comment(lib, "pcl_io_debug.lib")
#pragma comment(lib, "pcl_io_ply_debug.lib")
#pragma comment(lib, "pcl_kdtree_debug.lib")
#pragma comment(lib, "pcl_keypoints_debug.lib")
#pragma comment(lib, "pcl_octree_debug.lib")
#pragma comment(lib, "pcl_registration_debug.lib")
#pragma comment(lib, "pcl_sample_consensus_debug.lib")
#pragma comment(lib, "pcl_search_debug.lib")
#pragma comment(lib, "pcl_segmentation_debug.lib")
#pragma comment(lib, "pcl_surface_debug.lib")
#pragma comment(lib, "pcl_tracking_debug.lib")
#pragma comment(lib, "pcl_visualization_debug.lib")

** I don't need above all things but I don't know, what they do................

7. Types sample codes

#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>


int main ()
{
 pcl::PointCloud<pcl::PointXYZ> cloud;
 cloud.width    = 10000;
 cloud.height   = 1;
 cloud.is_dense = false;
 cloud.points.resize (cloud.width * cloud.height);
 for (size_t i = 0; i < cloud.points.size (); ++i)
 {
  cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
  cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
  cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
 }
 for (size_t i = 0; i < cloud.points.size (); ++i)
  std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

 pcl::visualization::CloudViewer viewer("PCL Viewer");
 viewer.showCloud(cloud.makeShared());
 while (!viewer.wasStopped());
 return 0;
}


<results>





2016년 2월 14일 일요일

[C++]MFC, Release method including static library

When you release your project without static library, the released exe. file would not work on other PC. That is because libraries related to your project are not included in your released file. Here I will introduce the release method including static library to prevent the happening described above.

1) In your project properties, set configuration from debug to release.
2) Click the General tab of configuration properties, 
3) Change 'Use MFC in a shared DLL' to 'Use MFC in a static library'
4) Nextly, move the Code generation tab of C/C++
5) Change '/MD' to '/MT' in the runtime library.

details are shown in below figure.





2016년 2월 12일 금요일

[C++]MFC, obtain the pointer of MainFrame, Doc, View classes

MFC, obtain the pointer of MainFrame, Doc, View classes 


// Notice: Before doing below, you have to include the header of the pointer to be obtained.



※ CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();

1. MainFrame Pointer
CMainFrame *frame = (CMainFrame*)AfxGetMainWnd();

2. Doc class Pointer
CxxxDoc *pDoc = (CxxxDoc*)(frame->GetActivedocument());

3. View class Pointer
CxxxView* pView = (CxxxView*)((CMainFrame*)(AfxGetApp()->m_pMainWnd))->GetActiveView();

--------------------------------------------------------------------------
[SDI Type]

1. MainFrame pointer
- CMainFrame *pFrame = (CmainFrame *) AfxGetMainWnd();

2. App class pointer
- CTestApp *pApp = (CtestApp *) AfxGetApp();

3. Document class pointer
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
  CTestDoc *pDoc = (CTestDoc *)pFrame->GetActiveDocument();
- CTestDoc *pDoc = ((CMainFrame *)AfxGetMainWnd())->GetActiveDocument();

4. View class pointer
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
  CTestView *pView = (CTestView *)pFrame->GetActiveView();
- CTestView *pView = ((CMainFrame *)AfxGetMainWnd())->GetActiveView();
 --------------------------------------------------------------------------------
[MDI type]

1. ChildFrame pointer
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
  CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
- CChildFrame *pChild = ((CMainFrame *)AfxGetMainWnd())->GetActiveFrame();

2. Document pointer
- CMainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
  CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
  CMdiTestDoc *pDoc = (CMdiTestDoc *)pChild->GetActiveDocument();
- CMdiTestDoc *pDoc = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveDocument();

3. View pointer

- CCainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
  CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
  CMdiTestView *pView = (CMdiTestDoc *)pChild->GetActiveView();
- CMdiTestView *pView = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveView();


** This post is written by courtesy of http://egloos.zum.com/printf/v/1940633

2016년 2월 1일 월요일

[C++] MFC, Add dialog to a SDI based project

Summary to add dialog (formview) to a project based on SDI.

1. Firstly, Create a new project which is based on SDI.

2. Add a new dialog to resource.

3. Add class to the added dialog (should be based on CDialog class) (ex. CMyDlg)

4. Add a member function "BOOL Create(Cwnd* pParentWnd); " in CMyDlg class.

5. type below codes for the member function in .cpp file of the above class,

BOOL CMyDlg::Create(CWnd* pParentWnd)
{
           return CDialog::Create(IDD, pParentWnd);
}

6. include "CMyDlg" in main frame class (Or View class)

7. declare the added class' instance (e.g., CMyDlg *dlg;)

8. Lastly, in .cpp file of Main frame class (or view class), type below codes in OnCreate (if there is no OnCreate, add message function) ,
     dlg = new CMyDlg;
       dlg->Create(this);
       dlg->ShowWindow(SW_SHOW);
       dlg->MoveWindow(0,0,1024,64); 



Additionally, if menu buttons (or event handler) are used for create the dialog, 
refer to below functions:

bool CMFC_TESTView::CreateChildDlg(void)
{
        if(dlg != NULL) return 0;
               dlg = new CMyDlg;
       
               if(dlg->GetSafeHwnd() ==0)
               {
                       if(!dlg->Create(this)) return 0;
                       else {dlg->ShowWindow(SW_SHOW);
        //dlg->MoveWindow(0,0,1024,64);
                              }
               }

  
        return TRUE;
}


bool CMFC_TESTView::DestroyChildDlg(void)
{
               if(dlg != NULL)
                       if(!dlg->DestroyWindow()) return FALSE;
       
        dlg =NULL;
        return TRUE;
}