Can not update edit-control text from a callback function in mfc

Joined
Apr 2, 2009
Messages
2
Reaction score
0
Hi All,

I am trying to convert a console Softphone application(pjsua from PJSIP) into an MFC application(learning VC++ along the way).

My application is working with all the functionality. But I am not able to update the status for the registartion, call information etc. on the softphone’s main dialog itself(I can call MessageBox to display all these info, which is not convenient ant the correct way).

So, I change the static member function use for callback to non-static using a static wrapper function.

But whenever I try to update the content of edit-control in the main dialog, it gives error.

Following is the coding in my program

/*********** CPhoneDlg.h************/
#include <pjsua-lib/pjsua.h>
CPhoneDlg:: public CDialog
{
……………………………………
Public:
void on_reg(pjsua_acc_id acc_id);
static void wrapper_to_on_reg(pjsua_acc_id acc_id)
…………………..
CString m_info;
}

/************ CPhoneDlg.cpp ***********/
#include "CPhoneDlg.h"
void *pObj;
/************ Callback called by the library when registration status has changed ***********/
void CPhoneDlg:: on_reg_state(pjsua_acc_id acc_id)
{
---do some stuff----

/** Now update the registration status on CPhoneDlg’s main dialog, m_info is the edit-control’s value variable on CPhoneDlg’s
main dialog ******/
m_userinfo=L”User status updated”;
//When I call the Update data, it gives a break point
//calling UpdateData before DoModal()?
UpdateData(false);
}

void CPhoneDlg:: wrapper_to_on_reg(……………………)
{
CPhoneDlg* pPhone = (CPhoneDlg*)pObj;
pPhone->on_reg(acc_id);
}

BOOL CPhoneDlg:: OnInitDialog()
{
CPhoneDlg phoneDlg;
pObj =(void*)&phoneDlg;

…………………………………………
pjsua_config cfg; //pjsua_config is a struct
……………………………………

// implement and override the on_reg_state in pjsua_config
cfg.cb.on_reg_state = &CPhoneDlg:: wrapper_to_on_reg;
---------------------------
…………………………………………….
}

/*********** pjsua.h**********/
typedef struct pjsua_config
{
…………..
pjsua_callback cb;
…………….
}

typedef struct pjsua_callback
{
……………………………………………….
void (*on_reg_state)(pjsua_acc_id acc_id);
……………………………………………………

}

I am badly stuck in this, please help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top