Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help needed! Please help

Help needed! Please help

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxhelp
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mustafa Demirhan
    wrote on last edited by
    #1

    Hi, :confused: One of my programs uses keyboard hook and shell hook. However, under win9x/ME it does not work as expected. What's the point: When Winscheduler is active and it is minimised on try bar... If you minimize another program (e.g. Word, Acad 14, Excel ...), the icon of minimised program disappear from task bar. If you use ALT+TAB you can steel switch between programs. Moreover, when you open a new window, it is not seen on the taskbar. Here is the source code for the dll file: // SystemHook.cpp : Defines the entry point for the DLL application. #include "stdafx.h" #include "SystemHook.h" #include #define ID_CMD_KEYPRESSED WM_USER+200 #define ID_CMD_WNDCREATED WM_USER+201 // Shared DATA #pragma data_seg("SHARDATA") static HWND hwndMain = NULL; // Main hwnd. We will get this from the App #pragma data_seg() // Globals for this module HWND ghWndMain; // Handle to main window -- used to post msgs HHOOK hHookKey; // A handle to our installed hook HHOOK hHookShell; // A handle to our installed hook static BOOL bHookInstalled; // TRUE if hook has been installed HINSTANCE ghDLLInst; // Handle to the DLL's instance. Set in DllMain. BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } ghDLLInst=(HINSTANCE)hModule; return TRUE; } // This is the constructor of a class that has been exported. // see SystemHook.h for the class definition CSystemHook::CSystemHook() { return; } // KeyboardHook() SYSTEMHOOK_API LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) { if (nCode >= 0) { if(nCode == HC_NOREMOVE) return CallNextHookEx(hHookKey, nCode, wParam, lParam); // Skip if the key was released or if it's a repeat if (!(lParam & 0x80000000 || lParam & 0x40000000)) { { static HWND h=::FindWindow(NULL,"WinScheduler"); PostMessage(h , ID_CMD_KEYPRESSED , wParam, lParam); } } } return CallNextHookEx(hHookKey, nCode, wParam, lParam); } SYSTEMHOOK_API LRESULT CALLBACK ShellProc(int nCode,WPARAM wParam,LPARAM lParam) { return CallNextHookEx(hHookShell, nCode, wParam, lParam); } //********************************************************************** // InstallHook() // Insta

    B 1 Reply Last reply
    0
    • M Mustafa Demirhan

      Hi, :confused: One of my programs uses keyboard hook and shell hook. However, under win9x/ME it does not work as expected. What's the point: When Winscheduler is active and it is minimised on try bar... If you minimize another program (e.g. Word, Acad 14, Excel ...), the icon of minimised program disappear from task bar. If you use ALT+TAB you can steel switch between programs. Moreover, when you open a new window, it is not seen on the taskbar. Here is the source code for the dll file: // SystemHook.cpp : Defines the entry point for the DLL application. #include "stdafx.h" #include "SystemHook.h" #include #define ID_CMD_KEYPRESSED WM_USER+200 #define ID_CMD_WNDCREATED WM_USER+201 // Shared DATA #pragma data_seg("SHARDATA") static HWND hwndMain = NULL; // Main hwnd. We will get this from the App #pragma data_seg() // Globals for this module HWND ghWndMain; // Handle to main window -- used to post msgs HHOOK hHookKey; // A handle to our installed hook HHOOK hHookShell; // A handle to our installed hook static BOOL bHookInstalled; // TRUE if hook has been installed HINSTANCE ghDLLInst; // Handle to the DLL's instance. Set in DllMain. BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } ghDLLInst=(HINSTANCE)hModule; return TRUE; } // This is the constructor of a class that has been exported. // see SystemHook.h for the class definition CSystemHook::CSystemHook() { return; } // KeyboardHook() SYSTEMHOOK_API LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) { if (nCode >= 0) { if(nCode == HC_NOREMOVE) return CallNextHookEx(hHookKey, nCode, wParam, lParam); // Skip if the key was released or if it's a repeat if (!(lParam & 0x80000000 || lParam & 0x40000000)) { { static HWND h=::FindWindow(NULL,"WinScheduler"); PostMessage(h , ID_CMD_KEYPRESSED , wParam, lParam); } } } return CallNextHookEx(hHookKey, nCode, wParam, lParam); } SYSTEMHOOK_API LRESULT CALLBACK ShellProc(int nCode,WPARAM wParam,LPARAM lParam) { return CallNextHookEx(hHookShell, nCode, wParam, lParam); } //********************************************************************** // InstallHook() // Insta

      B Offline
      B Offline
      BenDev
      wrote on last edited by
      #2

      I'm not sure I understand what your code is supposed to do but I can spot something wrong : hHookKey, hHookShell, bHookInstalled should be inside your SHARDATA section. They should be shared between processes. I think ghWndMain should be inside as well. (hwndMain doesn't seem to be used ?) #pragma data_seg("SHARDATA") HHOOK hHookKey = NULL; HHOOK hHookShell = NULL; BOOL bHookInstalled = FALSE; HWND ghWndMain = NULL; #pragma data_seg() ------------------------- Benoit Devigne http://www.bdevigne.com contact@bdevigne.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups