⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spy.dpr

📁 VISUAL C++对话框源码通过此对话框源码你可以更好掌握对话框的编程
💻 DPR
字号:

program spy;
uses Windows, Messages, shlobj,SysUtils;
const
  ID_EXIT = 1000;
  ID_MOUSE=1009;
  ID_ABOUT=1001;
  ID_EDIT1=1002;
  ID_EDIT2=1003;
  ID_EDIT3=1004;
  ID_EDIT4=1005;
  ID_EDIT5=1006;
  ID_TOP=1007;
  ID_PIC=2323;

  ID_STATIC=65535;
  ID_CAR=102;

{$R Demo.Res}
var
 topmode:boolean;
  MainWin: HWND;
   myhwnd:integer;
   mypoint:tpoint;
   Text: array [0..255] of char;
   cText: array [0..255] of char;
   hFont:integer;
   spymode:boolean;
   irect:trect;

function MainDialogProc(
  DlgWin: hWnd;
  DlgMessage: UINT;
  DlgWParam: WPARAM;
  DlgLParam: LPARAM
  )
  : integer; stdcall;
var
  MyIcon: HICON;
  mystring:string;

begin
  mystring:='hello';
  Result := 0;
  //PtInRect
  case DlgMessage of


    WM_INITDIALOG:

      begin
      spymode:=false;
      topmode:=true;
hfont:=CreateFont(-12,0,0,0,0,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH or FF_DONTCARE,'宋体');
      MyIcon := LoadIcon(hInstance, 'MainIcon');
      SetClassLONG(DlgWin, GCL_HICON, MyIcon);

      MainWin := DlgWin;
      CheckDlgButton(MAINWIN,ID_TOP,0);
        SetWindowText(mainwin,'窗口类名查看器 V1.0');

        SetWINDOWPOS(MAINWIN,HWND_TOPMOST,0,0,0,0,swp_nomove or swp_nosize);
       ;
        //SendMessage(GETDLGITEM(MAINWIN,ID_CB),CB_ADDSTRING ,0,integer(mystring));
        //SendMessage(GETDLGITEM(MAINWIN,ID_CB),wm_settext ,0,integer(mystring));
        SendMessage(getdlgitem(mainwin,ID_ABOUT),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_EXIT),WM_SETFONT,hFont,0);
       // SendMessage(getdlgitem(mainwin,ID_CB),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_EDIT1),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_EDIT2),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_EDIT3),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_EDIT4),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_EDIT5),WM_SETFONT,hFont,0);
        SendMessage(getdlgitem(mainwin,ID_STATIC),WM_SETFONT,hFont,0);
        SendMessage(GETDLGITEM(MAINWIN,ID_TOP),BM_SETCHECK,BST_CHECKED,0);
      end;
    WM_Close:
      begin
      KillTimer(mainwin,1);
      PostQuitMessage(0);
       Exit;
      end;





      WM_LBUTTONDOWN:  //鼠标左键按下的消息
      begin

        getcursorpos(mypoint);
        getwindowrect(getdlgitem(mainwin,ID_PIC),IRECT);
        if PtInRect(IRECT,mypoint) then
        begin


       SetCapture( mainwin);
       spymode:=true;

       end;
      end;
      wm_mousemove:                  // 移动鼠标消息
      begin
       if spymode=true then
       begin
        getcursorpos(mypoint);
      setdlgitemtext(mainwin,ID_MOUSE,pchar('X:'+inttostr(mypoint.X )+' Y:'+inttostr(mypoint.Y )));
      myhwnd:=windowfrompoint(mypoint);
      GetWindowText(myhwnd, @Text, 255);
       GetClassName(myhwnd, @cText, 255) ;
      setdlgitemtext(mainwin,ID_EDIT1,pchar(StrPas(Text)));
      setdlgitemtext(mainwin,ID_EDIT2,pchar(StrPas(cText)));
       setdlgitemtext(mainwin,ID_EDIT5,pchar(inttostr(getwindowlong(myhwnd,gwl_id))));
         setdlgitemtext(mainwin,ID_EDIT4,pchar(inttostr(getwindowlong(myhwnd,gwl_exstyle))));
      setdlgitemtext(mainwin,ID_EDIT3,pchar(inttostr(myhwnd )));
       end;
       end;
      wm_lbuttonup:     //鼠标左键弹起的消息
      begin
       ReleaseCapture ;
       spymode:=false;

      end;

    WM_COMMAND:
      case LOWORD(DlgWParam) of




         ID_ABOUT:
         begin


           messageBox(DlgWin, '程序名:窗口类名查看器                       '+#13+'作者:xiaoter'+#13+'E_mail:mzrxh@21cn.com', '窗口类名查看器', MB_ICONQUESTION + MB_OK) ;

         end;


        ID_Exit:

          begin

              PostQuitMessage(0);
           Exit;

           end;
          ID_TOP:
             begin
             if topmode then
             begin
               SendMessage(GETDLGITEM(MAINWIN,ID_TOP),BM_SETCHECK,BST_UNCHECKED,0);
               SetWindowPos(MAINWIN,HWND_NOTOPMOST,0,0,0,0,swp_nomove or swp_nosize);

               end
               else
               begin
                SendMessage(GETDLGITEM(MAINWIN,ID_TOP),BM_SETCHECK,BST_CHECKED,0);
               SetWINDOWPOS(MAINWIN,HWND_TOPMOST,0,0,0,0,swp_nomove or swp_nosize);

               end;
                     topmode:=not topmode;
             end;
      end;
  end;
end;
begin
  DialogBox(hInstance, 'MAINFORM',0, @MainDialogProc);

  end.







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -