Skip to main content

Create Splitting Windows in VC 2005

Add two CSplitterWnd type variables into the MainFrame:

CSplitterWnd m_wndSplitterLM; // split the window to left and middle panel


// Than add the following code into the OnCreateClient Function:

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// create a splitter with 1 row, 2 columns
if (!m_wndSplitterLM.CreateStatic(this, 1, 2))
{
TRACE("SpltLR create failed\n");
return false;
}

// add the first splitter pane - the default view in column 0
if (!m_wndSplitterLM.CreateView(0, 0,
RUNTIME_CLASS(CMultiLayerTree), CSize(60, 0), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}

// add the second splitter pane - which splits the right window into two columns
if (!m_wndSplitterMR.CreateStatic(
&m_wndSplitterLM, // our parent window is the first splitter
1, 2, // the new splitter is 1 rows, 2 column
WS_CHILD | WS_VISIBLE, // style, WS_BORDER is needed
m_wndSplitterLM.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
}

if (!m_wndSplitterMR.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(600, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}

if (!m_wndSplitterMR.CreateView(0, 1,
RUNTIME_CLASS(CCtrlPanel), CSize(40, 0), pContext))
{
TRACE0("Failed to create third pane\n");
return FALSE;
}


return true;
}

Comments

Popular posts from this blog

Oracle ORA-01000 maximum open cursors exceeded

Several days ago, I wrote a piece of program in C#/.Net to import some records into oracle database. It is windows version 10g XE. When the program is running, I got a run-time error which is ORA-01000 maximum open cursors exceeded. Here is the Oracle docs about ORA-01000: ORA-01000 maximum open cursors exceeded Cause: A host language program attempted to open too many cursors. The initialization parameter OPEN_CURSORS determines the maximum number of cursors per user. Action: Modify the program to use fewer cursors. If this error occurs often, shut down Oracle, increase the value of OPEN_CURSORS, and then restart Oracle. In order to solve this problem, I increased my OPEN_CURSORS by using: ALTER SYSTEM SET open_cursors = 5000 SCOPE=BOTH; You can use SQL/PL client and "connect" command to login the database system by using "system" user to change the open_cursors. If you are using .NET, DBA, and Java programming, please remember to close all the re...

Comparison == vs equals() in Java

In java, we have two operations (" == " and " equals() ") to check the equivalence of String s. It is important to understand that the difference between them.    == The == operator compares the two objects and checks to see if two objects are exactly the same object (refer to the same instance). .equals() The equals() method compares the characters in the two different objects. Two strings may be different objects , but can contains the same values (exactly the same characters). public class Main {     public static void main(String[] args) {         String s1 = "Shangshu";         String s2 = new String(s1);         System.out.println(s1 + " == " + s2 + " is " + (s1 == s2));         System.out.println(s1 + ".equals(" + s2 + ") is " + (s1.equals(s2)));     } } The output of the above code is:...

Tips about sizeof() function in C and C++

The unary operator sizeof is used to calculate the sizes of datatypes in Bytes in modern luanguages in the programming languages C and C++. It is an useful operation in memory allocation. In order to use it right, some tips that you may want to know: sizeof() is a compile-time function (macro-like function), not a run-time function. Therefore, you can declare array as: int arr[sizeof(int)]; because sizeof() is a compile-time function, the equation in sizeof() function will not be calculated. For example: int i=3; int a = sizeof(i++); the value of i will not be changed after sizeof(i++);  because sizeof() is a compile-time function, it can not help you determine the size of an array parameter. The following code will print out size 12 and 4. void test_sizeof(int arr[]) { cout << "sizeof(arr) = " << sizeof(arr) << endl; } int main() { int arr[3]; cout << "sizeof(arr) =" << sizeof(arr) << endl; te...