Extending CSPLitterWnd - to implement the hidden split bar

xiaoxiao2021-03-06  81

CSPLitterWnd can easily create a splitter window. To hide a view in the splitter window, simply call: getPane function Get the view pointer, then call the showWindow function hide the window. But doing this only hide the view window, there is no hidden split bar; after the program frame size changes, the program will automatically call the ReCalcLayout function, so that the display effect is not normal. CSplitterWnd splitter did not provide the size of the public function set, by analyzing the source code that CSplitterWnd: it contains several protected member variables public: m_cxSplitter, m_cySplitter, m_cxBorderShare, m_cyBorderShare, m_cxSplitterGap, m_cySplitterGap, m_cxBorlder, m_cyBorlder by re Construct the value of m_cxsplittergap, m_cysplittergap variables, you can implement the function of changing the size of the division. ------------------------------------solution------------ -------------------------------------------- 1. Delivery from csplitterwnd A new class cmysplitterWnd; 2. Add member variables and functions in .h files as follows: int m_cx; int m_cy; void hidesplitter (); void showSplitter (); 3. Add implementation code in .cpp file as follows: Void CMysplitterWnd: : Hidesplitter () {m_cx = m_cxsplittergap; // Save previous cx m_cy = m_cxsplittergap; // save previous cym_cxsplittergap = 0; m_Cysplittergap = 0;}

Void cmysplitterWnd :: showSplitter () {m_cxsplittergap = m_cx; m_Cysplittergap = m_cy;} 4. Generate a splitter window using the new class CMYSPLITTERWND, call HideSplitter, showSplitter function when needed.

转载请注明原文地址:https://www.9cbs.com/read-108095.html

New Post(0)