|
I coded an application using hook events but when I trace events in debug mode, only the events sent by this application are catched!! The application doesn't catch others events from Windows!!
My hook functions are in a dll, I don't understand!!
|
|
|
|
|
Can u clarify more on this or how you r using SetWindowsHookEx()??
|
|
|
|
|
Of course!!
In my dll, i've coded the methods called by SetWindowsHookEx():
extern "C" LRESULT CALLBACK
SpyGetMsgProc(INT hCode, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
...
// Windows messages are taken here
return CallNextHookEx(NULL, hCode, wParam, lParam);
}
extern "C" LRESULT CALLBACK
SpyCallWndProc(INT hCode, WPARAM wParam, LPARAM lParam)
{
// like SpyGetMsgProc()
}
and in my program i coded a method SetSpyHook() which use SetWindowsHookEx():
BOOL SetSpyHook(BOOL bSet)
{
static HHOOK hhkGetMessage = NULL;
static HHOOK hhkCallWndProc = NULL;
static HMODULE hmodHook = NULL;
hmodHook = LoadLibrary("Hook");
...
hhkGetMessage = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)GetProcAddress(hmodHook, "SpyGetMsgProc"), hmodHook, 0);
...
hhkCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)GetProcAddress(hmodHook, "SpyCallWndProc"), hmodHook, 0);
...
}
My application works, but it catch only its messages!! I can't catch all messages from the others windows (like Spy++)!!
Thanks for your help...
|
|
|
|
|
I have seen the same problem while working on my current project (a Windows NT shell replacement). I assumed that the debugger was unable to display TRACE events that were not in the process space of the application it was currently debugging, but I do not know that for sure.
I ended up writing my own TRACE implementation that uses a memory map file to hold a table of debug strings. After writing the TRACE viewer application, I was able to determine that the hooks were indeed being hit by different applications (my custom TRACE macros automatically display the process and thread handles of the calling process and thread).
I think this is simply an issue with the capabilities of the debugger itself.
|
|
|
|
|
Hi!
Anyone want to help me out?
I implemented a tray icon in my program and everything is working great in the way I want it to be. However, there's a slight problem. The popup menu doesn't disappear right away if I click outside the popup menu. But it will disappear if I move the cursor back to the popup menu.
Any idea what is wrong with my code?
#define WM_NOTIFYICON WM_USER + 50
HWND g_hWnd;
HINSTANCE g_hInst;
HICON g_hIcon;
BOOL TrayMessage(HWND hWnd, DWORD dwMsg, UINT uId)
{
NOTIFYICONDATA nd;
nd.cbSize = sizeof(NOTIFYICONDATA);
nd.hWnd = hWnd;
nd.uID = uId;
nd.uFlags = NIF_MESSAGE | NIF_ICON;
nd.uCallbackMessage = WM_NOTIFYICON;
nd.hIcon = g_hIcon;
return Shell_NotifyIcon(dwMsg, &nd);
}
void NotifyAdd()
{
TrayMessage(g_hWnd, NIM_ADD, 777);
}
void NotifyDelete()
{
TrayMessage(g_hWnd, NIM_DELETE, 777);
}
void OnContextMenu()
{
HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1));
HMENU hPopup = GetSubMenu(hMenu, 0);
POINT pt;
GetCursorPos(&pt);
TrackPopupMenu(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_hWnd, NULL);
}
LRESULT OnNotifyIcon(LPARAM lParam)
{
switch (lParam)
{
case WM_RBUTTONUP:
OnContextMenu();
break;
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_CLOSE:
NotifyDelete();
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CONTEXTMENU:
OnContextMenu();
break;
case WM_NOTIFYICON:
return OnNotifyIcon(lParam);
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int n)
{
MSG msg;
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_DBLCLKS;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.hInstance = hInstance;
wc.lpszClassName = "popupwindowClass";
RegisterClass(&wc);
g_hInst = hInstance;
g_hWnd = CreateWindowEx(WS_EX_APPWINDOW, "popupwindowClass",
"popupmenu test", WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
0, 0, 320, 240, NULL, NULL, hInstance, NULL);
if (g_hWnd)
{
g_hIcon = LoadIcon(NULL, IDI_APPLICATION);
ShowWindow(g_hWnd, n);
UpdateWindow(g_hWnd);
NotifyAdd();
}
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
|
|
|
|
|
It's a feature!
Take a look at here.
Daniel
"das leid schlaft in der maschine" -Einstürzende Neubauten
|
|
|
|
|
Thank you. I haven't tried the article's suggestion, but I will see to it today.
|
|
|
|
|
How to delete a file that has a normal attribute but
has an "ACCESS DENIED" permission?
|
|
|
|
|
access denied usually means either you don't have the right security permissions, or the file maybe in use elsewhere, or it is a system file
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I have been looking, to no avail, for a way to add an item to the context menu of a printer - i have tried all the sample shell extensions that i could find source for, and can not get any of them to work with the printer object. I am pretty sure that I am setting the registry correctly, but seems like extenstion not working. Any help appreciated.
|
|
|
|
|
Be Warned:
With all things relating to the windows printing subsystem, make sure that the documentation that you are refering to notes if it is for NT or 9x.
There is a TON of cool stuff that you can do with the NT print spooler that you can't just do under Win9x.
|
|
|
|
|
I only need it for Win2K - even so, I have 95/98 code in there just in case someone decides to run it on those OS's. Any experience with shell extensions in ATL for non-filesystem objects ?
|
|
|
|
|
I am now on a huge proj for visual c++ and would really appreaciate some help...i have a workspace for all common programs and others for functional ones. i'm able to compile and build .exe file for the functinal source codes but when it comes to the common workspace, i receive the above msg...i have checked and sure that all the .lib and .h files are included so what seems to be the problem?
thanks in advance
|
|
|
|
|
are you saying that half the apps can log-on and half can't?
if so, check the log-on parameters and such ... otherwise your question is not very clearly stated so its difficult to understand the problems you are having
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Hi there,
1. Is there a possibility to get a pointer to my Main Frame from my CView derived ?
2. I have a split window with a CView derived Win in one side and a CFrameWnd on the other (which have his own CViews).
a. how can i find the parent Frame of the view?
b.how can i find the Main Frame of the view (the parent of the parent's frame)?
Thanks in Advanced,
Ariel.
|
|
|
|
|
1. CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd();
2/ a. GetParentFrame()
b. oh, a view inside a view ? The only MainFrame is the one you get above, but I doubt that is what you mean ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Thanks alot - actually you answerd 2.b. in your answer - so i have all i needed !!!
Thank you,
Ariel.
|
|
|
|
|
How could I hide scrollbar (not disable) in CScrollView?
|
|
|
|
|
change the window style specifying NOT WS_VSCROLL or NOT WS_HSCROLL
either do it in the CreateWindow() function or apply it afterwards in response to some event the user may generate
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Is there a way a CListCtrl in ReportView mode will select all the row when selecting one and not only the first iSubItem ???
Waht i mean is that when selecting rows in Report view mode only the first column of this row is selected. I want to be able to select all the row (all the SubItems) in the same click on the row.
Can this be done ?
Thanks in advance,
Ariel.
|
|
|
|
|
Yes, you can select the whole row.
DWORD dwStyle = pList->SendMessage( LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0 );
dwStyle = dwStyle | LVS_EX_FULLROWSELECT;
pList->SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle );
Daniel
"das leid schlaft in der maschine" -Einstürzende Neubauten
|
|
|
|
|
Hi there,
Thanks alot you saved me alot of time till i would have figured this out.
Thanks Again,
Ariel.
|
|
|
|
|
You can do it Daniel's way or,
// Set the listview style. Add features that you like.
List.SetExtendedStyle
(
m_fList.GetExtendedStyle()
| LVS_EX_FULLROWSELECT // Select all items when clicked
| LVS_EX_GRIDLINES // Draw gridlines. I like them.
| LVS_EX_TRACKSELECT // Hover if you wish etc.
);
Probably both the same. The secret is the Extended Style business. I'm just passing on what I was told on this site. And it works too.
|
|
|
|
|
Hi there,
First, Thanks alot for the answer it was really helpful and it have a nice view this way.
The only thing i don't understand whats the : "| LVS_EX_TRACKSELECT // Hover" ?
If you can tell me that too i'll be very thankfull,
Ariel.
|
|
|
|
|
Look up "Extended list view styles" in the Visual Studio help index. You can do a lot of interesting things in a list view control.
LVS_EX_TRACKSELECT
Version 4.70. Enables hot-track selection in a list view control. Hot track selection means that an item is automatically selected when the cursor remains over the item for a certain period of time. The delay can be changed from the default system setting with a LVM_SETHOVERTIME message. This style applies to all styles of list view control. You can check whether or not hot-track selection is enabled by calling SystemParametersInfo.
|
|
|
|