|
i don't know if it could help you but i post the entire code of my function:
void CCalcRiskPortDlg::OnCalcvar()
{
UpdateData(TRUE);
::CoInitialize(NULL);
//LoadTables Table;
//LoadTables Table2(m_dlgSector);
double *pTabVar=new double[pow(2,m_dlgAsset)];
CString strValue;
int *pTabBinPort=new int[m_dlgAsset];
int *pTabNumPort=new int[m_dlgAsset];
int k,i;
try
{
LoadTables Table(1,m_dlgSector,1,m_dlgSector);
_ConnectionPtr pConnection=NULL;
CString strTemp;
strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\vol_correl1.mdb;");
_bstr_t strCnn(strTemp);
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open(strCnn,"","",adConnectUnspecified);
Table.pCorrel=Table.LoadCorrelation(m_dlgSector,Table.pCorrel,"Correlation");
Table.pVol=Table.LoadVolatility(m_dlgSector,Table.pVol,"Volatilité");
i=0;
for(k=0;k<=m_dlgAsset-1;k++)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
}
*pTabVar=Table.CalcVar(pTabNumPort,m_dlgAsset);
for(i=1;i<=pow(2,m_dlgAsset);i++)
{
k=m_dlgAsset-1;
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
k--;
}
*(pTabBinPort+k)=1;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
}
pConnection->Close();
}
catch(_com_error &e)
{
AfxMessageBox("a pas bon");
}
m_dlgValue=pTabVar[2];
strValue.Format("%.9f",m_dlgValue);
CEdit* PEdit=(CEdit*)GetDlgItem(IDC_VALUE);
PEdit->SetWindowText(strValue);
delete []pTabBinPort;
delete []pTabNumPort;
delete []pTabVar;
::CoUninitialize();
// TODO: Add your control notification handler code here
}
i hope it help you
regards
|
|
|
|
|
It's hard to say... This is a little suspicious:
for(i=1;i<=pow(2,m_dlgAsset);i++)
{
...
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
} i runs between 1 and 2m_dlgAsset , and then you use it as an index to <cpde>pTabVar. I think you should change the last sentence to
*(pTabVar+i-1)=...;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This looks suspicious as well:
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
k--;
} Could there be any chance that k is <0 and you step out of bounds?
Putting an assert on k after decrement or (better yet?) VERIFY(--k >= 0) should help detect this problem in debug mode.
|
|
|
|
|
i've just read your post and i think that it's exactly the problem, because, when i arrive to pTabBinPort[0], i decrement again k so that it will be equal to -1. So, i will test it to see if it works;
thanks a lot
|
|
|
|
|
in fact in my code i change 2 things:
for(i=1;i<=pow(2,m_dlgAsset)-1;i++)
{
k=m_dlgAsset-1;
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
if(k!=0)
k--;
}
*(pTabBinPort+k)=1;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
}
you could see in the for statement that i going from 1 to pow(2,m_dlgAsset)-1 now and i've put a test in the while loop just for the case of k=0, so that we couldn't be in the situation of k=-1.
But now i have another problem, when i test my application with m_dlgSector=30 and m_dlgAsset=15, at the end of the function i have another message error which says:
Unhandled exception in CalcRiskport.exe (MFC42.DLL):0xC0000005:Access Violation. It's happened at this line:
strValue.Format("%.5f",m_dlgValue);
You could see the whole code in the precedent post.
|
|
|
|
|
You are not changing pTabBinPort anywhere are you? If you want to do some pointer arithmetic do it on a tmp pointer variable.
Or it could be that you are overflowing the allocated memory
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
I have a problem when I start to monitor the serial port for a BREAK signal.
It seems that a situation occur when there are BREAK signals on "the queue". That is that if I trigger a BREAK signal just before I monitor the UART port this BREAK signal can triggers the program when I start to monitor the UART.
There must be a way to clear the BREAK signal queue before I start to monitor the UART... How do I do that??
There is somethin called PURGE UART but this seem only to clear the TX and RX line, not the BREAK signal line.
Please help!!
|
|
|
|
|
ClearCommError
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
ehhh sorry about that. Do I feel lucky...well should I!?
I hope so, cause I would be very VERY grateful if you let me know the answer to my problem.
|
|
|
|
|
I am developing an MDI app. In this app I have two documents and one view for each document. Doc1 is persistant so there is only one instance of it period and that gets opened on startup by default. Doc2's view needs to be able to access a variable in Doc1. I can get a pointer to Doc1 in Doc2's view like so:
Doc2view.h
public:
CDoc2* GetDocument();
CDoc1* GetDBDocument();
....
#ifndef _DEBUG
inline CDoc2* CDoc2view::GetDocument()
{ return (CDoc2*)m_pDocument; }
#endif
#ifndef _DEBUG
inline CDoc1* CDoc2view::GetDBDocument()
{ return (CDoc1*)m_pDocument; }
#endif
Now in Doc2's view I can access the pointer to Doc1 of cource like:
CString Value;
CDoc1* pDoc = GetDBDocument();
Value = pDoc->StoredValue;
The problem is that does not point to the current instance of Doc1 for some reason. When I try and access the variable in Doc1 it returns nothing. In the above example Value would return nada.
Please help I am a little new to MDI programming so this is confusing me.
Thx,
Richard
|
|
|
|
|
inline CDoc1* CDoc2view::GetDBDocument()
{ return (CDoc1*)m_pDocument; } Maybe I haven't understood your question, but this makes little sense. What type is m_pDocument ? If it's not a CDoc1 * , forcing the cast will not covnert it into a CDoc1 * . Seems like you're treating m_pDocument either as a CDoc1 * or a CDoc2 * , depending on the situation. Could you clarify this?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry if the above is cofusing I will try and clarify:
What I did basicly was just copy the GetDocument function for Doc2view and modify the names in hopes it would get me the pointer for Doc1 in the same way it gets it's own document pointer.
Maby it would be better to ask this:
How do I get a pointer to a document? In my app there are two documents with each one having it's own view. I just need to be able to access a variable in the first document from the second documents view.
Thx,
Richard
|
|
|
|
|
|
Thx! that helped a lot I was able to fix my problem.
Thx,
Richard
|
|
|
|
|
Hi!
I'm looking for a static-like control supporting some advanced formatting (like superscript, subscript, and some special chars like sqrt, square, to-the-power-of 2, ttpo n , greek letters, etc.) Should work with ATL if possible, and I'd like to avoid using bitmaps and hosting IE for several reasons, and I can't use unicode in all cases.
Any ideas? Any controls you know?
Same would be cool for report view list ctrl columns - but I guess I'm already stretching the topic...
Thanks
Peter
|
|
|
|
|
Aren't the formatting capabilities of CRichEditCtrl enough for your needs? By selectively changing the font you can have the greek and math symbols.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yep, RE ctrl would do it; however there's still the make it non-selectable, default cursor etc, no scroll bars etc. But I'll give it a try.
(And it doesn't help with listr ctrl columns - I hoped to rip off the code for some custom drawing...)
|
|
|
|
|
Hi,
Did you ever find a control that did this, i need a similar thing and would like to avoid writing it myself.
Cheers,
Andy.
|
|
|
|
|
Hi,
I am Mani from Hyderabad, India.
My Q---->
Can we develop software like Yahoo Messenger in VC++(Dialog Based).
Just an idea......!
Mani.
|
|
|
|
|
Anonymous wrote:
Can we develop software like Yahoo Messenger in VC++(Dialog Based).
CG has replied to your Media-Player thread
Nish
p.s. By the way, you can I guess. It depends on the kind of UI you have in mind.
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Hi,
I am Mani from Hyderabad, India.
My Q---->
Can we develop software like Yahoo Messenger in VC++(Dialog Based).
Just an idea......!
Mani.
|
|
|
|
|
What on earth does that have to do with the header ?
I agree - the world needs more ways to spam each other. Check out the examples here on CP, and you, too, can help spread the joy.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Christian Graus wrote:
What on earth does that have to do with the header ?
I think it was Colin Davies who once said there is nothing wrong in marketing your post using a handsome subject
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
I'll admit it beats 'Help needed - URGENT !!!'
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
ROTFLMAO
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|