You are creating a user-interface thread. With socket operations worker threads are usual.
Also, why did you retry to create the thread if the first call fails? This makes no sense.
If the thread creation is done by your main thread, it will be blocked by calling WaitForSingleObject() until the thread terminates.
The skeleton for using a worker thread would look like this:
class CMyClass // optional : public CObject
static UINT ThreadFunc(LPVOID pParam);
m_pThread = AfxBeginThread(ThreadFunc, this, THREAD_PRIORITY_NORMAL,
// When m_pThread is deleted by this class (e.g. when using a StopThread() function)// m_pThread->m_bAutoDelete = FALSE;
UINT CMyClass::ThreadFunc(LPVOID pParam)
CMyClass* pThis = reinterpret_cast<CMyClass*>(pParam);
bool bKill = false;
// Call WaitForMultipleObjects() here to:// Check for kill event: Break// Check for I/O event: Handle event// Check for timeout: Break or handle it in some way// If not using a kill eventif (pThis->m_bKill)
So each time the timer fires, you are updating a progress bar, correct? Is that progress bar owned by the same thread that is running the timer? If so, it may be that the paint messages are not being processed. However, without seeing relevant code, I can't say for sure.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
Here is an OnCustomdraw() I copied from existing code and modified to do what you want it to do (hopefully). It is untested, so I don't actually know if it will work correctly (or even compile), but go ahead and try it out.
void CYourListCtrl::OnCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = 0;
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
*pResult = CDRF_NOTIFYITEMDRAW;
elseif ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
// This is the prepaint stage for an item. Here's where we set the
// item's text color. Our return value will tell Windows to draw the
// item itself, but it will use the new color we set here.
// Do not apply special behavior if the list control is disabled.
int nItem = (int)pLVCD->nmcd.dwItemSpec;
// Always draw the selected item with the highlight color.
if (GetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED) != 0)
// Store the color back in the NMLVCUSTOMDRAW struct.
pLVCD->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);
pLVCD->clrTextBk = GetSysColor(COLOR_HIGHLIGHT);
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
I have a paper size and the num of image to be print on page.
if one image print over the page its working fine
but how can I identify the size of new image to print on page if multiple num of image print over the page,
like: if 40*40 is image size its print on 40*40 paper finally if only one image print over 1 page, if 2 image print on the page the image size should be 20*20 each print perfectly on page and occupy the whole area of page.
and also tell me how to arrange the images in printing like left to right or top to bottom ,to occupy the whole paper area by providing num of images on page.
I want to know how to create manifest for my c++ private assemblies. What I have done now is keeping a static manifest file(as show below) and embed it into the dll. The down side of this approach is that I cannot update the version number in the manifest file. I want to update the version in the manifest file with the version of dll.
Please advice me if anyone knows some details on creating manifest for "private assembly"
I would want to write a small chat program allowing to communicate across the Net.
But I only found classic Winsock samples with 1 server/clients, where clients need an ip address to connect with the server.
Isn't it possible to have only clients (which would probably be also servers for others clients) ?
(if I just have 2 executables on 2 different PCs, I cannot know the ip of the other client exe)
Last Visit: 31-Dec-99 18:00 Last Update: 2-Oct-23 22:44