普通的应用程序启动后都会在任务栏上显示一个长方形的窗体,如果在该窗体上点击右键即可看到
“还原、移动、大小、最小化、最大化、关闭”菜单,如果想把该菜单改为自己定义的菜单得怎么
实现呢?{
我用TMsg.message可以截获鼠标右键点击任务栏上的窗体的事件,但就是无法分辨出鼠标所点击的
窗体的句柄[用WindowFromPoint()得不到其句柄],如以没能够实现。
}望请得到您的指教,万分感激不尽!!

解决方案 »

  1.   

    在你弹出菜单前用GetCursorPos可以得到鼠标的位置
    “还原、移动、大小、最小化、最大化、关闭”这些你可以自己做一个菜单模拟
      

  2.   

    //添加系统菜单
    procedure Tfunc.AppendToSystemMenu(Form:TForm;Item:string;ItemID:word);
    var NormalSysMenu,MinimizedMenu:HMenu;
        AItem:Array[0..255] of Char;
        PItem:PChar;
    begin
      NormalSysMenu:=GetSystemMenu(Form.Handle,False);
      MinimizedMenu:=GetSystemMenu(Application.Handle,False);
      if Item='-' then
        begin
          AppendMenu(NormalSysMenu,MF_SEPARATOR,0,nil);
          AppendMenu(MinimizedMenu,MF_SEPARATOR,0,nil);
        end
      else
        begin
          PItem:=StrPCopy(@AItem,Item);
          AppendMenu(NormalSysMenu,MF_STRING,ItemID,PItem);
          AppendMenu(MinimizedMenu,MF_STRING,ItemID,PItem);
        end;
    end;
    *************************
    在主窗体中
    //系统菜单的消息响应,一般加在要使用的窗体里面
    procedure Tfunc.RegisterMsg(var Msg:TMsg;var Handled:Boolean);
    begin
      if Msg.message=WM_SYSCOMMAND then
        if Msg.wParam=99 then
          ShellExecute(Handle,'open',PChar('http://boyzxd.myrice.com'),nil,nil,SW_SHOW);
    end;
    在form.onshow里
    //添加系统菜单
      func.AppendToSystemMenu(main,'-',98);
      func.AppendToSystemMenu(main,'查看注册码(&R)',99);
      func.AppendToSystemMenu(main,'关于(&A)',100);
      Application.OnMessage:=RegisterMsg;有问题请留短消息^_^