Hello
I have a problem with preference page and thread, which should "on_done" post a message to preference dialog.
Let's assume, that I have typical preference page with edit control and two buttons - one with PostMessage and SetDlgItemTextW in his function (and this proves, that message is processed - console will show "It's working!", edit control is changed) and second, which creating a thread with preferences dialog as parent window. In "on_done" are executed identical PostMessage and SetDlgItemTextW functions (with parent window as HWND parameter), but those messages are not processed by preferences window.
What I don't know, where I'm making an error?
class PreferencesMain: public CDialogImpl<PreferencesMain>, public preferences_page_instance
{
public:
enum {IDD = IDD_MAINPREFS};
BEGIN_MSG_MAP(PreferencesMain)
MSG_WM_INITDIALOG(OnInitDialog)
COMMAND_HANDLER(IDC_B_CATGETINFO, BN_CLICKED, GetCatalogInfo)
COMMAND_HANDLER(IDC_B_TESTPOST, BN_CLICKED, TestPostMessage)
MESSAGE_HANDLER_EX(WUM_SHOW,OnUserMessageShow)
END_MSG_MAP()
LRESULT GetCatalogInfo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
service_ptr_t<threaded_process_callback> catInfo = new service_impl_t<Catalog_info>();
//Catalog_info it's implemented threaded_process_callback
static_api_ptr_t<threaded_process>()->run_modeless( catInfo,
threaded_process::flag_show_abort,
this->m_hWnd,//Maybe there is error...?
"Checking...");
return 0;
}
LRESULT TestPostMessage(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
//when I press IDC_B_TESTPOST message is posted and processed, and IDC_EDIT1 is changed
::SetDlgItemTextW( this->m_hWnd, IDC_EDIT1, L"Local SetDlg");
::PostMessage(this->m_hWnd, WUM_SHOW, (WPARAM)0, (LPARAM)0);
return 0;
}
LRESULT OnUserMessageShow(UINT, WPARAM, LPARAM){
console::formatter()<<"It's working!";//but only with one button
return 0;
}
....
//Most important - in my problem - part of Catalog_info
void Catalog_info::on_done(HWND p_wnd,bool p_was_aborted) {//This not working
::SetDlgItemTextW(p_wnd, IDC_EDIT1, L"SetDlg from on_done");//on_done is in main thread, so this should be safe... Right?
::PostMessage(p_wnd ,WUM_SHOW,(WPARAM)0, (LPARAM)0);
}