|
thanks for your valueable answer. can you give me a working code in this regard please ?
|
|
|
|
|
How would he do that?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I don't know why, but this guys is really starting to piss me off. I spent almost an hour writing my response to him a few threads down, assuming he was at least semi-capable as a C++ programmer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I don't know why, but this guys is really starting to piss me off.
Is there anything that doesn't, John? How people can get so riled over stuff like this is beyond me. If he bothers you so, why not just ignore him and move on?
John Simmons / outlaw programmer wrote: I spent almost an hour writing my response to him a few threads down, assuming...
That was your second mistake.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all:
Having a bit problem here. The function signature is as following:
<code>OccurrenceList& getOccurrences(string word);</code>
Seems to me, it reads the function "getOccurrences" will return a reference which refers to a variable of "OccurrenceList" type. Am I right?
Thank you
|
|
|
|
|
Yes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi:
If that is right, why am I always getting this error:"error C2143: syntax error : missing ';' before '&'".
The function definition is:
<code>OccurrenceList& WordTable::getOccurrences(string theWord) "<-The line of error".
{
return; //It returns nothing because I want to simplify the function first. I know it will generate another error.
}</code>
Can anyone help?
Thank you
|
|
|
|
|
Maybe OccurrenceList is not recognized as a type. Check it about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
C_Zealot wrote: error C2143: syntax error : missing ';' before '&
you probably forgot to #include the header in which the OccurrenceList class is defined...
C_Zealot wrote: return; //It returns nothing because I want to simplify the function first. I know it will generate another error
also, for this, i'd suggest you to prefer this, even if it's temporary and returns a reference to a local variable :
return OccurrenceList();
|
|
|
|
|
hi all
i hane made a dialog box in mfc and a button on it
i set browse on button
how can i browse a word document and attach it with it
please help me
bye
hi
|
|
|
|
|
Use CFileDialog() or SHBrowseForFolder API.
paras_s12 wrote: how can i browse a word document and attach it with it
To what do you want to attach the WORD doc to
"it" is just not self explanatory and what do you exactly mean by attaching it.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
paras_s12 wrote: ...browse a word document...
paras_s12 wrote: attach it with it
"It" being what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello
I have a strange problem in my code. I call this function to return me the current date and time. But, what I have observed is that once this piece of code gets exceuted in my workspace, all the CString variables in the workspace get initialized with the current date time by default (though they have been intialized with empty strings)
Is this because of the concept called buffer overrun. Is there anything like buffer overrun happening here where in the memory is getting corrupted because we are not specifying the size of the source / target buffers into which the strings have to be copied.
Please do clarify. Find the code snippet attached.
<br />
CString CLogger::GetCurrentDateTime()<br />
{<br />
CString strCurrDateTime,strTemp;<br />
<br />
SYSTEMTIME stCurrent,stLocal;<br />
GetSystemTime(&stCurrent); <br />
SystemTimeToTzSpecificLocalTime(NULL, &stCurrent, &stLocal);<br />
<br />
<br />
wsprintf(strCurrDateTime.GetBuffer(0),_T("%02d/%02d/%d %02d:%02d"),stLocal.wDay, stLocal.wMonth, stLocal.wYear,stLocal.wHour, stLocal.wMinute);<br />
<br />
return strCurrDateTime;<br />
}<br />
Regards,
Vipin.
|
|
|
|
|
Never use GetBuffer for doing things like that (and furthermore, you request a size of 0, so you will probably screw everything by write something much larger in the buffer). See the doc[^]
You should use the Format[^] function instead.
|
|
|
|
|
Hi,
I think you should consider taking COleDatetime for this. Because you could either use GetCurrentTime or construct a new COleDateTime from your SYSTEMTIME structure.
Afterwards you can use the Format method to assign it to your CString.
example:
CString CLogger::GetCurrentDateTime()
{
COleDateTime dtCurrent = COleDateTime::GetCurrentTime();
return dtCurrent.Format ( _T("%d/%m/%Y %H:%M") );
}
or
CString CLogger::GetCurrentDateTime()
{
SYSTEMTIME stCurrent,stLocal;
GetSystemTime(&stCurrent);
SystemTimeToTzSpecificLocalTime(NULL, &stCurrent, &stLocal);
COleDateTime time ( stLocal );
return time.Format ( _T("%d/%m/%Y %H:%M") );
}
|
|
|
|
|
The GetBuffer method of CString is misused in your code.
you're asking a zero-length buffer to CString and filling it with (a non-zero number of) characters.
You've to ask for a larger buffer (or, and will be better, don't use at all the GetBuffer method).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Just in case you were still wandering;), the reason you see the Date Time text in every uninitialised CString afterwards is that CString has a peculiar internal static member which represents the empty string. If you've overwritten this as it appears by overrunning the 0 length buffer returned from GetBuffer(0) then all CStrings which get auto initailised to this empty string will appear to contain the Date Time string.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I have used the CListCtrl example 'LVCustomDraw' to create a list control with colored columns. This works fine until I add an imagelist (BITMAP) to the list control.
My class is derived from the CListCtrl class, and I use two functions 'OnEraseBkgnd' and 'OnCustomDraw' to color the alternate columns.
The list control and imagelist are defined in the dialog class header
...
CListCtrlEx m_ctlList;
CImageList m_cImageListNormal, m_cImageListSmall, m_cImageListState;
...
and the bitmap is add in the dialog class
...
// Create 256 color image lists
HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 |ILC_MASK , 8, 1);
m_cImageListNormal.Attach(hList);
hList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 1);
m_cImageListSmall.Attach(hList);
// Load the large icons
CBitmap cBmp;
cBmp.LoadBitmap(IDB_IMAGES_NORMAL);
m_cImageListNormal.Add(&cBmp, RGB(255, 0, 255)); //m_colRow1
cBmp.DeleteObject();
// Load the small icons
cBmp.LoadBitmap(IDB_IMAGES_SMALL);
m_cImageListSmall.Add(&cBmp, RGB(255,0,255));
// Attach them
m_ctlList.SetImageList(&m_cImageListNormal, LVSIL_NORMAL);
m_ctlList.SetImageList(&m_cImageListSmall, LVSIL_SMALL);
...
The columns and items are then added.
I assume the default color of the list control is white, and the image is transparent, but when the background is redrawn, the image is not being 'refreshed', and hence it appears to have a white background.
I have noticed another example on CodeProject that has a similar result when the image is added.
Thank you
Steve
|
|
|
|
|
try calling the CImageList::SetBkColor() and then check whether the background has changed or not.
nave
|
|
|
|
|
I tried setting the background color in the OnInitDialog() function. No change ...
Next I tried
CImageList *img = (CImageList *) CListCtrlEx::GetDlgItem (IDB_IMAGES_SMALL);
ASSERT ( img != NULL );
but the return value of img is NULL.
|
|
|
|
|
Steve144 wrote: CImageList *img = (CImageList *) CListCtrlEx::GetDlgItem (IDB_IMAGES_SMALL);
What are you tryig to do?? To get the image list in a list control there is a function called GetImageList()...
nave
|
|
|
|
|
Oops - not a good bit of code ...
I have inserted the following code in the OnCustomDraw() function, and there is no change in B/G color of the listview image
CImageList *imgS = (CImageList *) CListCtrlEx::GetImageList ( LVSIL_SMALL );
ASSERT ( imgS != NULL );
CImageList *imgN = (CImageList *) CListCtrlEx::GetImageList ( LVSIL_NORMAL );
ASSERT ( imgN != NULL );
.....
case CDDS_SUBITEM | CDDS_PREPAINT | CDDS_ITEM:
{
imgS->SetBkColor ( RGB(225, 225, 225) );
imgN->SetBkColor ( RGB(225, 225, 225) );
|
|
|
|
|
Steve144 wrote: imgS->SetBkColor ( RGB(225, 225, 225) );
I think you want to change the white background of the image. But the above code will set the background of the image as white itself. Try using some other color say.
imgS->SetBkColor ( RGB(255,0,0) );// Red COlOR
nave
|
|
|
|
|
Nave,
The color is grey (225,225,225).
I have changed to red, but no change is B/G color of image
|
|
|
|
|
Is there any bluetooth hardware that has a keyboard and can control the computer remotely? And how can I program on the computer's side to get and interpret the signals from the bluetooth hardware as I need?
It's better if the computer can receive the original ditial voice data stream from the bluetooth hardware.
Thanks very much.
|
|
|
|