Build your own spy ++

Source: Internet
Author: User

Bool apientry maindlgproc (hwnd hdlg, // dialog box handle
Uint message, // Message Type
Wparam, // additional message
Lparam) // additional message
{
Point mousepoint;
Char STR [256];
Hwnd; // store the window handle
Switch (Message) // Message Processing
{
Case wm_initdialog: // dialog box initialization message
{
// Keep the window on the top floor
Setwindowpos (hdlg, hwnd_topmost, 0, 0, 0, swp_nosize | swp_nomove );
Settimer (hdlg, 1,100, null );
M_hwnd = hdlg;
Return (true );
}
Case wm_close:
{
Enddialog (hdlg, true );
Return (true );

}
Case wm_timer:
{
Getcursorpos (& mousepoint); // retrieves the mouse position
Hwnd = windowfrompoint (mousepoint); // obtain the window handle where the mouse pointer is located
Sendmessage (hwnd, wm_gettext, 255, (long) Str );
Setdlgitemtext (hdlg, idc_caption, STR );
// Obtain the window class name
Getclassname (hwnd, STR, 255 );
Setdlgitemtext (hdlg, idc_classname, STR );
// Obtain the window class value
Ltoa (getclasslong (hwnd, gcw_atom), STR, 10 );
Setdlgitemtext (hdlg, idc_classatom, STR );
// Obtain the window style
Ltoa (getwindowlong (hwnd, gwl_exstyle), STR, 2 );
Setdlgitemtext (hdlg, idc_extstyle, STR );
// Obtain the window ID
Ltoa (getwindowlong (hwnd, gwl_id), STR, 10 );
Setdlgitemtext (hdlg, idc_id, STR );
Return (true );
}
Case wm_destroy:
{

Killtimer (hdlg, 1 );
// Taskbardeleteicon (getsafehwnd (), 100, m_hicon, _ T ("Hi! "));
Return (true );
}
Case wm_command: // command button message
{
If (loword (wparam) = idc_quit)
Enddialog (hdlg, true );
Return (true );
}
}
Return (false );
}
Int winapi winmain (hinstance hinst,
Hinstance hinstprev,
Lpstr szcmdline,
Int ncmdshow)
{
Dialogbox (hinst, // application strength handle
Makeintresource (idd_maindlg), // resource ID of the dialog box
Null, // parent window handle of the dialog box
(Dlgproc) maindlgproc); // process function pointer in the dialog box
Return (0 );
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.