c++ - Change Control's Value by a Function in MFC? -


i set int variable idc_edit1 control. want change function, when clicking on button, show error!

void test() {     cthdlg d;     d.m_text1 = 5;     d.updatedata(false); }  void cthdlg::onbnclickedok() {     // todo: add control notification handler code here     // pthread = afxbeginthread(threadfunction, thread_priority_normal);     test(); } 

enter image description here

in test function define new instance of cthdlg class, , try modify it. not work it's not created, , have no relation actual dialog being displayed.

instead, if test stand-alone (not member) function should pass actual dialog instance argument, , use that.

for example

void tesy(cthdlg& dlg) {     dlg.m_text1 = ...;     dlg.updatedata(false); }  void cthdlg::onbnclickedok() {     test(*this); } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -