|
I must be missing something. I get what you are saying about using _tcscpy() but the second parameter in the code you posted would be an ANSI string which would work if _UNICODE is not defined. But if it is, then I would get a compile error: cannot convert parameter 2 from 'const char *' to 'const unsigned short *'
I have researched that there is a "wide char" version of this ostringstream class called, wostringstream. But, I would run into the same problem when it comes to converting it in the _tcscpy(). That is, if I am using .c_str(). How do I convert properly?
|
|
|
|
|
JohnnyG wrote:
I must be missing something
I lost the <> in HTML conversions so my code which typedefs actually looks like
typedef std::basic_ostringstream<TCHAR> _tostringstream;
|
|
|
|
|
Oh-h-h-h! Now, I get it. That makes sense. It works now. Thanks alot for your help Rama!
|
|
|
|
|
Anybody out there know how can I get the current GMT from a website such as worldtimeserver.com using CInternetSession?? I need a reliable timestamp that is not attached to the user's system time.
Any tips would be appreciated!
Its always 4:20 somewhere!
|
|
|
|
|
This would be an excellent example of a web resource provider! You can use this framework to write it.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
try this
http://www.time.gov/timezone.cgi?GMT/d/0/
When I did this from their web page, it looked like the GMT is simply used for display purposes. the 0 is used as an offset from GMT. E.G. PDT is -8.
Hope this helps,
Bill
|
|
|
|
|
I would like to set the HTML inside a CHtmlView without browsing to a site or reading a file. So far the best bet is using GetHtmlDocument and then using the write method of the IHtmlDocument interface, but I have not been too successful since I havent much experience with MFC and OLE.
If there is a better way too do it or if you would be kind enough to post some code it would be much appreciated.
Thanks in advance.
|
|
|
|
|
Try using the write and writeln methods on teh IHTMLDocument2 interface
Here is some code I got from an MS sample somewhere
// Get the pDoc interface from the CHtmlView
IHTMLDocument2 *pDoc; // Declared earlier in the code
IDispatch* pDisp = GetHtmlDocument();
HRESULT hr;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
if( pDoc )
{
HRESULT hresult = S_OK;
VARIANT *param;
SAFEARRAY *sfArray;
BSTR bstr = csText.AllocSysString();
// Creates a new one-dimensional array
sfArray = SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (sfArray == NULL || pDoc == NULL)
{
goto cleanup;
}
hresult = SafeArrayAccessData(sfArray,(LPVOID*) & param);
param->vt = VT_BSTR;
param->bstrVal = bstr;
hresult = SafeArrayUnaccessData(sfArray);
hresult = pDoc->writeln(sfArray);
cleanup:
SysFreeString(bstr);
if (sfArray != NULL)
{
SafeArrayDestroy(sfArray);
}
}
Also have a look at the tutorial by Philip Patrick
http://www.codeproject.com/internet/parse_html.asp
|
|
|
|
|
As the title says, MeasureItem just doesn't get called except for couple times at the beginning (I found that out with a debugger). It doesn't matter what height I make MeasureItem set, the effect never shows. Also ownderdraw fixed is UNset and ownerdraw variable is SET, and this class was working correctly in another application.
Here is some codes:
BOOL CMultiLineComboBox::PreCreateWindow (CREATESTRUCT& cs)
{
if (!CComboBox::PreCreateWindow (cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~( CBS_OWNERDRAWFIXED | CBS_SORT );
cs.style |= ( CBS_OWNERDRAWVARIABLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS );
return TRUE;
}
It is used like this:
m_pcomboGap[i] = new CMultiLineComboBox();
m_pcomboGap[i]->Create (WS_CHILD | WS_BORDER | CBS_NOINTEGRALHEIGHT,
rect, this, IDC_COMBO1 + i);
void CMultiLineComboBox::DrawItem(LPDRAWITEMSTRUCT lpdis) is written and
working.
Any help is appreciated, thanks.
|
|
|
|
|
If your combo located on the dialog box or property page?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I assume you meant "Is."
It's in a class derived from CFormView.
What do you have in mind?
I abandoned using MeasureItem and set sizes in AddString. But I still can't control the total height of the drop down list... Sometimes it displays all entries that are, say, 100 pixels; but sometimes it will cut off the last entry and displayed a total of 80 pixels.
I'd still appreciate it if someone can help me get MeasureItem to be used.
Can someone recommend some on-line MFC documents? This book I'm using doesn't list the specifics.
|
|
|
|
|
In VC6, when I wanted to add, for instance, the Microsoft DataGrid Control 6.0 (OLEDB) control, I went to Project | Add to Project | Components and Controls....
I can't find equivalent in VC7. Can you help me?
tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
1. Select the menu Project->Add Class
2. In the dialog box that appears. Select MFC class From ActiveX control
3. In the next dialog select the ActiveX control you want.
BTW, I don't think using MFC Wrappers around ActiveX controls is a good idea. I much rather recommend using #import the typelibrary.
|
|
|
|
|
Michel Prévost wrote:
Microsoft DataGrid Control 6.0 (OLEDB)
I don't think this component exist in VC7.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Yes, it does. I followed Rama's instructions and I found it.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Michel Prévost wrote:
I followed Rama's instructions and I found it.
But it does not exist in my computer.I don't think its thr part of default installation in VS.Net.
|
|
|
|
|
If I am using some code as follows
aThreads[iArrayIndex] = AfxBeginThread(ClientExtractThread, (LPARAM)pExtractor);
...
...
iArrayIndex = WaitForMultipleObjects(MAX_CONCURRENT_THREADS,aThreads,FALSE,INFINITE);
...
...
GetExitCodeThread(aThreads[iArrayIndex]->m_hHandle, &nRetVal);
I'm concerned that the member variable m_bAutoDelete of the CWinThread object created by AfxBeginThread, which defaults to TRUE, will cause the GetExitCodeThread call to not function correctly. Alternatively I can set this member to FALSE, but then I don't know what I have to clean up? Should I just call delete after the GetExitCodeThread has finished.
delete (CWinThread*)aThreads[iArrayIndex];
Thanks for any suggestions.
Chris
|
|
|
|
|
As you have said you can delete the CWinThread object safely
after you have got the Exit Code.
|
|
|
|
|
|
If you set m_bAutoDelete to TRUE, your thread will delete yourself. The value of 'aThreads[iArrayIndex]' in GetExitCodeThread call points to freed memory block and there's absolutely no guarantee that m_Handle contains valid value.
In short, you shouldn't use m_bAutoDelete --or-- you should store thread handles in other location.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Thanks Tomasz. You always have some good insight to offer.
I do end up having to store the thread handles in an other array since I need to pass an array of thread handles to the WaitForMultipleObjects call that I make.
Additionally, I am going to use m_bAutoDelete. But I'm going to set it to FALSE, so that when the thread completes, I can call still call GetExitCodeThread and the thread handle should still be valid. After getting the exit code value, I will then 'delete' the thread.
Thanks for the comment.
Chris
|
|
|
|
|
I have code that looks like:
CArray<obj *,="" obj="" *=""> ArrayOfObjPtrs;
ObjPtr op=new Obj();
ArrayOfObjPtrs.Add(op);
Then in another function called later in the same thread, I do:
delete ArrayOfObjPtrs.GetAt(0); // free the object ** run-time error on this line **
ArrayOfObjPtrs.RemoveAt(0);
the Run-time error is in MSVCRTD, but the last call of mine is on the stack right before it, is "Obj::`scalar deleting desctructor' (unsigned int 1) + 56 bytes
I get a Debug Asseertion:
dbgdel.cpp Line 47, Expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Can anyone please tell me what is going on? Thanks soooo much!
PS. Commenting out the 'delete' line results in a memory leak
|
|
|
|
|
Probabaly you could remove the element first and then delete it next using an
intermediatery temp variable.
|
|
|
|
|
What effect would that have?
|
|
|
|
|
How does the class ObjPtr look? Looks to me that there is some sort of a casting problem.
I feel that ArrayOfObjPtrs.GetAt(0) is not returning Obj* for some reason.
|
|
|
|