当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 在jsp开发中,把数据库链接封装在一个javabean中,数据库操作封装在别的javabean中,在这个bean中能不能调用数据库封装的javabean?具体该怎么做呢? ......
    摘要: we know that qq is very popular . some special effect of appearance will do much work , how to realize float on the screen. ......


关于全局钩子,请各位帮忙,谢谢了

我的全局钩子怎么不能PostMessage到我得出程序呢?  
  源代码如下:  
  //---------------------------------------------------------------------------  
   
  #include   <windows.h>  
  #include   <stdio.h>  
  #pragma   argsused  
  HHOOK   MyHook=NULL;  
  HWND   MyHwnd=NULL;  
  HINSTANCE   hInst=NULL;  
  long   Message=0;  
  const   LRESULT   CALLBACK   HookCallBack(int   nCode,WPARAM   wParam,LPARAM   lParam);  
  int   WINAPI   DllEntryPoint(HINSTANCE   hinst,   unsigned   long   reason,   void*   lpReserved)  
  {  
                  if   (hInst==NULL)   hInst=hinst;  
                  return   1;  
  }  
  //---------------------------------------------------------------------------  
  bool   __export   InstHook(HWND   Handle,long   Msg)  
  {  
                  if   (MyHook==NULL)  
                  {  
                                  MyHook=SetWindowsHookEx(WH_MOUSE,(HOOKPROC)HookCallBack,hInst,0);  
                                  MyHwnd=Handle;  
                                  Message=Msg;  
                  }  
                  else   return   false;  
                  return   true;  
  }  
  void   __export   DelHook()  
  {  
                  if   (MyHook==NULL)  
                  {  
                                  UnhookWindowsHookEx(MyHook);  
                                  MyHook=NULL;  
                  }  
  }  
  const   LRESULT   CALLBACK   HookCallBack(int   nCode,WPARAM   wParam,LPARAM   lParam)  
  {  
                  if   (nCode<0)   CallNextHookEx(MyHook,nCode,wParam,lParam);  
                  if   (nCode==HC_ACTION)  
                  {  
                                  SendMessage(MyHwnd,Message,wParam,lParam);//发送消息给主程序,只有鼠标在窗口上时窗口才收得到,??????  
   
                                  MOUSEHOOKSTRUCT   *l=(MOUSEHOOKSTRUCT   *)lParam;  
                                  HDC   h;  
                                  h=GetDC(0);  
                                  static   char   ch[20];  
                                  sprintf(ch,"Mouse:%d,%d           ",l->pt.x,l->pt.y);  
                                  TextOut(h,10,10,ch,strlen(ch));//可以输出到屏幕,说明全局钩子已经钩上  
                                //   MessageBox(NULL,"aaa","aaa",0);  
                                 
                  }  
                  return   CallNextHookEx(MyHook,   nCode,   wParam,   lParam);  
   
  }  
   
   
  我的E-mail:gqlyxg1981@sohu.com  
  先谢谢各位的帮忙

NO.1   作者: kataboy

SendMessage(hInst,Message,wParam,lParam);

NO.2   作者: mme

当然拉,你的窗口获得焦点时,MyHwnd才是有效的。  
  你在  
  int   WINAPI   DllEntryPoint(HINSTANCE   hinst,   unsigned   long   reason,   void*   lpReserved)  
  {  
                  if   (hInst==NULL)   hInst=hinst;  
                  return   1;  
  }  
  里面加入  
  int   WINAPI   DllEntryPoint(HINSTANCE   hinst,   unsigned   long   reason,   void*   lpReserved)  
  {  
                  MyHwnd=FindWind("你的窗口",NULL);//加入这句就可以了  
                  if   (hInst==NULL)   hInst=hinst;  
                  return   1;  
  }  
  其实也可以用共享变量MyHwnd来解决。


 ·为什么不能判断str字符为空    »显示摘要«
    摘要: string str = ""; if(str==null) //始终不能执行,换成if(str.length()<1)就可以! 这是为什么啊?我用的是tomcat4.0 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE