/[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 165 by twoaday, Tue Jan 24 10:10:15 2006 UTC
# 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 93  PTD_initialize (void) Line 104  PTD_initialize (void)
104      tray_proc_id = GetCurrentProcessId ();      tray_proc_id = GetCurrentProcessId ();
105      cbt_hook = SetWindowsHookEx (WH_CBT, PTD_CBT_proc, glob_hinst, 0);      cbt_hook = SetWindowsHookEx (WH_CBT, PTD_CBT_proc, glob_hinst, 0);
106      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);  
107          return FALSE;          return FALSE;
       }  
108            
   
109      /* Okay, what are we doing here:      /* Okay, what are we doing here:
110       * 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
111       * 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 237  PTD_keyb_send (UINT *keys, UINT n_keys) Line 239  PTD_keyb_send (UINT *keys, UINT n_keys)
239  }  }
240    
241    
 /* Return version of the PTD library. */  
 extern "C" const char *  
 PTD_get_version (void)  
 {  
     return PACKAGE_VERSION;  
 }  
   
   
242  /* Display a JPG picture in the given window at the given point. */  /* Display a JPG picture in the given window at the given point. */
243  extern "C" int  extern "C" int
244  PTD_jpg_show (HWND hwnd, POINT *p, LPCSTR name)  PTD_jpg_show (HWND hwnd, POINT *p, LPCSTR name)
245  {  {
246      CJPG jpg;      CJPG jpg;
247      HDC hdc;      HDC hdc;
248      POINT p2;      POINT sizewnd;
249        RECT rwnd;
250      BOOL rc;      BOOL rc;
251    
252      rc = jpg.load (name);      rc = jpg.load (name);
# Line 264  PTD_jpg_show (HWND hwnd, POINT *p, LPCST Line 259  PTD_jpg_show (HWND hwnd, POINT *p, LPCST
259          return -2; /* XXX: use real return code. */          return -2; /* XXX: use real return code. */
260      }      }
261    
262      p2.x = jpg.m_Width;      GetWindowRect (hwnd, &rwnd);
263      p2.y = jpg.m_Height;      sizewnd.x = rwnd.right - rwnd.left;
264      rc = jpg.show (hdc, p, &p2, 0, 0);      sizewnd.y = rwnd.bottom - rwnd.top;
265        rc = jpg.show (hdc, p, &sizewnd, 0, 0);
266    
267      ReleaseDC (hwnd, hdc);      ReleaseDC (hwnd, hdc);
268      jpg.freePictureData ();      jpg.freePictureData ();
269      return rc;      return rc;
270  }  }
271    
   
272                                    
273  BOOL WINAPI  extern "C" int WINAPI
274  DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserv)  DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserv)
275  {  {
276      switch (reason)  {      switch (reason)  {
277      case DLL_PROCESS_ATTACH:      case DLL_PROCESS_ATTACH:
278          glob_hinst = hinst;          glob_hinst = hinst;
279          break;          break;
280      case DLL_THREAD_ATTACH:        case DLL_THREAD_ATTACH:  
281          break;          break;
# Line 291  DllMain (HINSTANCE hinst, DWORD reason, Line 286  DllMain (HINSTANCE hinst, DWORD reason,
286      }      }
287      return TRUE;      return TRUE;
288  }  }
   

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26