|
I've given this a 5, not 'cause of the original answer but because of the way code-o-mat followed the problem through to it's solution. Class act!
Cheers,
Ash
|
|
|
|
|
Thanks.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
The APIs are not related in anyway.
Just to be sure I tried to run the piece of code and it works perfectly.
So the only thing relating both the APIs in the code above is the name.
By giving the same name for both the mutex and the mapping, I'm able to reproduce the error with GetLastError returning the error code 6.
|
|
|
|
|
Maxwell Chen wrote: if(hMutex) {
shouldn't that be if(!hMutex) { ?
|
|
|
|
|
Luc Pattyn wrote: shouldn't that be if(!hMutex) { ?
Nope, my original code snippet as the below is correct.
HANDLE hMutex = CreateMutex(NULL, FALSE, MUTEX_NAME);
if(hMutex) {
if(ERROR_ALREADY_EXISTS == GetLastError()) {
return FALSE;
}
}
Maxwell Chen
|
|
|
|
|
My mistake. This is one of the exceptional cases where calling GetLastError makes sense even when the function succeeded.
|
|
|
|
|
Maxwell Chen
|
|
|
|
|
What happens after you return FALSE ?
Otherwise, I think you just leaked a system object handle.
Your program should technically close the mutex handle if you are not going to use it.
|
|
|
|
|
Current, I have a parent CWnd, which is displaying many other child CWnds. All my message handling job are being done in parent CWnd, as I do not have access to child CWnds' code.
I wish to know which child CWnds is being clicked.
I can detect the right click
afx_msg void OnContextMenu(
CWnd* pWnd,
CPoint pos
);
pWnd will be the clicked child window.
However, how about left click? I know I can get the mouse coordinate, and perform some calculation accordingly to iterate through see which child CWnds falll into the point. However, I just don't want to go through all this. I which I can have something like.
CWnd* childWind = mouseEvent.getParent();
|
|
|
|
|
for simple child controls, override parent CWnd's PreTranslateMessage().
BOOL CMyWnd::PreTranslateMessage(MSG* pMsg)
{
BOOL b = CDialog::PreTranslateMessage(pMsg);
if(pMsg->message == WM_LBUTTONDOWN)
{
if(pMsg->hwnd == m_edit.GetSafeHwnd())
MessageBox("Edit control);
}
return b;
}
if you need to get mouse click on edit field of combo box, or scroll bar of list box, i think you have to to subclass them.
|
|
|
|
|
Please try it :
BOOL CYourParentWnd::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
*pResult = 0;
NMHDR* pHeader = (NMHDR*) lParam;
switch (pHeader->code) {
case NM_CLICK:
{
CWnd* pcChild = CWnd::FromHandle(pHeader->hwndFrom);
}
break;
}
return FALSE;
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
are you sure that WM_NOTIFY will be sent to parent window by all controls on mouse click?
|
|
|
|
|
No, I am not sure for "all" controls...
...but I would test it in the author's context
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
|
If you can, please leave a contact。
I want to be a hacker, how should I do?
I do not want to engage in sabotage, just interested in the Trojan Programming.
|
|
|
|
|
???
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Mr_Leon wrote: I want to be a hacker
Well you will not be very popular here.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Have you studied this[^]? I think they managed rather well.
|
|
|
|
|
Mr_Leon wrote: If you can, please leave a contact。
I want to be a hacker, how should I do?
I do not want to engage in sabotage, just interested in the Trojan Programming.
For starters, not beg. Hackers do it on their own.
...byte till it megahertz...
|
|
|
|
|
Hide your process, and then search user's info such as bank account to your mail inbox.
|
|
|
|
|
I'm from China。
Email:7841559@qq.com
|
|
|
|
|
Hook 去看雪论坛 一堆堆搞Hook的
学英语 去新东方
|
|
|
|
|
ignor d dwn votes brohter
|
|
|
|
|
Hi,
I have read your article about "Rendering GIF, JPEG, Icon, or Bitmap Files with OleLoadPicture".It's very interesting. But I have some problems about it.If the Windows are maximized,the picture showed in the STATIC would be erased.
Could you provide the code?My email address is nalang@163.com.
Thanks.
|
|
|
|
|
[1]Make the picture storing object, might be instance of CBitmap, accessible all the time by making it as data member of class.
[2]Do the painting operation in ::OnDraw(SDI\MDI Application) or ::OnPaint(Dialog based Application)
Sameer();
|
|
|
|