|
I define a struct like this:
typedef struct
{
float blc;
float sx;
float sy;
}ScreenStruct;
Then in the .h,I define a struct pointer :
ScreenStruct *m_Screen;
At last ,I use it in the .cpp as follows:
m_Screen[0].sx=0;
When I run ,it canont be complied.And the result is that
"miss ; (before *)" or "CView::ScreenStruct miss the storage class or class declaration".
How can I do?Thank u.
|
|
|
|
|
why do you declare m_Screen in the .h ? is it global or as it name tell (but you didn't), it is a class member ?
how is it initialized ?
why don't you declare ScreenStruct as a part of your CWiew class ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
yes.I declare the m_Screen in the Cview.h,which include the Cview class,and the m_Screen[0].cx=0 is in the Cview.cpp.
|
|
|
|
|
you didn't answer my question. how do you initialize m_Screen ?
moreover, i asked if you were declaring the struct ScreenStruct directly into the CWiew derived class...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I am sorry.
It initialized in the construction function
Cview::Cview()
{
...
m_Screen[0].sx=m_xStart;
...
} in the Cview.cpp.
The m_xStart is a float variable.
Thank u.
|
|
|
|
|
humm, it seems that you don't really know what you are doing, do you ?
where do you declare the structure ? inside the class, or outside, as a "global" type ?
notice that a talk about the class, not the .h or .cpp file !!!
class Cview {
private:
struct {
float blc;
float sx;
float sy;
} ScreenStruct m_Screen;
public:
Cview();
};
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 5:18 Wednesday 31st August, 2005
|
|
|
|
|
I think I make a mistake about the naming the class.
and the struct is a gobal type .It is not in the Cview class .So it is not a member of the class Cview.
So it like this:
typedef struct
{
//...
} Struct;
class Cview
{
public: Struct m_Screen;
public: Cview();
//... };
Thank u.
|
|
|
|
|
Ok, so let's start from the begining.
First, you have to declare your structure (that is how it will look like: what are the members). Then when it's done (and only when it's done) you can 'instantiate' a structure like that (that is, you can make use of it as a new instance).
In order to instantiate the structure, the compiler needs to know how it looks like, so it has to be defined before. Put the definition of the structure above the definition Cview class (him, also, this is not a good naming convention, I suggest to name your view class with a name more appropriate, something like CMyView). Then, inside your class, you can declare an instance of this structure:
ScreenStruct m_Screen;
Why do you want to use a pointer ? Do you need more than one (so you need a table of structure) ? If you just need one struct, use this solution instead otherwise you will need to initialize yout table wlike that:
m_Screen = new ScreenStruct[10];
and then delete the memroy afterward (in the destructor of your Cview class for example).
|
|
|
|
|
|
Yes.In my Application ,there are three struct ,so I define the pointer .So I think the pointer is a better way.But as u see, the result is not good.Thank you for your help.
|
|
|
|
|
And I declare the struct ScreenStruct before the Cview class'declaration.Thank u
|
|
|
|
|
where do you define this struct? Is in the same .h file where you declare m_Screen?
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
yes,the .h file is the Cview.h ,the .cpp is the Cview.cpp.thank u
|
|
|
|
|
if the definition of the struct is also in the CView.h file, then I guess you should check if you made any spelling-mistake.
|
|
|
|
|
I think it'll be better if you paste all the code of the CView.h file if it's not a huge one.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
There are the code of the CAirrfView.cpp and CAirrfView.h.
In the CAirrfView.cpp file:
CAirrfView::CAirrfView()
{
m_MaxScreen=20000;
m_Screen=new ScreenStruct[m_MaxScreen];
m_Screen[0].sx=m_xStart;
m_Screen[0].sy=m_yStart;
m_Screen[0].blc=blc;
}
CAirrfView::~CAirrfView()
{
delete m_Screen;
}
.....
void CAirrfView::GraphAll()
{
float minx,miny,maxx,maxy,bl1;
CAirrfDoc* pDoc =(CAirrfDoc*) GetDocument();
minx=(float)1E20;miny=(float)1E20;maxx=-(float)1E20;maxy=-(float)1E20;
SetCapture();
SetCursor(LoadCursor(NULL,IDC_WAIT));
BOOL pb=pDoc->GetRect(&minx,&miny,&maxx,&maxy);
SetCursor(LoadCursor(NULL,IDC_ARROW));
ReleaseCapture();
if(!pb)
{
m_xStart=0;
m_yStart=0;
blc=1.0;
return;
}
else
{
bl1=(maxx-minx)/(m_wScreen-20);
blc=(maxy-miny)/(m_hScreen-20);
if(bl1>blc)
blc=bl1;
m_xStart=minx-10*blc;
m_yStart=miny-10*blc;
}
p_Screen[pDoc->m_CurrentScreen1].sx=m_xStart;
p_Screen[pDoc->m_CurrentScreen1].sy=m_yStart;
p_Screen[pDoc->m_CurrentScreen1].blc=blc;
pDoc->m_CurrentScreen=pDoc->m_CurrentScreen1;
Invalidate();
}
in the CAirrfView.h file:
typedef struct
{
float blc;
float sx;
float sy;
}ScreenStruct;
class CAirrfView : public CView
{
ScreenStruct *m_Screen;
ScreenStruct *p_Screen;
int m_MaxScreen;
float m_xStart,m_yStart,blc,bl1;
void GraphAll();
};
Thank you.
|
|
|
|
|
it compiles and works fine
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
this is not answering your problem, but in your destructor, you should use delete[] instead of simple delete
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Im on a project wherein i have to lock a file & restrict its access on a certain interrupt from a port ?
I need someone to help me out with this , Any info on this topic would be of great help !!!!!!!!!!! Information could be in the form of Source Code , references ,any comment.............
Thank You
|
|
|
|
|
some ont know how i can add events in JournalPlaybackProc to simulate events in an hook ?
i have try this but it s only modify the event !
extern "C" __declspec(dllexport) LRESULT CALLBACK GetMsgProc(INT nCode,
WPARAM wParam,
LPARAM lParam)
{
MSG* pCwp = (MSG*)lParam;
pCwp->pt.x= 589;
pCwp->pt.y= 654;
lParam = (LPARAM)pCwp;
}
return CallNextHookEx( hHook, nCode, wParam, lParam );
}
|
|
|
|
|
Hello
I want to load MS Powerpoint dynamically into my dialoguebased MFC programm.
What control should I use and how to do this....? Any example or any link that can give me some material for this ?
Thankx and Regards
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
I am not sure what you mean by load PowerPoint into your app...but this will launch Powerpowerpoint....Note you may have to look into the Registry where Excel is installed.
try
{
STARTUPINFO start;
PROCESS_INFORMATION processinfo;
char temp[300];
CString strMessage = "Unable to launch the editor ",
strDefEditor,
strFileName;
pFrameWnd = dynamic_cast<cmainframe*> (AfxGetApp()->m_pMainWnd);
if (pFrameWnd)
{
//strEditor contains path to PowerPoint
strDefEditor = pFrameWnd->m_DlgOptions.m_strEditor;
}
strcpy (temp, strDefEditor);
strcat(temp, " \"");
strFileName = GetPathName();//ocument()->m_strL>GetPathName() ;//m_DlgDataSave.m_strFilePath + m_DlgDataSave.m_strFileName;
//SaveFile(&strFileName);
strcat(temp, strFileName);
strcat(temp,"\"");
start.cb = sizeof start;
start.lpReserved = NULL;
start.lpDesktop = NULL;
start.lpTitle = NULL;
start.cbReserved2 = 0;
start.lpReserved = NULL;
start.dwFlags = STARTF_USESHOWWINDOW;
start.wShowWindow = SW_SHOW;
if ( !::CreateProcess( NULL,
temp,
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&start,
&processinfo))
{
strMessage += "\"" + strDefEditor + "\".";
if (pFrameWnd)
pFrameWnd->MessageBox(strMessage, "Error launching editor", MB_OK);
}
else
{
// Close the data file to prevent access problems
//m_pDoc = (CESCDoc*) GetActiveDocument();
//m_pDoc->OnCloseDocument();
// OnCloseDocument();
}
}
catch(...)
{
pFrameWnd = dynamic_cast<cmainframe*> (AfxGetApp()->m_pActiveWnd);
if (pFrameWnd)
pFrameWnd->MessageBox( "Unable to open the file in Excel.",
MAIN_ERROR_MSG,
MB_ICONEXCLAMATION);
}
-Anil
|
|
|
|
|
can it be done with OLE?
V
|
|
|
|
|
Hello,
How can I get a notification to my program when another window (for eg. windows' calculator) is created or activated by the user?
Thank you for any valuable help.
|
|
|
|
|
One way is to set timer of few milliseconds. On its callback write code to like this,
FindWindow()//i dont remember exact API, but it finds window by title
|
|
|
|