本文整理汇总了C++中CWinApp::GetMainWnd方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::GetMainWnd方法的具体用法?C++ CWinApp::GetMainWnd怎么用?C++ CWinApp::GetMainWnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::GetMainWnd方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnBtnFileSendCancel
void CFileSendDlg::OnBtnFileSendCancel()
{
// TODO: Add your control notification handler code here
if(m_nFileSent == m_nTotalFileCnt)
{
/*
::EnterCriticalSection(& CFileTransSock::Instance().m_CS);
if( (DWORD)m_pSpckObjMap->m_pThreadObj != 0xfeeefeee &&
(DWORD)m_pSpckObjMap->m_pSockObj != 0xfeeefeee )
{
CFileTransSock::Instance().RemoveSocketObj(m_pSpckObjMap->m_pThreadObj, m_pSpckObjMap->m_pSockObj);
CFileTransSock::Instance().FreeSocketObj( m_pSpckObjMap->m_pSockObj);
CFileTransSock::Instance().RenumberThreadArray(m_pSpckObjMap->m_pThreadObj); //20080707
}
::LeaveCriticalSection(& CFileTransSock::Instance().m_CS);
*/
shutdown (m_pSpckObjMap->m_pSockObj->s ,SD_BOTH ) ;
//closesocket(m_pSpckObjMap->m_pSockObj->s);
CWinApp *pApp = AfxGetApp();
CWnd *pMainWnd = pApp->GetMainWnd();
pMainWnd->PostMessage(WM_FILE_SENDDLG_CLOSE, (WPARAM)m_szSockObjID, (LPARAM)0);
//CDialog::OnOK();
}
else
{
CFileTransSock::Instance().CancelSendFile(m_pSpckObjMap);
/*
::EnterCriticalSection(& CFileTransSock::Instance().m_CS);
if( (DWORD)m_pSpckObjMap->m_pThreadObj != 0xfeeefeee &&
(DWORD)m_pSpckObjMap->m_pSockObj != 0xfeeefeee )
{
CFileTransSock::Instance().RemoveSocketObj(m_pSpckObjMap->m_pThreadObj, m_pSpckObjMap->m_pSockObj);
CFileTransSock::Instance().FreeSocketObj( m_pSpckObjMap->m_pSockObj);
CFileTransSock::Instance().RenumberThreadArray(m_pSpckObjMap->m_pThreadObj);
}
::LeaveCriticalSection(& CFileTransSock::Instance().m_CS);
*/
shutdown (m_pSpckObjMap->m_pSockObj->s ,SD_BOTH ) ;
//closesocket(m_pSpckObjMap->m_pSockObj->s);
CWinApp *pApp = AfxGetApp();
CWnd *pMainWnd = pApp->GetMainWnd();
pMainWnd->PostMessage(WM_FILE_SENDDLG_CLOSE, (WPARAM)m_szSockObjID, (LPARAM)0);
//CDialog::OnOK();
}
}
示例2: OnNoThanksFileTransfer
LRESULT CFileSendDlg::OnNoThanksFileTransfer (WPARAM wParam, LPARAM lParam)
{
/*
::EnterCriticalSection(& CFileTransSock::Instance().m_CS);
if( (DWORD)m_pSpckObjMap->m_pThreadObj != 0xfeeefeee &&
(DWORD)m_pSpckObjMap->m_pSockObj != 0xfeeefeee )
{
CFileTransSock::Instance().RemoveSocketObj(m_pSpckObjMap->m_pThreadObj, m_pSpckObjMap->m_pSockObj);
CFileTransSock::Instance().FreeSocketObj( m_pSpckObjMap->m_pSockObj);
CFileTransSock::Instance().RenumberThreadArray(m_pSpckObjMap->m_pThreadObj); //20080707
}
::LeaveCriticalSection(& CFileTransSock::Instance().m_CS);
*/
shutdown (m_pSpckObjMap->m_pSockObj->s ,SD_BOTH ) ;
//closesocket(m_pSpckObjMap->m_pSockObj->s);
AfxMessageBox("상대방이 전송을 취소하였습니다.");
CWinApp *pApp = AfxGetApp();
CWnd *pMainWnd = pApp->GetMainWnd();
pMainWnd->PostMessage(WM_FILE_SENDDLG_CLOSE, (WPARAM)m_szSockObjID, (LPARAM)0);
//CDialog::OnOK();
return TRUE;
}
示例3: DoModal
int CDialog::DoModal()
{
return DialogBox(
app.GetInstanceHandle(), // application instance handle
"AboutBox", // actually IDD will be used
app.GetMainWnd()->GetSafeHwnd(),// parent window handle
DlgProc ); // dialog procedure
}
示例4: obj
CLog& CLog::Instance()
{
CWinApp *pApp = AfxGetApp();
CWnd *pMainWnd = pApp->GetMainWnd();
static CLog obj(pMainWnd->GetSafeHwnd());
return obj;
}
示例5: OnConnectionEstablished
void CMyClientEventHandler::OnConnectionEstablished(const CClientPtr& client)
{
AUTO_LOG_FUNCTION;
//std::lock_guard<std::mutex> lock(_mutex);
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_conn, 0);
}
}
}
示例6: OnConnectionLost
void CMyClientEventHandler::OnConnectionLost(const CClientPtr& client)
{
AUTO_LOG_FUNCTION;
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
if (client->m_conn_id != 0xFFFFFFFF) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_offline, 0);
}
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_disconn, 0);
}
}
}
示例7: SetupTabBar
void CGUIEditor::SetupTabBar()
{
CWinApp *app = AfxGetApp();
assert(app);
CWnd *mainWnd = app->GetMainWnd();
assert(mainWnd);
m_TabBar.Create(mainWnd, CGUITabBar::IDD, CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY, CGUITabBar::IDD);
TOOLBARSTRUCT atbs;
atbs.Text = _T("GUI");
atbs.cBar = &m_TabBar;
atbs.hIcon = (HICON)LoadImage(GUIEditorDLL.hModule,
MAKEINTRESOURCE(IDI_EDITORICO), IMAGE_ICON, 0, 0, 0);
static DWORD msgHash_AddToolBar = CHashString(_T("AddToolBar")).GetUniqueID();
EngineGetToolBox()->SendMessage(msgHash_AddToolBar, sizeof(TOOLBARSTRUCT), &atbs);
}
示例8: frustum_event_callback
//*****************************************************************************
// Function : frustumEventCallback
// -------------------------------
// Description : Receives the event callback when a HapticFrustum event occurs
// Return type : void
// Argument #1 : gstTransform *node
// Argument #2 : void *cbData
// Argument #3 : void *userData
//*****************************************************************************
void frustum_event_callback(gstTransform *node, void *cbData, void *userData)
{
gstEvent *event = (gstEvent *) cbData;
// if a pop through event occurs, leave this haptic context
if (event->id == HapticFrustum::POPPED_THROUGH) {
#ifdef WIN32
CWinApp *appPtr = (CWinApp *) AfxGetApp();
CFrameWnd *winPtr = (CFrameWnd *) appPtr->GetMainWnd();
CHapticView *hapticView = (CHapticView *) winPtr->GetActiveView();
#else // SGI or SUN
CHapticView *hapticView = (CHapticView *) ApplicationShell->GetActiveView();
#endif
// force the PHANToM to change into mouse mode
hapticView->OnPhantomLeave();
}
}
示例9: Store
void Options::Store(void)
{
CWinApp* pApp = AfxGetApp();
if (pApp == NULL) return;
RECT location;
pApp->GetMainWnd()->GetWindowRect(&location);
ini->SetValueI(L"Position", L"pos_x", location.left);
ini->SetValueI(L"Position", L"pos_y", location.top);
ini->SetValueI(L"Hotkey", L"mod_key", mod_key);
ini->SetValueI(L"Hotkey", L"vkey", vkey);
ini->SetValue(L"Skin", L"name", skinName.GetBuffer());
ini->SetValue(L"General", L"Directories", SerializeStringArray(Directories).GetBuffer());
ini->SetValue(L"General", L"Types", SerializeStringArray(Types).GetBuffer());
ini->WriteFile();
}
示例10: clear_ademco_event_list
void CAlarmMachine::clear_ademco_event_list()
{
if (!_alarming) return;
std::lock_guard<std::mutex> lock(_lock4AdemcoEventList);
_alarming = false;
_has_alarming_direct_zone = false;
_highestEventLevel = EVENT_LEVEL_STATUS;
_alarmingSubMachineCount = 0;
_ademcoEventList.clear();
if (_is_submachine) {
auto mgr = CAlarmMachineManager::get_instance();
CAlarmMachinePtr netMachine = mgr->GetMachine(_ademco_id);
if (netMachine) {
netMachine->dec_alarmingSubMachineCount();
}
}
if (!_is_submachine) {
CWinApp* app = AfxGetApp(); ASSERT(app);
auto wnd = static_cast<CAlarmMachineExDlg*>(app->GetMainWnd()); ASSERT(wnd);
wnd->MachineDisalarm(shared_from_this());
}
}
示例11: OnBnClickedOk
void Setting::OnBnClickedOk()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CWinApp *p = AfxGetApp();
CWnd *m_pWnd = p->GetMainWnd();
CESR_RadarDlg* pMainWnd = (CESR_RadarDlg*)m_pWnd;
CString strTemp;
m_real_max_width.GetWindowTextW(strTemp);
pMainWnd->real_max_width = _ttoi(strTemp);
m_real_min_height.GetWindowTextW(strTemp);
pMainWnd->real_min_height = _ttoi(strTemp);
m_road_width.GetWindowTextW(strTemp);
pMainWnd->road_width = _ttoi(strTemp);
m_road_count.GetWindowTextW(strTemp);
pMainWnd->road_count = _ttoi(strTemp);
pMainWnd->Auto_InitSetting = false;
CDialogEx::OnOK();
}
示例12: DealCmd
CMyClientEventHandler::DEAL_CMD_RET CMyClientEventHandler::DealCmd(const CClientPtr& client)
{
AUTO_LOG_FUNCTION;
DWORD conn_id = GetConnIdFromCharArray(client->m_packet2._cmd).ToInt();
JLOG(L"conn_id %d", conn_id);
switch (client->m_packet2._big_type)
{
case 0x01: // from Transmit server
{
switch (client->m_packet2._lit_type) {
case 0x00: // link test responce
{
JLOG(_T("Transmite server link test responce\n"));
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_rcv_lnk_tst, 0);
}
}
}
break;
case 0x01: // conn_id
client->m_conn_id = conn_id;
JLOG(_T("Transmite server responce my conn_id %d\n"), conn_id);
{
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_online, 0);
}
}
auto acct = client->acct_;
if (!acct.empty() && acct.length() <= 18) {
char buff[1024] = { 0 };
size_t len = client->m_packet1.Make(buff, sizeof(buff), AID_HB, 0, nullptr,
0, 0, 0, 0);
char_array cmd;
AppendConnIdToCharArray(cmd, ConnID(client->m_conn_id));
//AppendConnIdToCharArray(cmd, ConnID());
char acct_machine[9] = { 0 };
NumStr2HexCharArray_N(client->machine_acct_.c_str(), acct_machine, 9);
char acct_csr[9] = { 0 };
NumStr2HexCharArray_N(acct.c_str(), acct_csr, 9);
char pwd[4] = { 0 };
memset(pwd, 0xFF, 4);
len += client->m_packet2.Make(buff + len, sizeof(buff) - len, 0x04, 0x03, cmd,
acct_machine,
pwd,
acct_csr,
0);
client->PrepairToSend(-1, buff, len);
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_snd_machine_04_03, 0);
}
}
}
}
return DCR_ONLINE;
break;
default:
break;
}
} // end case 01
break;
case 0x05:
if (client->m_packet2._lit_type == 0x01) {
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_rcv_machine_05_01, 0);
}
}
}
break;
default:
break;
}
return DCR_NULL;
}
示例13: HandleAdemcoEvent
//.........这里部分代码省略.........
case ademco::EVENT_OFFLINE:
bOnofflineStatus = true; _rcccObj.reset();
bMachineStatus = true; online = false;
break;
case ademco::EVENT_ONLINE: bOnofflineStatus = true;
bMachineStatus = true;
break;
case ademco::EVENT_RETRIEVE_ZONE_OR_SUB_MACHINE:
HandleRetrieveResult(ademcoEvent);
return;
break;
case ademco::EVENT_QUERY_SUB_MACHINE:
return;
break;
case ademco::EVENT_DISARM: bMachineStatus = true; machine_status = MACHINE_DISARM;
break;
case ademco::EVENT_HALFARM: bMachineStatus = true; machine_status = MACHINE_HALFARM;
break;
case ademco::EVENT_ARM: bMachineStatus = true; machine_status = MACHINE_ARM;
break;
case ademco::EVENT_EMERGENCY:
default: bMachineStatus = false;
break;
}
#pragma endregion
if (bMachineStatus) { // status of machine
bool bStatusChanged = false;
#pragma region online or armed
if ((ademcoEvent->_zone == 0) && (ademcoEvent->_sub_zone == INDEX_ZONE)) {
_online = online;
if (!bOnofflineStatus && (_machine_status != machine_status)) {
bStatusChanged = true;
_machine_status = (machine_status);
}
}
#pragma endregion
#pragma region status event
if (ademcoEvent->_zone == 0) { // netmachine
// 2015-06-05 16:35:49 submachine on/off line status follow machine on/off line status
if (bOnofflineStatus && !_is_submachine) {
SetAllSubMachineOnOffLine(online);
}
} else { // submachine
if (subMachine) {
//subMachine->_online = online;
if (!bOnofflineStatus) {
if (!subMachine->get_online()) {
subMachine->set_online(true);
}
if (subMachine->get_machine_status() != machine_status)
bStatusChanged = true;
subMachine->_machine_status = machine_status;
subMachine->SetAdemcoEvent(ademcoEvent->_source,
ademcoEvent->_event,
ademcoEvent->_zone,
ademcoEvent->_sub_zone,
ademcoEvent->_timestamp,
ademcoEvent->_recv_time,
ademcoEvent->_xdata
);
}
}
}
#pragma endregion
} else { // alarm or exception event
#pragma region alarm event
_alarming = true;
EventLevel eventLevel = GetEventLevel(ademcoEvent->_event);
set_highestEventLevel(eventLevel);
// ui
// 1. main view btn flash
CWinApp* app = AfxGetApp(); ASSERT(app);
auto wnd = static_cast<CAlarmMachineExDlg*>(app->GetMainWnd()); ASSERT(wnd);
wnd->MachineAlarm(shared_from_this());
if (subMachine) {
if (!subMachine->get_alarming()) {
subMachine->set_alarming(true);
_alarmingSubMachineCount++;
}
subMachine->set_highestEventLevel(GetEventLevel(ademcoEvent->_event));
subMachine->HandleAdemcoEvent(ademcoEvent);
} else {
_has_alarming_direct_zone = true;
}
#pragma endregion
}
}
emit();
}
示例14: ThreadWorker
//.........这里部分代码省略.........
nRet = select(client->m_socket + 1, &fdRead, &fdWrite, nullptr, &tv);
if (WAIT_OBJECT_0 == WaitForSingleObject(manager->m_hEventShutdown, 0))
continue;
BOOL bRead = FD_ISSET(client->m_socket, &fdRead);
BOOL bWrite = FD_ISSET(client->m_socket, &fdWrite);
if (bRead) {
char* temp = client->m_buff.buff + client->m_buff.wpos;
DWORD dwLenToRead = BUFF_SIZE - client->m_buff.wpos;
nRet = recv(client->m_socket, temp, dwLenToRead, 0);
if (nRet <= 0) {
JLOG(_T("ThreadRecv::recv ret <= 0, ret %d"), nRet);
manager->m_handler->OnConnectionLost(client);
client->Disconnect();
continue;
} else if (manager->m_handler) {
client->m_buff.wpos += nRet;
DWORD ret = RESULT_OK;
ret = manager->m_handler->OnRecv(client);
while (1) {
unsigned int bytes_not_commited = client->m_buff.wpos - client->m_buff.rpos;
if (bytes_not_commited == 0) {
if (client->m_buff.wpos == BUFF_SIZE) {
client->m_buff.Clear();
}
break;
}
if (client->m_buff.wpos == BUFF_SIZE) {
memmove_s(client->m_buff.buff, BUFF_SIZE,
client->m_buff.buff + client->m_buff.rpos,
bytes_not_commited);
memset(client->m_buff.buff + bytes_not_commited,
0, BUFF_SIZE - bytes_not_commited);
client->m_buff.wpos -= client->m_buff.rpos;
client->m_buff.rpos = 0;
ret = manager->m_handler->OnRecv(client);
} else {
ret = manager->m_handler->OnRecv(client);
}
if (ret == RESULT_NOT_ENOUGH) {
break;
}
}
client->last_recv_time_ = COleDateTime::GetTickCount();
}
}
if (bWrite) {
// send link test
if (manager->m_handler
&& client->m_bConnectionEstablished
&& ((COleDateTime::GetTickCount() - client->last_send_link_test_time_).GetTotalSeconds() * 1000 >= LINK_TEST_GAP)) {
char buff[4096] = { 0 };
DWORD dwLen = client->GenerateLinkTestPackage(buff, sizeof(buff));
if (dwLen > 0 && dwLen <= sizeof(buff)) {
int nLen = client->Send(buff, dwLen);
if (nLen <= 0) {
JLOG(_T("ThreadLinkTest::Send ret <= 0, ret %d"), nLen);
client->Disconnect();
manager->m_handler->OnConnectionLost(client);
continue;
}
CWinApp* app = AfxGetApp();
if (app) {
CWnd* wnd = app->GetMainWnd();
if (wnd) {
wnd->PostMessageW(WM_NETWORKSTARTUPOK, mp_snd_lnk_tst, client->get_acct_id());
}
}
JLOG(_T("Send link test to transmite server, len %d\n"), nLen);
client->last_send_link_test_time_ = COleDateTime::GetTickCount();
}
}
// send data
if (!client->buffer_.empty() && client->buffer_lock_.try_lock()) {
std::lock_guard<std::mutex> lock(client->buffer_lock_, std::adopt_lock);
auto buffer = client->buffer_.front();
client->Send(&buffer[0], buffer.size());
client->buffer_.pop_front();
}
}
// check timeup
/*if (dwCount % 1000 == 0) {
dwCount = 0;
if ((COleDateTime::GetTickCount() - client->last_recv_time_).GetTotalSeconds() * 1000 > LINK_TEST_GAP * 3) {
manager->m_handler->OnConnectionLost(client);
client->Disconnect();
}
}*/
}
}
return 0;
}