|
.net doesn't have the classwizard.. and it doesn't add any of this extra stuff when creating message handlers, etc.. so deleting it does nothing.. i guess ill leave the stuff at the top of the .h files.. i was just curious if any of the .net users had noticed that the code looks alot better with classes and functions made using .net over VS6..
-dz
|
|
|
|
|
BTW, the #pragma once is VS.NET's way of implementing the #ifndef/#define/#endif sentries that you normally find at the top of Header Files.
IIUC, the #pragma once method is a slightly faster (it is also available in VC++ 6.0) way of preventing multiple-inclusion: the preprocessor keeps track of files that use the #pragma and can locate that information faster than going through its symbol table looking for the Sentry symbol.
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
|
|
|
|
|
If you will delete the lines
//{{AFX_MSG_MAP(CStatusBarMsgWnd) and
//}}AFX_MSG_MAP
from the CPP file, and respectively
//{{AFX_MSG(CStatusBarMsgWnd) and
//}}AFX_MSG
from the H file,
class wizard will tell that it doesn't find AFX_MSG_MAP or
AFX_MSG and wants to remove the class from its view.
Also if class wizard is run for the first time, it will
tell NOTHING and your custom class will not appear at all.
These lines look like a comment but class wizard uses them.
|
|
|
|
|
I've just read how Windows NT/2000 OS's are native Unicode and that a performance hit will be encountered if using ANSI strings. So, the recommendation was to #include <tchar.h> and use the _TEXT macros and so on. I also want to build for Win 9x too so I took this recommendation to heart.
I started to convert a library I just converted from BC++ to VC++ and
encountered this problem:
TCHAR* TRadar::GetString(TCHAR *buff)
{
ostrstream os(buff, 100);
os << radarTag.GetString() << " " << maxRange << " " << scanTime;
return buff;
}
The error is:
error C2664: '__thiscall std::ostrstream::std::ostrstream(char *,int,int)' : cannot convert parameter 1 from 'unsigned short *' to 'char *'
Obviously, ostrstream does not know what a Unicode array is. Is there a simpler way than below? Or, am I gonna have to do this to all of my objects that print msgs to a std::stream output. I thought the whole purpose of using TCHAR and the macros was so that I didn't have to put any conditional preprocessor statements in except defining _UNICODE.
TCHAR* TRadar::GetString(TCHAR *buff)
{
#ifdef _UNICODE
USES_CONVERSION;
ostrstream os(W2A(buff), 100);
#else
ostrstream os(buff, 100)
#endif
os << radarTag.GetString() << " " << maxRange << " " << scanTime;
return buff;
}
|
|
|
|
|
Use
typedef std::basic_ostringstream<tchar> _tostringstream;
TCHAR* TRadar::GetString(TCHAR *buff)
{
_tostringstream os(buff); os << radarTag.GetString() << " " << maxRange << " " << scanTime;
.
.
.
}
|
|
|
|
|
You lost me. I don't see where basic_ostringstream's constructor takes a TCHAR pointer. And, if you meant char pointer, I still have to convert from ANSI to Unicode and would still need the #ifdef _UNICODE so that I can convert for NT but not for Win 9x. Could you clarify, please? Thanks.
|
|
|
|
|
It was a typo
Here is the complete code
TCHAR* TRadar::GetString(TCHAR *buff)
{
_tostringstream os;
os << radarTag.GetString() << " " << maxRange << " " << scanTime;
_tcscpy(buff, os.str().c_str());
return buff;
}
(It is not as efficient as strstream but strstream is not in the Standard C++ lib anymore.)
|
|
|
|
|
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.
|
|
|
|