|
|
CSocket* connect()
{
pClientSocket = new CSocket;
pClientSocket->Create();
bConnect = pClientSocket->Connect(
m_strServerIPAddress.c_str(),
m_iServerPort
);
}
if( ! bConnect )
{
CString strTmp;
strTmp.Format("Error: Failed to connect to server (%s).",m_strServerIPAddress.c_str());
AfxMessageBox(strTmp);
return FALSE;
}
return pClientSocket;
}
//then I did
CSocket m_pClientSocket;
m_pClientSocket=new CSocket;
m_pClientSocket = Connect();
//then I used the m_pClientSocket->Receive() func that worked
//now I created a secondary thread using beginthreadex()
//then I called the m_pClientSocket->Receive()func in the secondary thread func threadproc()in a while loop ..it seems that evrytime I call the Receive method it raises the Debug assertion failed exception ..if I ignore the error I continues to execute the receive func of CSocket but after quite some delay..
Is there ant way out of this problem...
Thanx and Regards
Junni
|
|
|
|
|
As Rage pointed, you should provide more complete information about your problem. Which assertion failed? This is important info. Some pseudo-code would be useful for helping you too.
A common error on multithreaded CSocket code is made with CSocketServer; from MSDN:
"
If you want to handle this connection in a different thread, just passing the MFC object to the thread will not work correctly. To correctly set up everything for the connection to be handled in a different thread, the following steps are required:
1. Detach the socket handle from the CAsyncSocket object in the thread where the connection was accepted.
2. Pass the socket handle to the thread.
3. In the thread, attach this handle to a CAsyncSocket derived object.
"
I see dumb people
|
|
|
|
|
I vaguely remember comming across this problem before. I just opted to use socket handle as I was under presure to get the project finished on time. I never had the chance to go back and figure it out. If you figure it out I'd be grateful if you posted the answer here.
Regards,
Brian Dela
|
|
|
|
|
|
yes it is a worker thread and can u provide some info about the Message Pump and how to implement that..a snippet of code would do a lot..
Thanx
junni
|
|
|
|
|
does the error have something to do with m_hash?
Rob
|
|
|
|
|
|
I am trying to write a program that writes pure hexadecimal text into a file.
For example I want to write in the figure 0x00010000 into the file. However I have tried using streams but when I look at the file the contents in a hex viewer the contents are 34 38 for a 0 whereas I would like there to be 00 01.
Does anybody know of a way to do it using std::streams?
|
|
|
|
|
If you are writing "text" into a file, then it wouldn't matter if it was hex or not ... everything will be characters. When looked at in a hex viewer, you will be seeing characters, regardless of what they represent.
If you want the resulting file to be viewed with a hex viewer and to look like hex bytes, then you will want to write the data to the file in binary.
Good luck,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Hi code gurus,
I'm trying to find out how to retrive the desktop background (a.k.a. desktop wallpaper) to use it in my applications (just the wallpaper without the desktop icons or any other things). Also, I want to change the wallpaper bitmp (in memory by retrieving the bitmap handle or a pointer to the bitmap). For example, I want to write a screen saver that utilizes the desktop background to apply some graphics effects on the background bitmap. Also I want to use it in other applications .. I want to change the bitmap itself e.g. draw a clock on the bitmap. I don't want to load the wallpaper bitmap file, I know how to do this but I want to get the wallpaper from memory, is this possible?
Thanks in advance ...
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
Take a look at IActiveDesktop interface.
Its got all the methods to deal with what you have mentioned like setting up the wallpaper, retrieving the bitmap etc.I'm not sure if you would be able to get a handle to the wallpaper bitmap from memory
Cheers
Kannan
|
|
|
|
|
Hi all,
is it possible to create a string table resource within a static linked library.
I use a static linked library and I want to use different string tables to translate error messages in different languages. With AfxMessageBox I create the dialog to display the error messages.
If this is not possible, has anybody another idea to do that?
Ciao,
f.o.b
|
|
|
|
|
Sorry, it's not. Resources are compiled by resource compiler and appended to a finished exe file. Static library is handled by C++ compiler/linker.
You can prepare a resource file to be included into rc file of the application using the library using #include statement (With a risk of resource ID conflict).
Pavel
Sonork 100.15206
|
|
|
|
|
Have alook at my article, it uses resource only DLLs not static libraries
http://www.codeproject.com/cpp/mult_lang_support.asp
|
|
|
|
|
I solved my problem.
If you want to know how to do it, check the following web side (unfortunatly in german):
http://www.differentpla.net/~roger/devel/tips/vc/resources_in_libs/
|
|
|
|
|
Ups, sorry,
the webside is in english )
Ciao,
f.o.b
|
|
|
|
|
I'd like to create an application (a DialogBased or SDI) that has the main window splitted into two parts.
The first part is a treeview and the second is a form that shows details of an item selected in the treeview.
There is one form for every different type of an item.
The problem I've come across is to how to make the second part of window dynamic? I mean how to visualize the detailed form and changing (replacing) it into another dynamically once the item in the tree view is changed?
Many thanks for any hint in advance.
misiek
|
|
|
|
|
I suppose you are using MFC.
I've solved it with a view which owns hidden modeless dialogs for each type of item. When an item in the tree is selected, the proper dialog is shown and filled.
Pavel
Sonork 100.15206
|
|
|
|
|
I beg your pardon
But let me describe your solution more closely.
Your application is based on Doc/View core.
You splitted the main window into two "subwindows"
One of the windows owns hidden modeless dialogs for each type of item.
Am I right?
Once more thx a lot.
misiek
|
|
|
|
|
I'm using a CSplitterWnd MFC class to implement multiple pane windows.
See this[^]
or MSDN for more info.
Some excerpts of the view with dialogs:
class CDlgView : public CView
{
...
CEmbeddedDlg* m_curdlg;
CEmbeddedDlg* m_emptydlg;
CTableDlg* m_tabledlg;
CProtocolDlg* m_protocoldlg;
CDataView* m_dataview;
...
void ShowDlg(IXMLDOMElementPtr node);
...
};
void CDlgView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
m_emptydlg->SetWindowPos(NULL,0,0,cx,cy, SWP_NOMOVE | SWP_NOZORDER);
m_tabledlg->SetWindowPos(NULL,0,0,cx,cy, SWP_NOMOVE | SWP_NOZORDER);
m_protocoldlg->SetWindowPos(NULL,0,0,cx,cy, SWP_NOMOVE | SWP_NOZORDER);
}
int CDlgView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_emptydlg = new CEmbeddedDlg();
m_emptydlg->Create(IDD_EMPTY,this);
m_curdlg = m_emptydlg;
m_emptydlg->ShowWindow(SW_SHOWNORMAL);
m_tabledlg = new CTableDlg();
m_tabledlg->Create(IDD_TABLE,this);
m_protocoldlg = new CProtocolDlg();
m_protocoldlg->Create(IDD_PROTOCOL,this);
return 0;
}
void CDlgView::ShowDlg(IXMLDOMElementPtr node)
{
m_curdlg->ShowWindow(SW_HIDE);
if(node==NULL) m_curdlg = m_emptydlg;
else
{
_bstr_t name = node->nodeName;
if(name == _bstr_t("table")) m_curdlg = m_tabledlg;
else if(name == _bstr_t("protocol")) m_curdlg = m_protocoldlg;
else m_curdlg = m_emptydlg;
}
m_curdlg->ShowWindow(SW_SHOWNORMAL);
m_curdlg->Fill(node);
}
Pavel
Sonork 100.15206
|
|
|
|
|
|
I want the non-MFC versions of CString and COleDateTime classes. These should be free and the exact replica of original MFC classes. Anyone having some information in this regard then please tell me.
|
|
|
|
|
CString is part of WTL template library, but I not sure about the licence - it's free for VC++ users.
Pavel
Sonork 100.15206
|
|
|
|
|
WTL has CString class that is non-MFC, or std::string can be used as a replacement. I've never come across a good COleDateTime replacement that wasn't MFC. Although it isn't hard to convert the code in the MFC src to something useable - depending which functionality you require.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|