Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
OutlawTornNMT
Gerbil First Class
Topic Author
Posts: 148
Joined: Sun Jul 21, 2002 5:30 pm

Splitter Wnd Issues with Stidio .Net

Thu Feb 26, 2004 1:42 pm

Ok here's my first snippet of code:

BOOL fRet = FALSE;

CRect cr;
GetWindowRect(&cr);

if(!m_wndSplit.CreateStatic(this, 2, 1, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST))
goto bail;

m_wndSplit.SetRowInfo(0, 13*(cr.Height())/16, 10);
m_wndSplit.SetRowInfo(1, 3*(cr.Height())/16, 10);

if(!m_wndSplit.CreateView(1, 0, RUNTIME_CLASS(CDirCmdView), CSize(0, cr.Height()/2), pContext))
goto bail;

if(!m_wndSplit2.CreateStatic(&m_wndSplit, 1, 2, WS_CHILD | WS_VISIBLE | WS_BORDER, m_wndSplit.IdFromRowCol(0, 0)))
goto bail;

if(!m_wndSplit2.CreateView(0, 0, RUNTIME_CLASS(CMapView), CSize(cr.Width()/2, cr.Height()/2), pContext))
goto bail;

m_wndSplit2.SetColumnInfo(0, 7*(cr.Width())/8, 10);

if(!m_wndSplit2.CreateView(0, 1, RUNTIME_CLASS(CStatusView), CSize(cr.Width()/2, cr.Height()/2), pContext))
goto bail;

m_wndSplit2.SetColumnInfo(1, cr.Width()/8, 10);

m_wndSplit.RecalcLayout();
m_wndSplit2.RecalcLayout();

fRet = TRUE;
bail:
return fRet;


This works peachy until I add the OnSize message handler, and add this code:

CRect cr;
GetWindowRect(&cr);

m_wndSplit.SetRowInfo(0, 13*(cr.Height())/16, 10);
m_wndSplit.SetRowInfo(1, 3*(cr.Height())/16, 10);

m_wndSplit2.SetColumnInfo(0, 7*(cr.Width())/8, 10);
m_wndSplit2.SetColumnInfo(1, cr.Width()/8, 10);

m_wndSplit.RecalcLayout();
m_wndSplit2.RecalcLayout();

Then I get an access violation error on the very first CreateStatic function. What gives? All I want to do is take my top portion of code, and make it so whenever the window is resize that the aspect ratio of all the childviews stays the same...

Thanks in advance.
 
Veritas
Gerbil First Class
Posts: 113
Joined: Wed Dec 26, 2001 7:00 pm
Location: Houston, TX
Contact:

Wed Mar 10, 2004 11:43 am

Well, I am not entirely sure why you get the access violation error as I have done something similar in the past. Here is a link to the tutorial I used to learn how to create splitter windows:

http://www.gamedev.net/reference/articl ... le1358.asp
 
UberGerbil
Grand Admiral Gerbil
Posts: 10368
Joined: Thu Jun 19, 2003 3:11 pm

Thu Mar 11, 2004 2:30 am

Are you verifying that you're got a non-zero sized rect before you go passing its width and height into other calls? Some of those calls may barf (that's the technical term) if you pass zeros in as args. Be careful about assuming the order of events, and also be careful about assuming your window is always some non-zero size. I can't tell you how many times I've crashed somebody's app because they had a ton of resize code that worked fine until the window was minimized (oops, how many controls can you tile in a zero sized window?)

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On