Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

graph controls not sizable dynamically?

I am trying to size my graph controls in the OnInitDialog method, but the application crashes?
It crashes in the PositionAndSizeGraphs method on this line, graphPtr->GetWindowRect(&graphRect);

Does anyone know why? The code works fine in VC++ 6.0.


BOOL CDistribution::OnInitDialog()
{
CDialog::OnInitDialog();
PositionAndSizeGraphs();

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDistribution::PositionAndSizeGraphs()
{
RECT graphRect;
RECT histogramRect;

CNiGraph* graphPtr=(CNiGraph*) GetDlgItem(IDC_PRJECTION_GRAPH);
graphPtr->GetWindowRect(&graphRect);

CNiGraph* histogramPtr=(CNiGraph*) GetDlgItem(IDC_HISTOGRAM);
histogramPtr->GetWindowRect(&histogramRect);

int top,bottom,left,right;

top=histogramRect.top;
bottom=histogramRect.bottom;
left=graphRect.left;
right=graphRect.right;


graphRect.right=graphRect.left+ (graphRect.bottom-graphRect.top);

ScreenToClient(&graphRect);
graphPtr->MoveWindow(&graphRect,TRUE);

}
0 Kudos
Message 1 of 6
(4,122 Views)
Have you declared CNiGraph instances and associated them with the actual HWNDs for IDC_PRJECTION_GRAPH and IDC_HISTOGRAM with DDX_Control calls? You would typically declare the CNiGraph instances as member variables of CDistribution and put the DDX_Control calls in CDistribution::DoDataExchange.

Message Edited by drohacek on 06-25-2005 04:38 PM

0 Kudos
Message 2 of 6
(4,107 Views)
Yes, I have tried it that way and I get the same error message. In OnInitDialog these two objects or pointers -- depending on how you code it -- do not have HWND handles.

Message Edited by mps on 06-25-2005 07:31 PM

0 Kudos
Message 3 of 6
(4,103 Views)
When I step through my code, my CNiGraph instance is associated with the control HWND in the call to DDX_Control:



DDX_Control(pDX, IDC_CWGRAPH1, m_graph);




Do you have DDX_Control calls for IDC_PRJECTION_GRAPH and IDC_HISTOGRAM? If so, are the HWNDs within the CNiGraph instances invalid after the DDX_Control calls? Could you attach a small project that I can use to reproduce this behavior?
0 Kudos
Message 4 of 6
(4,093 Views)
Are you compiling your code in the .NET environment?
0 Kudos
Message 5 of 6
(4,090 Views)
Yes. Visual Studio .NET 2003.
0 Kudos
Message 6 of 6
(4,074 Views)