|
Hi all!
I've done a Visual C++ application and it works perfectly, but when I have done another similar one using the same include statements and in the same order, I get these errors:
<br />
C:\Archivos de programa\Microsoft Visual Studio\MyProjects\imevo_versiones\ejemplo ivocom 1\ventana\speech.h(468) : error C2146: syntax error : missing ';' before identifier 'FAR'<br />
C:\Archivos de programa\Microsoft Visual Studio\MyProjects\imevo_versiones\ejemplo ivocom 1\ventana\speech.h(468) : fatal error C1004: unexpected end of file found<br />
I never got these errors before and the changes that I've done doesn't matter this header "speech.h" (I think so at least).
Any ideas?
Thank you in advance!
|
|
|
|
|
If memory serves me you are missing a semicolon at the end of the class prototyped in speech.h
|
|
|
|
|
I don't know what you mean... (I'm just a newbie)
The error must be out of the speech.h code because it works ok with other applications and it's the same for all of them.
Where should be that missing semicolon?
Thanks!
|
|
|
|
|
Try using #include <windows.h> before you include speech.h
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi:
i have an SDI Application in which i have used CFormView as my view Class ,
i have two edit controls Edit1 and Edit2 and two buttons Ok and Cancle
i want to make Ok as default Button as Edit1 Control gets focus and when Edit2 Control gets focus i want to make Cancle as default Button ,
i m trying this code to do this
on Event Handler of Edit1 Set Focus i m trying this code
ptrOne->SetButtonStyle(ptrOne->GetButtonStyle() | BS_BS_DEFPUSHBUTTON)
but it is not working ,
can any one help me....
Thanks
"Winner's don't do different things , they do things differently "
|
|
|
|
|
You need to remove the BS_DEFPUSHBUTTON style from the Ok button and add it to the cancel button. However such changes may not be recognized once the form has been created.
Also sound like a terrible idea from a UI persptive. Poor old user.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
You should also send the DM_SETDEFID message to the dialog window, with WPARAM set to the control ID of the cancel button. Otherwise it visually changes, but the behaviour doesn't necessarily...
Steve S
|
|
|
|
|
OK, say I have two classes: class A and class B and I need both classes to be able to refer to each other. In class A I have #include "b.h" and in class B I have #include "a.h" .
In each file the #include statements are within a #ifndef block like so
#ifndef _A_H
#define _A_H
#include "b.h"
class A
{
.
.
.
};
#endif
to prevent each class being redefined.
But... this throws compilation errors! For example, in class B it says class A is not defined. I feel it's a prob with the #ifndef stuff I've got going on there. Some of you smart guys must know a better way to do this and one with which I will not get these feckin' errors. Any ideas? Any help much appreciated! Thanks.
Eoge
Dublin, Ireland
|
|
|
|
|
You need to forward declare the classes being used.
eg.
class A;
class B
{
A* m_pA;
...
};
This works where you are using pts to the associated classes. It won't work if instances of each class are defined with the other class. My guess is that isn't possible.
As an aside I have to wonder why you have two classes so tightly coupled to each other in this way.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Excellent! That's solved my problem. Thank you so much.
I'm still a little confused though... why does this work? I thought that with a #include statement I was effectively forward declaring that class. For example, if I write
#include "a.h"
class A;
class B
{
A* m_pA;
...
};
don't I effectively have
class A
{
...
};
class A;
class B
{
A* m_pA;
...
};
?
On your aside as to why I may desire / require such a thing:
Well, it's a question I've been asking myself actually. I'm writing a simulation application that has an Environment object which contains a list of Person objects. These Person objects need to access some resources contained within the Environment object in which they reside. To do this, my Person object has a pointer back to the Environment so that it may access these resources.
So, do you think that this is an awkward way to go about solving this problem?
Thanks again.
Eoge
Dublin, Ireland
|
|
|
|
|
eoge wrote:
I thought that with a #include statement I was effectively forward declaring that class
#include is a preprocessor directive. The preprocessor runs before the compiler. You have to think of #include as if it takes the contents of the file and inserts it at that point in the code. Once all of the include's have been performed, then the compiler starts. #include has nothing to do with the class being declared.
Forward declarations are perfectly appropriate when you have objects that refer to each other. For example, suppose we have a class 'Parent'. This class could contain a list of objects of class 'Child'. At the same time, each 'Child' object could have two pointers of type 'Parent', one called 'Mother' and the other 'Father':
class Child;
class Parent {
Child *ChildrenList;
};
class Child {
Parent *Mother;
Parent *Father;
};
Software Zen: delete this;
|
|
|
|
|
have you tried
#pragma once
instead of the #ifndef block.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening??
Øivind
|
|
|
|
|
Add OnOK() and OnCancel() handlers and don't call the base class handlers. Ie,
void CMyDialog::OnOK()
{
CDialog::OnOK(); }
just comment out the Wizard generated call to CDialog::OnOK() and all will work as you expect.
Rob Manderson
Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004
|
|
|
|
|
|
Alternatively you can override PreTranslateMessage
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if ((pMsg->wParam == 13) || (pMsg->wParam == 27))
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Sorry cant remember the VK defns (its too late!)
Ant.
|
|
|
|
|
I would like to know the basic Difference Between CListCtrl and CListView.
Does each of them behave differently ?
laiju
|
|
|
|
|
The CListCtrl wraps a Win32 Common Controls List View. It's a straight control. The CListView is actually derived from CView and wraps the List View so that it can be used in the Document / View architecture of MFC. The controls behave the same, the difference is the intended use.
|
|
|
|
|
First I do appreciate your help .But iam sorry to say that I have not understood the basic difference between CListView and CListCtrl.
I would appreciate if you could elaborate on the fundamentals.
laiju
|
|
|
|
|
CListCtrl is the MFC wrapper class for a Windows list control.
CListView is the corresponding 'view' class in MFC, when you want one of the views in your document/view application to be implemented using a list control. One of the member functions of CListView returns a reference to the underlying CListCtrl.
If you are building a document/view application, and want one of your views to be a list control, you will use CListView. Within dialog boxes, you use CListCtrl.
Software Zen: delete this;
|
|
|
|
|
In the MFC SDI applications how can get a pointer to the frame object from the view or documect object?
|
|
|
|
|
AfxGetMainWnd()
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I use the following code to set the cursor of a window:
HCURSOR cursor = theApp.LoadStandardCursor(IDC_ARROW);<br />
<br />
SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(),<br />
GCL_HCURSOR,<br />
(LONG) cursor);<br />
The problem is that I get the following compiler warning:
warning C4311: 'type cast' : pointer truncation from 'HCURSOR' to 'LONG'
How do I do this the right way??
Øivind
|
|
|
|
|
Original function is:
ULONG_PTR SetClassLongPtr(
HWND hWnd,
int nIndex,
LONG_PTR dwNewLong
);
That mean the you have poenter on cursor and need write:
SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(),
GCL_HCURSOR,
(LONG_PTR) &cursor);
HCURSOR is "typedef unsigned int HCURSOR" but you need poenter on address.
|
|
|
|
|
With your code, I don't get any warnings, but the cursor doesn't change.. =(
SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), <br />
GCL_HCURSOR,<br />
(LONG_PTR) &cursor);
|
|
|
|