/[winpt]/trunk/PTD/PTD.cpp
ViewVC logotype

Diff of /trunk/PTD/PTD.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 57 by werner, Wed Nov 2 11:29:44 2005 UTC revision 248 by twoaday, Fri Jul 28 11:11:09 2006 UTC
# Line 1  Line 1 
1  /* PTD.cpp - Privacy Tray Dynamic  /* PTD.cpp - Privacy Tray Dynamic
2   *      Copyright (C) 2002-2005 Timo Schulz   *      Copyright (C) 2002-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 23  Line 23 
23  #endif  #endif
24    
25  #include <windows.h>  #include <windows.h>
 #include <windows.h>  
26  #include <stdio.h>  #include <stdio.h>
27  #include <ocidl.h>  #include <ocidl.h>
28  #include <olectl.h>  #include <olectl.h>
# Line 32  Line 31 
31    
32  HINSTANCE glob_hinst;  HINSTANCE glob_hinst;
33    
34  /* We need a special section in the DLL for storing our shared data */  /* We need a special section in the DLL for storing our shared data.
35       This shared data is required by the hook function becuase theat
36       function is called in the context of the actual thread running the
37       hook and thus we need a way to communicate the result of our hook
38       function back to us.  We use a shared data segment for this. */
39    #ifdef __GNUC__
40    #define ATTR_SEC __attribute__((section (".SHARDAT"), shared))
41    #else
42    #define ATTR_SEC
43  #pragma data_seg(".SHARDAT")  #pragma data_seg(".SHARDAT")
44  static HHOOK    cbt_hook = NULL;    /* CTB hook handle. */  #endif
45  static DWORD    tray_proc_id = 0;   /* WinPT PID */  static HHOOK cbt_hook      ATTR_SEC = NULL; /* CTB hook handle. */
46  static HWND     shell_traywnd = 0;  /* Tray window handle. */  static DWORD tray_proc_id  ATTR_SEC = 0;    /* WinPT PID */
47  static HWND     curr_focus = NULL;  /* Current window focus handle. */  static HWND  shell_traywnd ATTR_SEC = 0;    /* Tray window handle. */
48  static HWND     rebar_w32 = NULL;  static HWND  curr_focus    ATTR_SEC = NULL; /* Current window focus handle. */
49  static HWND     mstask_swc = NULL;  static HWND  rebar_w32     ATTR_SEC = NULL;
50  static HWND     systab_c32 = NULL;  static HWND  mstask_swc    ATTR_SEC = NULL;
51    static HWND  systab_c32    ATTR_SEC = NULL;
52    #ifndef __GNUC__
53  #pragma data_seg()  #pragma data_seg()
54    #endif
55    #undef ATTR_SEC
56    
57  static unsigned *journ_keys = 0;  static unsigned *journ_keys = 0;
58  static unsigned key_idx = 0;  static unsigned key_idx = 0;
# Line 49  static unsigned nkeys = 0; Line 60  static unsigned nkeys = 0;
60  static HHOOK journ_hook = NULL;     /* Journaling hook  handle. */  static HHOOK journ_hook = NULL;     /* Journaling hook  handle. */
61    
62    
63    void dns_cleanup (void);
64    
65    
66  static LRESULT CALLBACK  static LRESULT CALLBACK
67  PTD_CBT_proc (int code, WPARAM wparam, LPARAM lparam)  PTD_CBT_proc (int code, WPARAM wparam, LPARAM lparam)
68  {  {
# Line 93  PTD_initialize (void) Line 107  PTD_initialize (void)
107      tray_proc_id = GetCurrentProcessId ();      tray_proc_id = GetCurrentProcessId ();
108      cbt_hook = SetWindowsHookEx (WH_CBT, PTD_CBT_proc, glob_hinst, 0);      cbt_hook = SetWindowsHookEx (WH_CBT, PTD_CBT_proc, glob_hinst, 0);
109      if (cbt_hook == NULL)      if (cbt_hook == NULL)
       {  
         char buf[500];  
                   
         FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),  
                    MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),  
                    buf, sizeof buf -1, NULL);  
         MessageBox (NULL, buf, "Error", MB_OK|MB_ICONSTOP);  
110          return FALSE;          return FALSE;
       }  
111            
   
112      /* Okay, what are we doing here:      /* Okay, what are we doing here:
113       * In the past I used the Spy++ application to find out why the old current       * In the past I used the Spy++ application to find out why the old current
114       * window doesn't work on so much systems. Now we try to use the computer       * window doesn't work on so much systems. Now we try to use the computer
# Line 141  PTD_delete (void) Line 146  PTD_delete (void)
146  {  {
147      if (!cbt_hook)      if (!cbt_hook)
148          return;          return;
149        dns_cleanup ();
150      UnhookWindowsHookEx (cbt_hook);      UnhookWindowsHookEx (cbt_hook);
151      cbt_hook = NULL;      cbt_hook = NULL;
152      shell_traywnd = NULL;      shell_traywnd = NULL;
# Line 188  PTD_playback_proc (int code, WPARAM wpar Line 194  PTD_playback_proc (int code, WPARAM wpar
194      }      }
195            
196      return CallNextHookEx (journ_hook, code, wparam, lparam);      return CallNextHookEx (journ_hook, code, wparam, lparam);
197  } /* PTD_Playback_proc */  }
198    
199    
200    
# Line 237  PTD_keyb_send (UINT *keys, UINT n_keys) Line 243  PTD_keyb_send (UINT *keys, UINT n_keys)
243  }  }
244    
245    
 /* Return version of the PTD library. */  
 extern "C" const char *  
 PTD_get_version (void)  
 {  
     return PACKAGE_VERSION;  
 }  
   
   
246  /* Display a JPG picture in the given window at the given point. */  /* Display a JPG picture in the given window at the given point. */
247  extern "C" int  extern "C" int
248  PTD_jpg_show (HWND hwnd, POINT *p, LPCSTR name)  PTD_jpg_show (HWND hwnd, POINT *p, LPCSTR name)
249  {  {
250      CJPG jpg;      CJPG jpg;
251      HDC hdc;      HDC hdc;
252      POINT p2;      POINT sizewnd;
253        RECT rwnd;
254      BOOL rc;      BOOL rc;
255    
256      rc = jpg.load (name);      rc = jpg.load (name);
# Line 264  PTD_jpg_show (HWND hwnd, POINT *p, LPCST Line 263  PTD_jpg_show (HWND hwnd, POINT *p, LPCST
263          return -2; /* XXX: use real return code. */          return -2; /* XXX: use real return code. */
264      }      }
265    
266      p2.x = jpg.m_Width;      GetWindowRect (hwnd, &rwnd);
267      p2.y = jpg.m_Height;      sizewnd.x = rwnd.right - rwnd.left;
268      rc = jpg.show (hdc, p, &p2, 0, 0);      sizewnd.y = rwnd.bottom - rwnd.top;
269        rc = jpg.show (hdc, p, &sizewnd, 0, 0);
270    
271      ReleaseDC (hwnd, hdc);      ReleaseDC (hwnd, hdc);
272      jpg.freePictureData ();      jpg.freePictureData ();
273      return rc;      return rc;
274  }  }
275    
   
276                                    
277  BOOL WINAPI  extern "C" BOOL WINAPI
278  DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserv)  DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserv)
279  {  {
280      switch (reason)  {      switch (reason)  {
281      case DLL_PROCESS_ATTACH:      case DLL_PROCESS_ATTACH:
282          glob_hinst = hinst;          glob_hinst = hinst;
283          break;          break;
284      case DLL_THREAD_ATTACH:        case DLL_THREAD_ATTACH:  
285          break;          break;
# Line 291  DllMain (HINSTANCE hinst, DWORD reason, Line 290  DllMain (HINSTANCE hinst, DWORD reason,
290      }      }
291      return TRUE;      return TRUE;
292  }  }
   

Legend:
Removed from v.57  
changed lines
  Added in v.248

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26