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 ); }
|