textbox - MFC Edit control - WM_DROPFILES message register for drag and drop -


according this article, allow drop on target, have

use subclassdlgitem() re-route 1 message dialog object of handling can done there.

mr. danrollins (the author of article) provides example

class ceditdropnotif : public cedit {     virtual bool pretranslatemessage(msg* pmsg) {         if ( pmsg->message == wm_dropfiles ) {             getparent()->sendmessage(wm_dropfiles, pmsg->wparam, pmsg->lparam);             return true; // eat         }         return false; // allow default processing     } }; bool cmydlg::oninitdialog() {  ...     static ceditdropnotif ced;  // must persist (usually dlg member)     ced.subclassdlgitem( idc_edit1, );     ::dragacceptfiles( ced.m_hwnd, true );  // editbox, not dialog  ... 

but don't understand why edit control (cedit) has accept files in properties window (visual studio resource view), can't register message wm_dropfiles without having create inherited class (or can haven't known yet).

i see can register click message button following code

begin_message_map(csimpledlg, cdialogex) ... on_bn_clicked(idc_btn_01, &csimpledlg::onbnclickedbtn01) end_message_map() 

is there way can similar drag drop event, like

on_draw_drop(idc_txt_01, &csimpledlg::ondragdrop01)//is exist? 

the answer is: nope. on_bn_clicked macro maps member function handles bn_clicked notification sent via wm_command message. notifications sent control's parent (although mfc has "reflection" mechanism forwards notifications controls). wm_dropfiles general windows message, not notification that's it: if want handle have derive cedit.

see also:


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -