ASH84

Software Engineer/Developer, co-founder of Payhere. Ex-Banksalad. Intereseted in iteroperability, bootstrap company, writting.

[MFC] Change View in CSplitterWnd

created:2011-06-08
updated:2015-07-03
edit

이번 프로젝트를 하면서 허벌나게 CSplitterWnd 와 함께 동거동락을 하고 있는데요. MainFrame 에서 CSplitterWnd 에 대해서 구획 나누어 주고 뷰 배치하는 작업 그리고 CSplitterWnd 재정의 해서 굵기 조정하는 부분까지. 다 했는데 하나의 고비가 남아 있더군요. 그것은 바로. 런타임에서 CSplitterWnd 에 배치된 뷰를 바꾸는 일입니다.  


I  used 
CSplitterWnd in this project. In MainFrame, I was coding the Work placing view, dividing region using CSplitterWnd. Also override CSplitterWnd and then adjust the thickness. But, One obstacle remains. It’s just. In RunTime environment, change View in CSplitterWnd.

 



Below code. 







일단 MainFrame 을 가져오고 나서 CCreateContext 를 생성합니다. 위의 코드는 뷰에 도큐먼트가 없는 뷰를 대상으로 하고 있기때문에 Doc 연결을 가져오지 않는데요, 만약 도큐먼트가 있는 뷰라면 해당 부분을 넣어 주어야 할것 입니다. 그리고 CSplitterWnd 의 해당 위치에 DeleteView 를 통해서 해당 뷰를 지우고, 다시 CreateView 를 통해서 전환할 뷰를 생성해 주면 됩니다. 매우 간단하지요?


Once, Get pointer of MainFrame, Create CCreateContext. In the above code, Do not get Document Connection becauseof the view without document. But if the view get Document, insert document connection part. And erase the view using DeleteView fuction of CSplitterWnd, Create changing view using CreateVIew Fucntion. It is very Simple. 








그런데 만약 전환하려는 뷰의 OnInitalUpdate() 함수에서 뷰 안에 있는 컨트롤들을 배치하고 있다면?


But if you want to switch the view OnInitalUpdate () function in the control of the view if you are placed?

 

 



아쉽게도 CreateVIew 를 통해서 런타임 상에서 배치를 하게 되면 OnInitalUpdate() 함수가 호출되지가 않습니다. 만약 어떤 정의하는 부분이나 초기화 하는 부분이 있다면 초기화가 되지 않겠지요. 때문에 명시적으로 호출해 주어야 합니다. 그래서 CView 클래스의 인스턴스를 만들어서 생성된 View 를 가져와서 명시적으로 OnInitialUpdate() 를 호출해 주고 있는 것입니다. 




Unfortunately, if placed on the runtime through CreateVIew, OnInitalUpdate () function is not called. If you have any part of definition or initiation, do not define or init. so you must call init. So that call explicitly OnInitialUpdate() function using the point of created view.

 





런타임 상에서 OnInitialUpdate() 함수를 사용하기 때문에 그에 관련해서 오류가 생길수도 있으니 조심하세요.^^ 




Runtime on the OnInitialUpdate () function, because it have got an error, so be carefulwith respect ^ ^

 

















#CreateView  #CSplitterwnd  #dev  #OnInitalUpdate  #뷰전환