|
That's a good idea but I want to emphasize that the motivation to determine the number of active threads via the semaphore handle is to simplify the code. The mechanism I'm currently using gets the job done. However, complexity is the enemy of good code. A solution based on a GetSemaphoreCount-like function would be not only simple and elegant but very understandable to anyone maintainig the code. For the time being it is likely that I will continue to use the method descrived in my original post.
Julberto
|
|
|
|
|
|
Thanks for the links to the article and books. I'll look into them.
By the way, it is important to me to know when all threads are done so the code can proceed to release resources. The background threads are somewhat short-lived since they just generate a synthetic HTML page and send it to the requesting client. The foreground thread waits until all background threads (if any) are done and then deletes the server object.
Julberto
|
|
|
|
|
I don't like polling, so I always use WaitForMultipleObjects()
I would have liked if they made it possible to have an event signaled every time the sempahore is in an unused state. You could simulate this by writing a small function with a critical section with the semaphore code inside and a counter.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If you want to use GetSemaphoreCount(), try Linux
In windows, such function could be
long GetSemaphoreCount(HANDLE hSem)
{
long tmp=0;
if (WAIT_TIMEOUT!=WaitForSingleObject(hSem,0)) ReleaseSemaphore(hSem,1,tmp);
return tmp;
}
Good luck
|
|
|
|
|
#define *** 0x000000AE
For hours now I have been trying to find out why my code was not working. It's that above message!! I've been playing with the icon on the titlebar and for some reason everything I did was painted over, even though I trapped just about every message I could think of. Through the aid of spy++ I found the culprit!
|
|
|
|
|
I believe it is undocumented. In WinUser.h the closest value is :
#define WM_NCXBUTTONDBLCLK 0x00AD
|
|
|
|
|
That was the first place I looked. A search on google has only revieled a few symbian references, nothing which would have an effect on what I am doing. It is sent prior to a WM_NCCALCSIZE message, with 0x04 in the wParam. I trapped it and returned 0, my app worked. Until I restarted VS when all of a sudden trapping it had no effect.
It doesn't matter, I wrote a function to bypass the whole routine. I now an animated icon on the title bar, and a static icon on the taskbar, switchable of course )
|
|
|
|
|
waldermort wrote: I now an animated icon on the title bar, and a static icon on the taskbar, switchable of course )
Great you got it all sorted out Is this going to give an article ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Rage wrote: Is this going to give an article ?
I doubt it, most of the code is hijacked and modified to suit my needs. I think writing an article about this will get me into trouble. All I wanted was to create a re-usable library which would enable me to show animated icons, and to minimize the window to the tray (animated not just hide).
This is the first time for me to subclass a window. In MFC probably very easy, but for plain old Win32 it takes a few lines of code.
|
|
|
|
|
How do I set the background color of an individual edit box? Say it is IDC_EDIT1 and I want a red background with normal black letters.
|
|
|
|
|
Create a brush and override WmCtlColor()..i think that's the one.
|
|
|
|
|
Oliver123 wrote: ...I want a red background with normal black letters.
Black letters on a red background are not very contrasting and thus may be hard to read.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
I look for any function that can get me date that OS Windows was installed on the PC. From command line I get this information by running systeminfo, but I need this from Visual C++.
Please help.
Thanks,
Nina
|
|
|
|
|
Can you shell execute this command within your code?
Best,
Jun
|
|
|
|
|
|
I think WMI will be your thing.
Take a look at 'Win32_OperatingSystem', there's an InstallDate property.
Don't think you are, know you are...
custom hardware & software - olloc.be
|
|
|
|
|
Good answer I thought about WMI, but did know Win32_OperatingSystem has a InstallDate property.
Best,
Jun
|
|
|
|
|
How to get Tree item selection change event in CTreeView derived class.
Thank you
KIRAN PINJARLA
|
|
|
|
|
check out TVN_SELCHANGED
Kuphryn
|
|
|
|
|
<br />
void CAnswerView::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult)<br />
{<br />
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);<br />
CTreeCtrl& ctlTree = (CTreeCtrl&) GetTreeCtrl();<br />
HTREEITEM m_ItemSel = ctlTree.GetSelectedItem();<br />
CString str=ctlTree.GetItemText(m_ItemSel );<br />
<br />
*pResult = 0;<br />
}<br />
|
|
|
|
|
I have an Edit control in my dialog box that takes a 10 digit number, now my requirement is after entering the number in the control, i will hit the return (enter) button in the keyboard for some validation to take place.
remember only with the pressing of the enter key in my keyboard, the validation should take place, i have tried handling the ON_EN_KILLFOCUS and ON_EN_CHANGE notification messages but in vain!!!
i have also tried enabling the Want Return style of the edit button but still i am not able to achieve the task, pls help??
thanx in advance
kumar_windows
|
|
|
|
|
You can try to put button near the edit control and make it a DEFAULT button. Then, after you insert the number and press Enter, the default button will be pressed. So you can validate the input.
Nina
|
|
|
|
|
Use PreTranslateMessage with VK_RETURN
|
|
|
|