Extending CSPLitterWnd - to implement the hidden split bar

xiaoxiao2021-03-06  119

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 the CPP file as follows: void cmysplitterWnd :: HideSplitter () {m_cx = m_cxSplitterGap; // save previous cx m_cy = m_cxSplitterGap; // save previous cy m_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, and the showSplitter function when needed.

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

New Post(0)