|
I created a splitter window with two rows and one column. I want to display different text in the two panes and also wants to have separate horizontal scroll bar for the panes.
This is the code that i have written,
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
CRect cr;
GetClientRect( &cr);
if ( !m_mainSplitter.CreateStatic( this, 2, 1,WS_HSCROLL ) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return FALSE;
}
if ( !m_mainSplitter.CreateView( 0, 0,RUNTIME_CLASS(CTrialView),CSize(cr.Width(), cr.Height()/2), pContext ) )
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR );
return FALSE;
}
if ( !m_mainSplitter.CreateView( 1, 0, RUNTIME_CLASS(CTrialView), CSize(cr.Width(), cr.Height()/2), pContext ) )
{
MessageBox( "Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR );
return FALSE;
}
m_bInitSplitter = TRUE;
return TRUE;
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
CRect cr;
GetWindowRect(&cr);
if ( m_bInitSplitter && nType != SIZE_MINIMIZED )
{
m_mainSplitter.SetRowInfo( 0, cy/2, 0 );
m_mainSplitter.SetColumnInfo( 0, cx, 50);
m_mainSplitter.RecalcLayout();
}
// TODO: Add your message handler code here
}
void CTrialView::OnDraw(CDC* pDC)
{
CTrialDoc* pDoc = GetDocument();
CRect clientRect;
GetClientRect (&clientRect);
CBrush myBrush;
CFont myFont;
CString world("Hello World");
myBrush.CreateSolidBrush ( RGB(255,255,255) );
myFont.CreateFont (25, 15, 0, 0, FW_NORMAL, 0, 0, 0, 1, 0, 0, 0, 0, "Arial");
CBrush *oldBrush = pDC->SelectObject (&myBrush);
CFont *oldFont = pDC->SelectObject (&myFont);
pDC->SetTextColor( RGB( 200 , 200 , 200 ) );
RECT rectText = { 60 , 5 , clientRect.Width() , 75 };
pDC->DrawText( world, &rectText , DT_SINGLELINE);
pDC->SelectObject (oldBrush);
pDC->SelectObject (oldFont);
myBrush.DeleteObject();
myFont.DeleteObject();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
|
|
|
|
|
I have a MFC Dialog programme,and there is no problem when I use more BUTTONs
but once I define a CBUTTON variable for a BUTTON,a problem would come
like this :
0x00000001 have a exception,there is a accessing conflict when 0xC0000005 read 0x00000001
|
|
|
|
|
don't you have 255 controls on your dialog already ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
humm, well, can you have a look into you Resource.h header file to see if the #define are consecutive and do coincide with your control IDs ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Doesn't it matter?
I just make everyone have a different value,it's necessary that they are consecutive?
|
|
|
|
|
yeetins wrote:
it's necessary that they are consecutive?
no, not necessary, but if you reach the end of the allow numbers, maybe it gives you an error...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I think it doesn't matter with resource.h
I'v checked it out
|
|
|
|
|
I think you need to give us more informations if you want us to help you. For example, when does this error occur ?? At the begining of your program or when you press the button, or ... ?
Did you try to use the debugger (F5) to see what instructions causes the crash ?
|
|
|
|
|
When?I don't konw.When I started,it didn't happen.
After I'v finished the program ,I need extra functions and more BUTTON,and then it happened.
the instructions that causes the crash is "CBUTTON m_BUTTON1" in the header file.
|
|
|
|
|
do you allocate memory for you button in the class constructor ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
allocate memory ?oh,I don't konw which operation can allocate memory for buttons in the class constructor?!
|
|
|
|
|
pfff, hey, do you know C++ ? do you know how that language work ?!
in your class, you have a member CBUTTON m_Button1; , but that doesn't create a button for you !!
that just declares a data member in your class that is of type CBUTTON.
if you want to use m_Button1 as a button of your dialog, you must allocate a button and store its address into this member.
Do you know the operator new ?????
Did you ever heard of the constructor of a class ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
yeetins wrote:
When?I don't konw.When I started,it didn't happen.
I don't ask when during the developement of your project it happened but when during your program that is running ! Is it when you launch your program or is it when you press the button ??
yeetins wrote:
the instructions that causes the crash is "CBUTTON m_BUTTON1" in the header file.
It is NOT an instruction ! You just declare a variable inside a header file. It is impossible that this is causing the bug. And also, you are using CBUTTON or CButton ? Because CBUTTON is probably then a user defined class ? From where does that come ??
I will suggest you to take some time to understand how to use the debugger because it is a really powerfull tool and you can obtain results much more quickier than posting on the forum. To start the debugger, press F5 and to set breakpoints (points in which the program will be stopped and where you can watch the value of the different variables) press F9. Then what you can do to see what instruction causes the crash is using step by step debugging (with F11 if I remember correctly).
|
|
|
|
|
Thanks for help,I am trying it.
But I think this will not work,because there is no problem when compiling the program.
It happons only when I run the .exe file
|
|
|
|
|
Err, ok, I think the first thing to do is open a C++ book and understand at least the basic of the language, otherwise we won't be of any help...
yeetins wrote:
But I think this will not work,because there is no problem when compiling the program.
No errors at compilation doesn't mean that your program doesn't contain any bug !! The compiler throw errors only if it cannot 'understand' some part of your code, but if it understand your code, it will compile even if they are enormous mistakes within it.
|
|
|
|
|
cedric moonen wrote:
No errors at compilation doesn't mean that your program doesn't contain any bug !!
Otherwise, windows would be free !!! :->
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
yeetins wrote:
the instructions that causes the crash is "CBUTTON m_BUTTON1" in the header file.
Do you mean CButton ? Why not show us the entire .h file instead? It's better to copy/paste rather than re-type code into a post. It would also help if we could see the dialog's DoDataExchange() method.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
thank you very much
But I think I'd better study the basic of c++ frist
I'v found what cause the prablem,but it is not what we discussed above.
thanks again
|
|
|
|
|
well you should still post what the problem was and how you solved it so that other members of CP can benefit from what you learned if they ever come across that same situation
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Hello,
I have a strange problem with one of my classes. I have the following two classes:
<br />
template <class T0, class T1 ><br />
class SomeClass<br />
{<br />
public:<br />
typedef T0 Type0;<br />
<br />
SomeClass() {}<br />
virtual ~SomeClass() {}<br />
<br />
virtual bool DoFoo(Type0 Param1) = 0;<br />
virtual int DoFoo(Type0 Param1, int nParam2) { }<br />
<br />
};<br />
<br />
class OtherClass : public SomeClass<A, B><br />
{<br />
public:<br />
virtual bool DoFoo(Type0 nParam1) { }<br />
};<br />
And somewhere I have this code:
<br />
void SomeFunction()<br />
{<br />
OtherClass otherClass;<br />
<br />
otherClass.DoFoo(1);
otherClass.DoFoo(1, 1);
}<br />
My problem is that in SomeFunction the compiler issues C2660 for a completly valid function call. The compiler says that it doesn't know DoFoo(int, int) . I have no idea why this error is issued...
[EDIT]
I'm using VS 2005 if it is of any help.
[\EDIT]
Blog[^]
|
|
|
|
|
could be that the compiler gets confused with the A Type0 and T0.
why don^t you try casting...call it like:
otherClass.DoFoo( (Type0)1, 1);
I`m not sure that`ll solve your problem, but I`ve had similar probs..
Greets,
Davy
|
|
|
|
|