|
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
|
|
|
|
|
System wide hook. Look throu the articles at CP.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Thank you all.
I will try...
|
|
|
|
|
More Accurate :- System Wide Hook of Type WH_CBT ....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
|
IShellFolder * psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop);
LPITEMIDLIST pidl = NULL;
#ifdef _UNICODE
psfDesktop->ParseDisplayName (NULL, 0, strArray.GetAt (0).GetBuffer(0), NULL, &pidl, NULL);
#else
OLECHAR * olePath = NULL;
olePath = (OLECHAR *) calloc (strArray.GetAt (0).GetLength () + 1, sizeof (OLECHAR));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)strArray.GetAt (0).GetBuffer(0), -1, olePath, strArray.GetAt (0).GetLength () + 1);
psfDesktop->ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL);
free (olePath);
#endif
just be patient to have a look. without unicode configuration,everything is good. But if I compiled with _UNICODE defined, after "ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL);" ,pidl is always null.
what's the matter????
Thank u every one here.
|
|
|
|
|
CString::GetBuffer returns LPTSTR , which is either a char* or a wchar_t* , depending on the unicode setting. You are testing for the definition of _UNICODE , while LPTSTR depends on the definition of UNICODE (notice the lack of underscore). When you define _UNICODE, are you defining UNICODE, and removing the definiton of MBCS too?
That being said, I'd suggest writing that piece as follows:
BSTR bstrName = strArray.GetAt(0).AllocSysString();
psfDesktop->ParseDisplayName(NULL, 0, bstrName, NULL, &pidl, NULL);
::SysFreeString(bstrName);
The above should work both for Unicode and MBCS builds.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|