|
Hi, hope someone can help me out here! Is it possible to pass an array to a function? I have a double data[32768] and I want to process it in some other function but I'm not sure of the syntax used to pass the array to another function. I tried
<br />
double[] void Window(double data[])<br />
{<br />
<br />
<br />
return data[];<br />
}<br />
but obviously that didn't work!
Thanks in advance,
Paddy
|
|
|
|
|
Paddy wrote:
double[] void Window(double data[])
Did you compiler swallow this?
You should be doing something like this (if I get your point):
double *Window(double *data, size_t count)
{
return data;
}
|
|
|
|
|
Thanks for the help thats exactly what I was looking for!
No my compiler didn't like the double[] void Window(double data[]) attempt, ha ha!
paddy
|
|
|
|
|
I have a quick question (okay maybe not so quick) about timing and controlling the TCP/IP stack in windows.
I developed a communications stack for an application that has to support large file tranports and smaller messages across TCP connection. The smaller (< 1K) control messages seem to work fine and the stack is able to communicate. However when I drop the big 10K message on the stack, it all seems to be writing correctly, however I am seeing a significant delay of 3 seconds between each 1k Window going out. (Note the TCP ACK comes back in around 9ms.) This 3 second delay (30 seconds total to send all 10K) seems a bit of a waste. I am going to continue to test and see if it is my machine but I believe it must be a property of the sockets. One other note is that if I send a continuous stream of the small control messages, there is no 3 second delay between packets.
I set up the socket as an overlapped socket:
m_Socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_IP, NULL, 0, WSA_FLAG_OVERLAPPED);
I then set the keep alive mode on, bind it to a local port, and then connect to the remote box. That all seems to work fine, except when I rely on the TCP window streaming mechanics I get that delay. The remote side even says that I have another 7K available in it's window that I could send. Is there some sort of TCP window parameter that I cannot find in the documentation??
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
Hi!
I have a database project using MFC and ODBC. When we create a ODBC project, we obtain a CMyRecordView class derived from CRecordView. This class use a dialog template to represent data.
I want to use a CListCtrl to represent my data.
So in my class CMyRecordView.h I have declared
CListCtrl m_wndListCtrl;
In my CMyRecordView.cpp :
DDX_Control(pDX, IDC_LISTCTRL_VIEWDATA, m_wndListCtrl);
and :
void CDataBaseManagerView::OnInitialUpdate()
{
m_wndListCtrl.InsertColumn(0,_T("Item"),LVCFMT_LEFT,100);
m_wndListCtrl.InsertColumn(1, _T("Value"),LVCFMT_LEFT, 100);
m_wndListCtrl.InsertColumn(2, _T("Time"), LVCFMT_LEFT, 100);
m_pSet = &GetDocument()->m_DataBaseManagerSet;
CRecordView::OnInitialUpdate();
}
In my dialog, my control style is set to VS_REPORT
The problem is that I dont see my columns.
I see a grey bar, but I dont see any text and I dont see any line break.
thanks for helping...
|
|
|
|
|
Probably a dumb question, but . . .
Anybody can give me some tips on this? I need to create a report based on a query (which joins a couple of tables from an Access DB). The query works fine, but I can't figure out how to use it in a new report.
Any help is appreciated.
Thanks
|
|
|
|
|
Is it okay to call EndDialog in Pretranslate message?
I want the dialog to disappear when they press enter so I'm overriding the pretranslate. I just dont know if this is ok:
Pretranslate()
{
stuff...
EndDialog(IDOK);
return TRUE;
Appreciate your help,
ns
|
|
|
|
|
I'm not sure, I've never tried it. Have you experienced a problem with it?
It seems to me like your dialog box doesn't have an OK button (IDOK) but you want it to behave as if it did. If that's the case, it's a lot easier to just add a line to your dialog's message map:
BEGIN_MESSAGE_MAP(CYourDlg, CDialog)
ON_BN_CLICKED(IDOK, OnOK)
END_MESSAGE_MAP()
Regards,
Alvaro
That which does not kill me postpones the inevitable. -- despair.com
|
|
|
|
|
It seems to work okay with the "enter" exit. I do have an ok button but users are standardly used to dismissing dlgs with an enter which takes their input plus exits....
Thanks much for the response
Appreciate your help,
ns
|
|
|
|
|
As long as you have specified a Default Button, Enter acts on that, which is normally to close the dialog, so I'm confused.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
I was trying to have the user exit the dlg in two ways....either by pressing OK, or by hitting enter after a valid entry on a dlg textbox. I see your point now. I did the unecessary pretranslate.....the OK button if its the default will automatically respond to bn_clicking it, or pressing enter....and exit.
Thanks.
Appreciate your help,
ns
|
|
|
|
|
Hello,
INTRODUCTION
I'm using HTMLView in order to show the user a better and intuitive GUI.
I'm modifying the contents of the HTML page dinamically, and in order to avoid to write to disk each time that I want to make a modification, I modify the contents directly from memory.
I don't know how to create a new HTML document, so I must make the first navigation in a standard way before to modify the contents. (I've not been able to do it ). In order to create the document I use one of those methods:
<code>1.</code> this->Navigate2(_T("about:blank"), navNoHistory);
<code>2.</code> this->LoadFromResource(_T("IDR_HTML1")); The code that I use in order to modify the HTML content dynamically (after the creation via the previous 1 or 2 method) is the next one:
<code>3.</code>
lpDispatch = this->GetHtmlDocument();
if (lpDispatch)
{
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDoc2);
lpDispatch->Release();
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (pSafeArray)
{
hr = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pElement->vt = VT_BSTR;
pElement->bstrVal = csHTML.AllocSysString();
hr = SafeArrayUnaccessData(pSafeArray);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pHTMLDoc2->clear();
pHTMLDoc2->close();
hr = pHTMLDoc2->write(pSafeArray);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
}
SysFreeString(pElement->bstrVal);
}
if (pSafeArray) SafeArrayDestroy(pSafeArray);
}
if (pHTMLDoc2) pHTMLDoc2->close();
}
} QUESTION
I have used the perfmon Win2k utility [(Control Panel >> Administrative tools >> ...) or (executing directly "perfmon")] in order to find out if my code has memory leaks or handle leaks.
Calling the previous portions of code (1. , 2. , and 3. ) leak some handles.
I would like to know why this is happening and how to avoid this.
NOTES
NOTE 1:
In order to see this I've used perfmon and I've added a new graph:
1. I've selected type "process".
2. I've selected "my process".
3. I've selected "Handles amount".
NOTE 2:
If I comment the code (1. , 2. and 3. ), there are no handle leaks (the handle leaks disappear).
As always thank you in advance.
|
|
|
|
|
With this line in your code,
lpDispatch->Release();
you are freeing the document before you use it. Nice!
A suggestion is to use a smart pointer instead, in order not to have to manage the interfaces life cycle yourself :
CComQIPtr<IHTMLDocument2> pHtmlDoc( GetHtmlDocument() );
|
|
|
|
|
Well, I've changed the code as you've suggested, but the handle leaks are even faster than before... (I'm sure that it is my fault because it's the first time that I use this kind of pointers and that I work with HTMLViews...). This is the code:
CComQIPtr<IHTMLDocument2> pHtmlDoc(this->GetHtmlDocument());
if (pHtmlDoc)
{
pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (pSafeArray)
{
hr = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pElement->vt = VT_BSTR;
pElement->bstrVal = csHTML.AllocSysString();
hr = SafeArrayUnaccessData(pSafeArray);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pHtmlDoc->clear();
pHtmlDoc->close();
hr = pHtmlDoc->write(pSafeArray);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
}
SysFreeString(pElement->bstrVal);
}
if (pSafeArray) SafeArrayDestroy(pSafeArray);
}
pHtmlDoc->close();
}
In the other hand, and using the first code (the posted in the first question) I've changed two things (and this is how the code is working now):
lpDispatch = this->GetHtmlDocument();
if (lpDispatch)
{
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDoc2);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (pSafeArray)
{
hr = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pElement->vt = VT_BSTR;
pElement->bstrVal = csHTML.AllocSysString();
hr = SafeArrayUnaccessData(pSafeArray);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
else
{
pHTMLDoc2->clear();
pHTMLDoc2->close();
hr = pHTMLDoc2->write(pSafeArray);
if (!SUCCEEDED(hr))
{
bRetorn = false;
}
}
SysFreeString(pElement->bstrVal);
}
if (pSafeArray) SafeArrayDestroy(pSafeArray);
}
if (pHTMLDoc2) pHTMLDoc2->close();
}
pHTMLDoc2->Release(); <code>this is new...</code>
lpDispatch->Release(); <code>this is what I've moved...</code>
}
Using this version the problems are exactly the same than the ones that I've found in the first release...
Could you give me an idea on how to continue working? my customer has already seen the program and this program has to work 24 hours a day, this means that I cannot go back to plain texts and that I must find the solution...
Thanks a lot in advance...
|
|
|
|
|
I would remove the clear() and close() method calls, since the only thing that matters is the write() method.
|
|
|
|
|
Well, thank you, I've done it and it continue working, but it continue leaking some handles...
I have more information to give to you:
The third code portion (step 3.) doesn't seems to be the guilty: that HTMLView modify it's contents each time the user selects items in a listView.
The HTML is used in order to show information regarding to items of a ListView, so each time that the user changes the selection the HTML gets changed...
The fact is that when the user changes the HTML View via selecting another field, nothing happens (I don't leak any handle).
but the first time the leaking occurs...
It seems that I create the new page via "Navigate2(_T("about:blank"));" and that when after I try to modify it I don't do it allright, because then and only then is when the leaks happen:
PROGRAM FLOW WHEN LEAKING HAPPEN:
1. this->Navigate2(_T("about:blank"), navNoHistory); <code>This line ONLY happens at the intitialization of the view...</code>
2. Selecting programatically the first item in the listview.
3. OnItemchanged calls PrepareHTML(); (Only one time (I'm sure about it))
4. PrepareHTML(); contains the <code>step 3</code> (the one you've helped me to modify...)
5. Closing window.
PROGRAM FLOW WHEN LEAKING HAPPEN 2:
1. this->Navigate2(_T("about:blank"), navNoHistory); <code>This line ONLY happens at the intitialization of the view...</code>
2. Selecting programatically the first item in the listview.
3. OnItemchanged calls PrepareHTML(); (Only one time (I'm sure about it))
4. PrepareHTML(); contains the <code>step 3</code> (the one you've helped me to modify...)
5. the user selects n times other items in the listview. <code>see notes below "note 1"</code>
6. Closing window. NOTES:
note 1:
It's curious to see that the same handles are leaked if the user selects 2000 different items in the listview or if the user doesn't select any other item than the first one that is selected.
note 2:
If I comment the line that writes the safearray inside the HTML (inside the step 3 )(hr = pHTMLDoc2->write(pSafeArray); ) then no leaks happen.
note 3:
notes 1 and 2 make me think that I have misunderstood something in the middle of the steps 1 and 3 because the leaking only happen between those steps...
I've noticed that leakage only happens when I create the HTML page using Navigate2 and when after I Write a safearray inside the HTML page... leakage doesn't happen if, after the first time I select n items in the listview, in this case the HTML modification happens without any error...
As always thank you in advance.
|
|
|
|
|
I don't know what might be the point of doing Navigate2("about:blank"). I don't think it is necessary. After all, once the underlying web browser instance is running, there is a default document to write to.
|
|
|
|
|
I thought this, but when I try to get the document the lpdispatch is not ready...
I would not do this if I would know how to create and attach a document to the CHTMLView...
But meanwhile...
Time to say that the HTMLView is not a normal HTMLView...
It's a HTMLCtrl, a wrapper class written by Paul DiLascia that makes possible to insert a HTMLView inside a dialog.
But before posting the question here in CP, I wrote down to Mr. DiLascia in order to ask him about it and his answer was that it must be a error of the MFC because his class was just a wrapper...
If you want I can try to send you a little sample code in order to make easier to talk about the problem...
What do you think about me sending you a little sample of this?
If you don't want to receive my little sample (with all the needed modifications), you can also download his article and source codes from his site at: http://www.microsoft.com/msj/0100/c++/c++0100.asp[^]
Note:
The DiLascia's article doesn't modify dynamically the web page contents.
Thanks a lot in advance for your time and help.
|
|
|
|
|
Ok then, to spend as little time as possible with the handle leak issue, the first thing to do is to isolate the code. This is a general debugging rule, and it translates in your particular case by trying to reproduce the behaviour with a simple CHtmlView class.
Good luck!
|
|
|
|
|
I have a little sample ready, can I send it to you? it's really simple:
2 dialogs and 3 buttons...
What do you think about it?
Thank you in advance.
|
|
|
|
|
Hello,
I'd like to tell you that I'm very sorry to annoy you with my problems... I don't like to do it, but I need to solve those problems as fast as I can... the program is now installed in an industrial PC that controls a machine and after some hours the PC crashes...
I hope that after seeing the little program you'll be able to tell me how stupid I've been to pass a surely easy thing...
As I said before (in other post) I'm dealing with those pointers and HTML for first time...
Thank you in advance, and please, if you don't want me to send you the sample, feel free to tell it to me, you've been trying to help me for a long time and I don't want to annoy you more...
|
|
|
|
|
Hello, I've written down (and posted) an article on how to place HTML inside a dialog (from Paul DiLascia) and how to change it dynamically, it is about what I've been asking you those days...
Would you be so kind to take a look at it? you could download the demo project and see what happens directly...
this is the direction of the article: http://www.codeproject.com/useritems/HTMLCtrlSample.asp[^]
Thank you in advance.
|
|
|
|
|
Joan,
Can you explain what you are trying to accomplish in step 3. Is this just to give you a blank html page to work with or ...??
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
In step 1 or 2 I make the browser to load a blank page in order to be able to work with it (create a new page).
In step 3 I modify the contents of the newly created HTML page using a CString that contains the code that I want to appear inside the HTML page.
Then, as I don't know how to tell the HTMLView to create a new HTML page to work with it, I make the HMLView to navigate to a blank page (steps 1 or 2 ) and then I modify this page (step 3 ).
hope this clarify what I'm trying to do...
Thank you for your interest.
|
|
|
|
|
Hi Joan,
Another simpler way to replace your page is as follows:
1) In your blank page add an id attribue to the body tag. eg:
<body id="mybody">
2) The use this code:
MSHTML::IHTMLDocument2Ptr pDoc( GetHtmlDocument() );
MSHTML::IHTMLElementPtr e;
e = pDoc->Getall()->item( _T("mybody") );
if ( e != NULL )
{
e->PutinnerHTML( (LPCSTR)sYourString.GetBuffer() );
sYourString.ReleaseBuffer();
}
This replaces all the html between the open and close body tags. It should do what you want.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|