|
thanks for answer my question
i change a little my code like this...
BOOL CMyThread::InitInstance()
{
while (!AfxSocketInit());
MySocket sock;
while (sock.Create(3005)==SOCKET_ERROR);
while (sock.Listen()==SOCKET_ERROR);
HANDLE file;
file=CreateFile(_T("C:\\initinstance.txt"),GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
CloseHandle(file);
Sleep(30000);
return TRUE;
}
socket listening for 30 sec with 6 thread
and after 30 sec thread is 5 and socket is close.
so...
and i understand my thread is closed after that..
here is my code for create thread...
CMyThread* pThread =
(CMyThread*)AfxBeginThread(
RUNTIME_CLASS(CMyThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
while(pThread==NULL)
{
Sleep(1);
pThread =
(CMyThread*)AfxBeginThread(
RUNTIME_CLASS(CMyThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
}
pThread->ResumeThread();
WaitForSingleObject(pThread->m_hThread,INFINITE);
what do you think? do i have mistake here?
and i'm no sure about calling "WaitForSingleObject(pThread->m_hThread,INFINITE);"
|
|
|
|
|
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
{
public:
void StartThread();
protected:
bool m_bKill;
CWinThread *m_pThread;
static UINT ThreadFunc(LPVOID pParam);
};
void CMyClass::StartThread()
{
m_pThread = AfxBeginThread(ThreadFunc, this, THREAD_PRIORITY_NORMAL,
0, CREATE_SUSPENDED);
m_pThread->ResumeThread();
}
UINT CMyClass::ThreadFunc(LPVOID pParam)
{
CMyClass* pThis = reinterpret_cast<CMyClass*>(pParam);
bool bKill = false;
while (!bKill)
{
if (pThis->m_bKill)
break;
}
return 0;
}
|
|
|
|
|
thanks a lot.
Solved 
modified 5-Apr-13 9:51am.
|
|
|
|
|
hi all,
on timer function I am step it a progress bar,
when I run the application the timer not working properly, means the progress bar not visible as step it
but when I debug the application its works,
I really don't understand what's happening here.
please help me for this.
|
|
|
|
|
Please ask your question specifically. No one understands your question.
Need more details !
or at least post some source code.
"If A is a success in life, then A=x+y+z. (Work is x; y is play; and z is keeping your mouth shut.)"
|
|
|
|
|
Could you please post the relevant code here?
Veni, vidi, vici.
|
|
|
|
|
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
|
|
|
|
|
DavidCrow wrote: 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?
yes
|
|
|
|
|
IF you dont pubish a short sample of your problem you are very unlikely to recieve an answer to your question.
|
|
|
|
|
if(m_modless == NULL)
{
m_modless = new CModeless(this);
this->EnableWindow(0);
if(!m_modless->Create(IDD_MODELESS, 0))
{
delete m_modless;
m_modless = NULL;
}
m_modless->m_prg2.SetRange32(0,100);
m_modless->m_prg2.SetStep(5);
SetTimer(1111, 50, NULL);
}
void CTestDlg::OnTimer(UINT_PTR nIDEvent)
{
if(nIDEvent==1111)
{
m_modless->m_prg2.StepIt();
}
CDialog::OnTimer(nIDEvent);
}
|
|
|
|
|
Hello all,
I have a dialog with a ListControl and some other buttons and edit boxes.
The ListControl has bunch of items in it. Now when the user clicks on one item in the ListControl, that particular item gets highlighted in blue color.
After the selection if user goes on to click on a edit box or buttons then the blue selection color disappears.
Is it possible to persist with the color even though user clicks on other controls in the same dialog?
How to do that?
Thanks in advance.
|
|
|
|
|
In the dialog resource editor, right-click the list control and select Properties. Set the "Always Show Selection" property to TRUE. That's it.
I don't know why the default is not TRUE for this property - I always end up setting it like that.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
That doesn't work.
I am looking for something by which the blue highlight will stay on the list item.
|
|
|
|
|
Donguy1976 wrote: I am looking for something by which the blue highlight will stay on the list item. Yes, that is what that property does for you. Actually, it should be shown as gray, not blue to indicate the does not have focus, but at least it shows the selection.
Do you by any chance override the list control styles during initialization? If so, you should include LVS_SHOWSELALWAYS.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
I want it to be BLUE and not GRAY.
Anyone know how to do that?
|
|
|
|
|
Things like that are normally done by overloading the list controls OnCustomdraw() . To do this, you use your own class derived from CListCtrl . If you want more information on that, check this (or you can Google):
http://msdn.microsoft.com/en-us/library/ms364048(v=vs.80).aspx[^]
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 );
*pResult = 0;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
if (IsWindowEnabled())
{
int nItem = (int)pLVCD->nmcd.dwItemSpec;
if (GetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED) != 0)
{
pLVCD->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);
pLVCD->clrTextBk = GetSysColor(COLOR_HIGHLIGHT);
*pResult = CDRF_DODEFAULT;
}
}
}
}
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Hello all,
I am working on a C++ application using MFC in VS 6.0
There's one dialog with 4 edit box controls and 1 check box, they are -
Name
Age
CheckBox
Height
Weight
Now when the dialog first open up only the Name & Age controls and CheckBox are shown to user.
Now if the user clicks on CheckBox then it should show the remaing 2 edit boxes, weight & height
So basically, if the CheckBox is checked then the dialog should resize automatically and show the remaining 2 edit controls.
Is it possible to do that with in 1 dialog itself?
If yes, how?
Please explain.
Thanks in advance.
|
|
|
|
|
|
See if this helps.
"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
|
|
|
|
|
Hi all,
I want to print image.
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.
please help me for this,
thanks.
|
|
|
|
|
|
can u please provide me any sample please if possible.
|
|
|
|
|
|
Hi all,
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"
="1.0"="UTF-8"="yes"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="MyCompany.MyDll" version="1.0.0.0"
processorArchitecture="x86" ></assemblyIdentity>
</assembly>
|
|
|
|
|
Hello,
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)
Thanks.
|
|
|
|