int LaunchSubProcess( const AString & args ) { // try to make a copy of our exe AStackString<> exeName; Env::GetExePath( exeName ); AStackString<> exeNameCopy( exeName ); exeNameCopy += ".copy"; Timer t; while ( FileIO::FileCopy( exeName.Get(), exeNameCopy.Get() ) == false ) { if ( t.GetElapsed() > 5.0f ) { AStackString<> msg; msg.Format( "Failed to make sub-process copy - error: %u (0x%x)\n\nSrc: %s\nDst: %s\n", Env::GetLastErr(), Env::GetLastErr(), exeName.Get(), exeNameCopy.Get() ); ShowMsgBox( msg.Get() ); return -2; } Thread::Sleep( 100 ); } AStackString<> argsCopy( args ); argsCopy += " -subprocess"; // allow subprocess to access the mutex g_OneProcessMutex.Unlock(); Process p; #if defined( __WINDOWS__ ) p.DisableHandleRedirection(); // TODO:MAC TODO:LINUX is this needed? #endif p.Spawn( exeNameCopy.Get(), argsCopy.Get(), nullptr, nullptr ); p.Detach(); return 0; }
// первоначальная инициализация bool ddMainWindow::initializing() { getMemoryFolderNames(); mobileCopyInfo = NULL; stopMobileCopy = false; auto_mounting(); // автоматическое монтирование slotFillTable(); // заполнение таблицы дисков showInfo = new TShowInfo(); mythread = new TMyThread(); mnt = new TMount(); QObject::connect(showInfo, SIGNAL(changeVal(int, const QString &)), SLOT(funcShowInfo(int, const QString &)), Qt::QueuedConnection); QObject::connect(showInfo, SIGNAL(sigShowMsgBox(QString)), SLOT(ShowMsgBox(QString)), Qt::QueuedConnection); QObject::connect(mythread, SIGNAL(sigShowMsgBox2(const QString &)), SLOT(ShowMsgBox2(const QString &)), Qt::QueuedConnection); QObject::connect(mythread, SIGNAL(sigChangeButton()), SLOT(ChangeButton()), Qt::QueuedConnection); QObject::connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), SLOT(showDiskInCombobox(int, int))); connect (&timer, SIGNAL (timeout()), &loop, SLOT(quit())); prevCol = -1; prevRow = -1; return true; }
void RtsForm::OnBtnClose() { if (!closing_) { MsgboxCallback mb = nbase::Bind(&RtsForm::OnQuitMsgBox, this, std::placeholders::_1); ShowMsgBox(m_hWnd, L"退出后,你将不再接收白板演示的消息内容", mb, L"退出白板提示", L"确定", L"取消"); } else { OnQuitMsgBox(MB_YES); } }
void CExternalUILobby::ServerDisconnected() { // 05. 10. 27 - 김주현 // __SRVDISCONNECTRELOGIN(서버디스컨넥트가 되었을 경우에 로그인창으로 이동할것인가 // 아니면... 프로그램을 강종할것인가.. #ifdef __SRVDISCONNECTRELOGIN CTCommand* pCmd = new CTCmdReLogin; // 이건 재로그인 #else CTCommand* pCmd = new CTCmdExit; // 이건 강종 #endif ShowMsgBox( "Server Disconnected", CTMsgBox::BT_OK , true , EUI_MAX , pCmd ); }
// 图片无效或者DUILIB图片引擎Read图片失败 void HeadModifyForm::OnNotifyImageInvalid() { // 提示图片无效,不是图片或者图片为超过200*200 auto multilan = MutiLanSupport::GetInstance(); std::wstring content = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_IMAGE_VALID"); std::wstring title = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_BUTTON_LOCAL_UPLOAD"); std::wstring yes = multilan->GetStringViaID(L"STRING_OK"); MsgboxCallback cb = nbase::Bind(&HeadModifyForm::OnButtonCloseTipCallback, this, std::placeholders::_1); cb = ToWeakCallback(cb); ShowMsgBox(m_hWnd, content, MsgboxCallback(), title, yes, L""); select_image_btn_->SetEnabled(true); }
void HeadModifyForm::OnNotifyHeadModifyFailed() { auto multilan = MutiLanSupport::GetInstance(); std::wstring content = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_SAVE_FAILED"); std::wstring title = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_TITLE"); std::wstring yes = multilan->GetStringViaID(L"STRING_OK"); MsgboxCallback cb = nbase::Bind(&HeadModifyForm::OnButtonCloseTipCallback, this, std::placeholders::_1); cb = ToWeakCallback(cb); ShowMsgBox(m_hWnd, content, cb, title, yes, L""); //删除缓存头像 StdClosure closure = nbase::Bind(&HeadModifyForm::DeleteFileCallback, new_temp_head_image_path_); nbase::ThreadManager::PostTask(kThreadGlobalMisc, closure); }
LRESULT SessionForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CloseReason closeReason = (CloseReason)wParam; // 如果是因为所有会话盒子都关闭了导致窗口关闭,则正常返回 if (kSessionBoxClose == closeReason) { return __super::OnClose(uMsg, wParam, lParam, bHandled); } // 如果是其他原因触发了WM_CLOSE else { int session_count = merge_list_->GetCount(); if (session_count > 0 && NULL != active_session_box_) { // 如果只有一个会话盒子,就直接关闭 if (1 == session_count) { CloseSessionBox(active_session_box_->GetSessionId()); } // 如果包含多个会话盒子,就询问用户 else { MsgboxCallback cb = ToWeakCallback([this](MsgBoxRet ret) { if (ret == MB_YES) { while (merge_list_->GetCount() > 0) { Control *merge_item = merge_list_->GetItemAt(0); ASSERT(NULL != merge_item); if (NULL == merge_item) break; CloseSessionBox(merge_item->GetUTF8Name()); } } }); ShowMsgBox(this->GetHWND(), L"当前窗口包含多个会话,确定要关闭窗口吗?", cb); } bHandled = TRUE; return 0; } } return __super::OnClose(uMsg, wParam, lParam, bHandled); }
void MsgRecordForm::OnPlayAudioCallback( const std::string &cid, int code ) { IdBubblePair::iterator it = id_bubble_pair_.find(cid); if(it != id_bubble_pair_.end()) { MsgBubbleAudio* item = dynamic_cast<MsgBubbleAudio*>(it->second); if(item) { item->OnPlayCallback(code); } } if (code != nim::kNIMResSuccess) { std::wstring tip = nbase::StringPrintf(L"语音播放失败,错误码:%d", code); ShowMsgBox(m_hWnd, tip, MsgboxCallback(), L"提示", L"确定", L""); } }
bool MemberManagerForm::OnBtnConfirmClick(ui::EventArgs* param) { if (((Option*)FindControl(L"owner"))->IsSelected()) { nim::Team::TransferTeamAsync(tid_, user_id_, false, nbase::Bind(&TeamCallback::OnTeamEventCallback, std::placeholders::_1)); } else if (((Option*)FindControl(L"manager"))->IsSelected() && user_type_ != nim::kNIMTeamUserTypeManager) { std::list<std::string> uids_list; uids_list.push_back(user_id_); nim::Team::AddManagersAsync(tid_, uids_list, nbase::Bind(&TeamCallback::OnTeamEventCallback, std::placeholders::_1)); } else if (((Option*)FindControl(L"member"))->IsSelected() && user_type_ != nim::kNIMTeamUserTypeNomal) { std::list<std::string> uids_list; uids_list.push_back(user_id_); nim::Team::RemoveManagersAsync(tid_, uids_list, nbase::Bind(&TeamCallback::OnTeamEventCallback, std::placeholders::_1)); } std::string new_team_card = nbase::StringTrim(re_team_card_->GetUTF8Text()); if (!team_card_.empty() && new_team_card.empty()) { MsgboxCallback cb = ToWeakCallback([this](MsgBoxRet ret) { this->ActiveWindow(); }); ShowMsgBox(m_hWnd, L"群昵称不能为空", ToWeakCallback(cb), L"提示", L"确定", L""); return true; } if (new_team_card != team_card_) { nim::TeamMemberProperty values(tid_, user_id_); values.SetNick(new_team_card); if (user_id_ != LoginManager::GetInstance()->GetAccount()) nim::Team::UpdateOtherNickAsync(values, nbase::Bind(&OnTeamEventCallback, user_id_, new_team_card, std::placeholders::_1)); else nim::Team::UpdateMyPropertyAsync(values, nbase::Bind(&OnTeamEventCallback, user_id_, new_team_card, std::placeholders::_1)); } Close(); return true; }
// 退出修改 void HeadModifyForm::OnButtonClose(bool forced_close /*= false*/) { if(forced_close) { // 强制退出 this->Close(); } else { // 是否已经设置退出标记 if(is_quit_) return; if(is_misc_thread_rendering_) { // 设置退出标记,在渲染回调DUI时再弹出提示 is_quit_ = true; } else { // 判断是否需要弹出提示 if(head_view_ctrl_->CheckHasLoadImage()) { // 退出提示:是否放弃修改? auto multilan = MutiLanSupport::GetInstance(); std::wstring content = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_CLOSE_TIP"); std::wstring title = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_TITLE"); std::wstring yes = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_GIVEUP_MODIFY"); std::wstring no = multilan->GetStringViaID(L"STRID_HEAD_MODIFY_CONTINUE_MODIFY"); MsgboxCallback cb = nbase::Bind(&HeadModifyForm::OnButtonCloseTipCallback, this, std::placeholders::_1); cb = ToWeakCallback(cb); ShowMsgBox(m_hWnd, content, cb, title, yes, no); } else { this->Close(); } } } }
void CExternalUILobby::ShowWaitMsgBox() { ShowMsgBox("Waiting...", 0, true, EUI_MAX ); }
// MainCommon //------------------------------------------------------------------------------ int MainCommon( const AString & args, void * hInstance ) { // don't buffer output VERIFY( setvbuf(stdout, nullptr, _IONBF, 0) == 0 ); VERIFY( setvbuf(stderr, nullptr, _IONBF, 0) == 0 ); // process cmd line args FBuildWorkerOptions options; if ( options.ProcessCommandLine( args ) == false ) { return -3; } // only allow 1 worker per system Timer t; while ( g_OneProcessMutex.TryLock() == false ) { // retry for upto 2 seconds, to allow some time for old worker to close if ( t.GetElapsed() > 5.0f ) { ShowMsgBox( "An FBuildWorker is already running!" ); return -1; } Thread::Sleep(100); } #if defined( __WINDOWS__ ) if ( options.m_UseSubprocess && !options.m_IsSubprocess ) { return LaunchSubProcess( args ); } #endif // prevent popups when launching tools with missing dlls #if defined( __WINDOWS__ ) ::SetErrorMode( SEM_FAILCRITICALERRORS ); #else // TODO:MAC SetErrorMode equivalent // TODO:LINUX SetErrorMode equivalent #endif #if defined( __WINDOWS__ ) VERIFY( SetPriorityClass( GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS ) ); #else // TODO:MAC SetPriorityClass equivalent // TODO:LINUX SetPriorityClass equivalent #endif // start the worker and wait for it to be closed int ret; { Worker worker( hInstance, args ); if ( options.m_OverrideCPUAllocation ) { WorkerSettings::Get().SetNumCPUsToUse( options.m_CPUAllocation ); } if ( options.m_OverrideWorkMode ) { WorkerSettings::Get().SetMode( options.m_WorkMode ); } ret = worker.Work(); } MEMTRACKER_DUMP_ALLOCATIONS return ret; }
int showhelp( const char *topic, EVENT (*rtn)( EVENT ), HelpLangType lang ) { bool first; int err; char filename[_MAX_PATH]; const char *hfiles[] = { NULL, NULL }; char ext[_MAX_EXT]; char *buffer; char *helptopic; if( HelpFiles[0].name == NULL ) { return( HELP_NO_FILE ); } switch( lang ) { case HELPLANG_FRENCH: hotSpots[0].str = "F4=Sujet pr�c�dent"; hotSpots[1].str = "Sortir"; break; case HELPLANG_ENGLISH: break; } helpStack = NULL; currentColour = C_PLAIN; currentAttr = AT( ATTR_NORMAL ); /* initialize the tab filter */ tabFilter.tab = (unsigned (*)(void *,void *))help_in_tab; tabFilter.next = (a_tab_field *(*)(void *,void *))help_next_field; tabFilter.parm = helpTab; tabFilter.mousepos = (void *(*)(void *,ORD *, ORD *))uivmousepos; tabFilter.mouseparm = &helpScreen; tabFilter.first = helpTab; tabFilter.wrap = false; tabFilter.enter = false; _splitpath( HelpFiles[0].name, NULL, NULL, filename, ext ); strcat( filename, ext ); hfiles[0] = filename; if( topic != NULL ) { size_t len = strlen( topic ) + 1; helptopic = HelpMemAlloc( len ); memcpy( helptopic, topic, len ); } else { helptopic = NULL; } err = HELP_OK; first = true; while( helptopic != NULL || first ) { if( first || help_reinit( hfiles ) ) { err = do_showhelp( &helptopic, filename, rtn, first ); if( err == HELP_NO_SUBJECT ) { break; } } else { // cannot open help file for hyperlink buffer = HelpMemAlloc( 28 + strlen( filename ) ); sprintf( buffer, "Unable to open helpfile \"%s\".", filename ); ShowMsgBox( "Error", buffer ); HelpMemFree( buffer ); HelpMemFree( helptopic ); helptopic = HelpMemAlloc( strlen( helpStack->word ) + 1 ); strcpy( helptopic, helpStack->word ); strcpy( filename, helpStack->helpfname ); prevtopic(); } first = false; } if( helptopic != NULL ) HelpMemFree( helptopic ); return( err ); }