|
All the accept error codes are listed here.
As you can see, whether you should skip this loop but keep the socket alive really depends on the severity of the error.
In your case, I think WSAENOBUFS was the error code corresponding to your CONNREFUSED error, which means the following possible causes:
1) Not enough memory
2) Can't create new file descriptors
3) Not enough other resources
Normally, that is pretty serious error and not easily recoverable.
Best,
Jun
|
|
|
|
|
Ok, after a double check, there is an error code WSAECONNREFUSED which I think is what you've got. But it's not the return by accept() from the server, but by connect() from the client. This usually results from trying to connect to a service that is inactive on the foreign host, that is, one with no server application running.
Best,
Jun
|
|
|
|
|
How do i change a Unicode project to MBCS using Visual Studio 2005?
What i've tried:
I opened the properties dialog for my project and clicked on "C/C++->preprocessor".
When i clicked on the "..." button at the right hand side of the "preprocessor definitions" box, there is a checkbox saying "Inherit from parent or project defaults" and a box that lists the inherited values: "_AFXDLL,UNICODE,_UNICODE".
I unchecked this box and added "_AFXDLL" and "_MBCS" to the original list of preprocessor definitions.
The list now looks like this: "WIN32;WINDOWS;_DEBUG;_AFXDLL;_MBCS;$(NOINHERIT)"
Now when i compile, this error comes up:
msvcrtd.lib(wcrtexew.obj) : error LNK2019: unresolved external symbol _wWinMain@16 referenced in function ___tmainCRTStartup
|
|
|
|
|
You just needed to modify your project properties. Go to Configuration Properties and look at Project Defaults. Change the Character Set from Unicode to MBCS. If it's a new project, the question you should ask is, it's 2006, why aren't you using unicode?
|
|
|
|
|
Thanks. To answer your question, the main problem i was having is this:
CString tempbuf;
tempbuf = "Job number,";
file.Write((LPCTSTR)tempbuf,tempbuf.GetLength());
file.Close;
When i open the file, it has 'J o b n u' in it.
I was told to change my project settings to MBCS to solve this problem. Is there any other way?
|
|
|
|
|
That depends on what you are doing and why you consider this a problem.
file.Write((LPCTSTR) tempbuf, tempbuf.GetLength() * sizeof(TCHAR));
You would then have a file with a UTF16LE string that says "Job number,". (edit: for unicode builds, and a normal ascii string for your mbcs build)
Have you considered...
CStringA tempbuf;
tempbuf = "Job number,";
file.Write((LPCSTR)tempbuf,tempbuf.GetLength());
file.Close; ?
-- modified at 6:40 Sunday 25th June, 2006
|
|
|
|
|
|
1 more question... For VS2005, whenever i'm working with a string say,
AfxMessageBox(_T("Something"));
I would have to put a '_T' before the string. Is there an easier way to work with strings without having to use '_T'?
|
|
|
|
|
_T is a macro that resolves to a unicode string on unicode builds (_UNICODE/UNICODE defined) and mbcs on mbcs builds. Eg. _T("Something") is L"Something" on unicode builds and "Something" on mbcs builds (You put L in front of a string to indicate a unicode string). It would be preferable to just get used to using the _T macro and all the TCHAR functions.
|
|
|
|
|
when I add a project to the current workspace, a warning message box pops up which showes "A project with the same name as the selected project already exists in the current workspace.". But actually my workspace doesn't have the project. somebody knows why? and how to figure out...
It is urgent! I am waiting online.
I will appreciate your answer.
kuoo
|
|
|
|
|
Oh,Maybe it is because the two project have the same name. but how to change the the project name in VC++ 6.0
kudoo
|
|
|
|
|
old_dustman wrote: how to change the the project name in VC++ 6.0
Two options:
1) Manually modify project files (.dsw, .dsp, .rc, etc)
2) Create a new project and copy over source files from the old project. Be sure to use the same project settings (easier to say than to do).
Best,
Jun
|
|
|
|
|
codes:
<br />
m_imagelist1.Create(16, 16, ILC_COLOR32, 1, 1);<br />
CBitmap *bmp=new CBitmap;<br />
CString str;<br />
for(int i=1; i<109; i++)<br />
{<br />
str.Format("qqface\\%d_m.bmp", i);<br />
bmp->m_hObject=(HBITMAP)LoadImage<br />
(NULL, str, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);<br />
<br />
m_imagelist1.Add(bmp, RGB(0, 0, 0));<br />
m_treeQunimage.Add(bmp, RGB(0, 0, 0));<br />
<br />
}<br />
delete bmp; <br />
m_List1.SetImageList(&m_imagelist2, LVSIL_SMALL);<br />
m_List1.DeleteAllItems();<br />
int nItem;<br />
m_List1.SetIconSpacing(50, 50);<br />
for(int i=1; i<109; i++)<br />
{<br />
nItem=m_List1.InsertItem(2*i,"hello", i);<br />
}<br />
now the list have a series of icons !
if I double click one icon, I want change this icon, what shall I do?will the following codes effective?
:
Wating for answers online, very urgent!
Just my interest for these common things
|
|
|
|
|
I think you need to check your code But see m_imagelist1.Replace(0,LoadIcon(AfxGetInstanceHandle(),(LPCTSTR)IDR_MAINFRAME)); maybe it is some helpful to you
whitesky
|
|
|
|
|
does it only change the imagelist
how to change the icon in CListCtrl?
or should insert into the item newly?
Just my interest for these common things
|
|
|
|
|
oh yes see SetItem and for other parameters for LVITEM see GetItem
whitesky
|
|
|
|
|
|
I insert the item this way , but how to get the item index?
or the other parameters for LVITEM, ex: item.iItem
:
for(int i=1; i<109; i++)<br />
{<br />
nItem=m_List1.InsertItem(2*i,"hello", i);<br />
}
it's double clicked !please tell me totallly!
thank you!
Just my interest for these common things
|
|
|
|
|
The parent window receives a NM_DBLCLK notification, and the message LPARAM points to an NMITEMACTIVATE that tells you which item was clicked, if any.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
Thank you very much!
I have done it following:
Item=new LVITEM;<br />
oldImage=faceNO[m_nCurrentSel/2]-1;<br />
Item->mask=LVIF_IMAGE ;<br />
Item->iItem=m_nCurrentSel ;<br />
nHop=0;<br />
<br />
SetTimer(2, 400, NULL);<br />
SetTimer(3, 300, NULL);<br />
if(nIDEvent==2)<br />
{<br />
if(nHop++>4)<br />
{<br />
KillTimer(2);<br />
KillTimer(3);<br />
return;<br />
}<br />
Item->iImage=-1;<br />
m_List1.SetItem(Item);<br />
m_List1.RedrawItems(Item->iItem, Item->iItem);<br />
}<br />
else if(nIDEvent==3)<br />
{<br />
Item->iImage=oldImage;<br />
m_List1.SetItem(Item);<br />
m_List1.RedrawItems(Item->iItem, Item->iItem);<br />
}
,but feel the effect is not comfortable!
My old idea is to make an icon visible and hidden by turns
it's so uncomfortable, I can see the icon twinkling!
How to prevent this happen?
Hope for some helps !
Just my interest for these common things
|
|
|
|
|
Can anyone show me how to update, delete, and add a record in a MS access database using CRecordset class without inheriting it.
thanks...
---------------------------Life is simple, you just complicate things-----------------------
|
|
|
|
|
For UPDATE, DELETE, and INSERT statements you don't need even CRecordset.
Can directly call CDatabase::ExecuteSQL, like for example:
class CFoo
{
CDatabase m_db;
};
void CFoo::SomewhereInSpace()
{
TRY
{
m_db.ExecuteSQL(_T("UPDATE Cats SET Name='Kitty' ")
_T("WHERE OwnerName='James'"));
}
CATCH(CDBException, e)
{
e->ReportError();
}
END_CATCH
}
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
... and if you want to use CRecordset (for SELECT statements, no way, you must do it), instantiate a CRecordset object (no need to derive) the call CRecordset::Open, and so on.
See example below
TRY
{
CRecordset rs(&m_db);
rs.Open(CRecordset::forwardOnly,
_T("SELECT Name, OwnerName FROM Cats"));
while(!rs.IsEOF())
{
const int nFieldsCount = rs.GetODBCFieldCount();
for(int nFieldIndex = 0; nFieldIndex < nFieldsCount; nFieldIndex++)
{
CDBVariant dbvarValue;
rs.GetFieldValue(nFieldIndex, dbvarValue);
}
rs.MoveNext();
}
rs.Close();
}
CATCH(CDBException, e)
{
e->ReportError();
}
AND_CATCH(CMemoryException, e)
{
e->ReportError();
}
END_CATCH
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
I need to add combobox into a listctrl as a subitem . how to do it?
|
|
|
|
|