本文整理汇总了C++中AfxGetThreadState函数的典型用法代码示例。如果您正苦于以下问题:C++ AfxGetThreadState函数的具体用法?C++ AfxGetThreadState怎么用?C++ AfxGetThreadState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AfxGetThreadState函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lstrcpyn
//--------------------------------------------------------------------------------------------------------------//
BOOL CFrmMain::PreCreateWindow(CREATESTRUCT& cs)
{
if (FALSE == CFrameWnd::PreCreateWindow(cs)) return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
lstrcpyn(AfxGetThreadState()->m_szTempClassName, c_szSingleInstanceId,
sizeof(AfxGetThreadState()->m_szTempClassName) / sizeof(TCHAR));
cs.lpszClass = AfxGetThreadState()->m_szTempClassName;
WNDCLASS wndcls = {0};
HINSTANCE hInst = NULL;
hInst = AfxGetInstanceHandle();
if (FALSE == ::GetClassInfo(hInst, cs.lpszClass, &wndcls))
{
wndcls.style = 0;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = NULL;
wndcls.hbrBackground = NULL;
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = cs.lpszClass;
if (!AfxRegisterClass(&wndcls)) AfxThrowResourceException();
}
else
{
ASSERT(wndcls.style == 0);
return TRUE;
}
return TRUE;
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:36,代码来源:FrmMain.cpp
示例2: while
//延时函数,测试环境是一个对话框程序
//如果超时中止,返回真,否则假。
bool zstringEx::z_wait_message_until_true(bool *Global_x_false,long ms)
{
//注意,本函数可能让程序无法退出,所以结束程序时,要先结束本函数
//在启动本等待函数时,第一个参数为假,当它为真时,等待就结束了
//ms=0,则上一个等待是永远,否则就是等待的毫秒值,值一到就不再等了,哪怕第一个参数还是假
bool *is_loop_user_stop=Global_x_false;
long m_start=clock();long m_end;
long kms=ms;bool timeout_flag=false;
_AFX_THREAD_STATE *pState; //定义指针
while(true) //这是一个死循环
{
pState= AfxGetThreadState(); //得到线程状态参数的指针
if(pState==NULL)break;
if(::PeekMessage(&(pState->m_msgCur),NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&(pState->m_msgCur)); //执行线程消息,如使按钮能响应
::DispatchMessage(&(pState->m_msgCur));
}
if(is_loop_user_stop!=NULL){if(*is_loop_user_stop==true)break;} //判断 用户是否要求停止,如果要,就断了死循环
if(kms!=0){m_end=clock();if(m_end-m_start>=kms){timeout_flag=true;break;}} //判断是否超时
Sleep(1); //减少CPU的占用,这个参数是消息响应速度,越大响应效果越差,越小CPU占用越大
}
return timeout_flag;
}
开发者ID:Leoyuseu,项目名称:CodeHub,代码行数:30,代码来源:zstringEx.cpp
示例3: AfxOleTerm
void AFXAPI AfxOleTerm(BOOL bJustRevoke)
{
// release clipboard ownership
COleDataSource::FlushClipboard();
// revoke all class factories
COleObjectFactory::RevokeAll();
#ifndef _AFX_NO_OCC_SUPPORT
AfxOleUnlockAllControls();
#endif
if (!bJustRevoke)
{
CWinThread* pThread = AfxGetThread();
if (pThread != NULL)
{
// destroy message filter (may be derived class)
delete pThread->m_pMessageFilter;
pThread->m_pMessageFilter = NULL;
}
// terminate OLE last
_AFX_THREAD_STATE* pState = AfxGetThreadState();
// -1 is special case, so need to compare against TRUE
if (pState->m_bNeedTerm == TRUE)
{
CoFreeUnusedLibraries();
::OleUninitialize();
pState->m_bNeedTerm = FALSE;
}
}
}
开发者ID:Rupan,项目名称:winscp,代码行数:33,代码来源:oleinit.cpp
示例4: GetActiveWindow
BOOL COFSNcDlg::OnNcActivate(BOOL bActive)
{
/// Обработка OnNcActivate и Запоминания состояния для перерисовки
if (m_nFlags & WF_STAYACTIVE) bActive = TRUE;
if (!IsWindowEnabled()) bActive = FALSE;
if (bActive==m_bActive)
return TRUE;
CWnd* pActiveWnd = GetActiveWindow();
if (pActiveWnd&&pActiveWnd!=this) {
pActiveWnd->SendMessage(WM_NCACTIVATE,bActive);
pActiveWnd->SendMessage(WM_NCPAINT);
}
// Turn WS_VISIBLE off before calling DefWindowProc,
// so DefWindowProc won't paint and thereby cause flicker.
//
DWORD dwStyle = GetStyle();
if (dwStyle & WS_VISIBLE)
::SetWindowLong(*this, GWL_STYLE, (dwStyle & ~ WS_VISIBLE));
MSG& msg = AfxGetThreadState()->m_lastSentMsg;
msg.wParam = bActive;
Default();
if (dwStyle & WS_VISIBLE) ::SetWindowLong(*this, GWL_STYLE, dwStyle);
// At this point, nothing has happened (since WS_VISIBLE was off).
// Now it's time to paint.
//
m_bActive = bActive; // update state
SendMessage(WM_NCPAINT); // paint non-client area (frame too)
return TRUE; // done OK
}
开发者ID:0anion0,项目名称:IBN,代码行数:34,代码来源:OFSNcDlg.cpp
示例5: AfxGetThreadState
int CWinThread::RunLoop() {
bool bIdle = true;
LONG lIdleCount = 0;
_AFX_THREAD_STATE* pState = AfxGetThreadState();
while (true)
{
#if UCFG_GUI
while (bIdle && !::PeekMessage(&(pState->m_msgCur), 0, 0, 0, PM_NOREMOVE))
bIdle = OnIdle(lIdleCount++);
#endif
do
{
//#ifndef NO_GUI //!!!
if (!PumpMessage())
return ExitInstance();
//#endif
if (IsIdleMessage(pState->m_msgCur))
{
bIdle = true;
lIdleCount = 0;
}
}
while (::PeekMessage(&(pState->m_msgCur), NULL, NULL, NULL, PM_NOREMOVE));
}
}
开发者ID:sirmax1,项目名称:coin,代码行数:26,代码来源:win-thread.cpp
示例6: ASSERT
void COXImageListBox::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
DWORD dwStyle=GetStyle();
// make sure LBS_OWNERDRAWFIXED and LBS_MULTICOLUMN styles are specified
ASSERT(dwStyle&LBS_OWNERDRAWFIXED);
ASSERT(dwStyle&LBS_MULTICOLUMN);
// make sure LBS_OWNERDRAWVARIABLE and LBS_MULTIPLESEL styles are not specified
ASSERT(!(dwStyle&(LBS_OWNERDRAWVARIABLE|LBS_MULTIPLESEL)));
// make sure the control is empty
ASSERT(GetCount()==0);
_AFX_THREAD_STATE* pThreadState=AfxGetThreadState();
// hook not already in progress
if(pThreadState->m_pWndInit==NULL)
{
if(!InitializeImageListBox())
{
TRACE(_T("COXImageListBox::PreSubclassWindow: failed to initialize the control\n"));
}
}
CListBox::PreSubclassWindow();
}
开发者ID:Spritutu,项目名称:AiPI-1,代码行数:26,代码来源:OXImageListBox.cpp
示例7: ASSERT_VALID
void COXHistoryCombo::PreSubclassWindow()
{
ASSERT_VALID(this);
// ... Attached window must be valid
ASSERT(m_hWnd != NULL);
ASSERT(::IsWindow(m_hWnd));
_AFX_THREAD_STATE* pThreadState=AfxGetThreadState();
// hook not already in progress
if(pThreadState->m_pWndInit==NULL)
{
if(GetParent() != NULL)
{
// Initialize this control
InitCombo();
}
}
// If GetParent() == NULL, this control is being created through Create()
// and it is still to ealy to initialize, this will be done in OnCreate
CComboBox::PreSubclassWindow();
ASSERT_VALID(this);
}
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:26,代码来源:OXHistoryCombo.cpp
示例8: ProcessGUIMessages
virtual void ProcessGUIMessages()
{
// Adapted from MFC's CWinThread::Run() (thrdcore.cpp).
_AFX_THREAD_STATE* pState = AfxGetThreadState();
CWinApp* pApp = AfxGetApp();
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(&pState->m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// call OnIdle while in bIdle state
if (!pApp->OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
}
// phase2: pump messages while available
while (::PeekMessage(&pState->m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// pump message, but quit on WM_QUIT
if (!pApp->PumpMessage())
{
Terminate();
pApp->ExitInstance();
}
}
::Sleep(0);
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:28,代码来源:WINMAIN.CPP
示例9: AfxGetThreadState
int PASCAL CSocket::ProcessAuxQueue()
{
AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
if (pThreadState->m_listSocketNotifications.IsEmpty())
return 0;
int nCount = 0;
while(!pThreadState->m_listSocketNotifications.IsEmpty())
{
nCount++;
MSG* pMsg = (MSG*)pThreadState->m_listSocketNotifications.RemoveHead();
ASSERT(pMsg != NULL);
if (pMsg->message == WM_SOCKET_NOTIFY)
{
CAsyncSocket::DoCallBack(pMsg->wParam, pMsg->lParam);
}
else
{
ASSERT(CAsyncSocket::LookupHandle((SOCKET)pMsg->wParam, TRUE) != NULL);
CAsyncSocket::DetachHandle((SOCKET)pMsg->wParam, TRUE);
}
delete pMsg;
}
return nCount;
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:27,代码来源:sockcore.cpp
示例10: ASSERT_VALID
//////////////////
// DoModal override copied mostly from MFC, with modification to use
// m_ofnEx instead of m_ofn.
//
int CFileDialogEx::DoModal()
{
ASSERT_VALID(this);
ASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
ASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook
// zero out the file buffer for consistent parsing later
ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile));
DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1;
ASSERT(nOffset <= m_ofn.nMaxFile);
memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR));
// WINBUG: This is a special case for the file open/save dialog,
// which sometimes pumps while it is coming up but before it has
// disabled the main window.
HWND hWndFocus = ::GetFocus();
BOOL bEnableParent = FALSE;
m_ofn.hwndOwner = PreModal();
AfxUnhookWindowCreate();
if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
{
bEnableParent = TRUE;
::EnableWindow(m_ofn.hwndOwner, FALSE);
}
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
ASSERT(pThreadState->m_pAlternateWndInit == NULL);
if (m_ofn.Flags & OFN_EXPLORER)
pThreadState->m_pAlternateWndInit = this;
else
AfxHookWindowCreate(this);
memset(&m_ofnEx, 0, sizeof(m_ofnEx));
memcpy(&m_ofnEx, &m_ofn, sizeof(m_ofn));
if (IsWin2000())
m_ofnEx.lStructSize = sizeof(m_ofnEx);
int nResult;
if (m_bOpenFileDialog)
nResult = ::GetOpenFileName((OPENFILENAME*)&m_ofnEx);
else
nResult = ::GetSaveFileName((OPENFILENAME*)&m_ofnEx);
memcpy(&m_ofn, &m_ofnEx, sizeof(m_ofn));
m_ofn.lStructSize = sizeof(m_ofn);
if (nResult)
ASSERT(pThreadState->m_pAlternateWndInit == NULL);
pThreadState->m_pAlternateWndInit = NULL;
// WINBUG: Second part of special case for file open/save dialog.
if (bEnableParent)
::EnableWindow(m_ofnEx.hwndOwner, TRUE);
if (::IsWindow(hWndFocus))
::SetFocus(hWndFocus);
PostModal();
return nResult ? nResult : IDCANCEL;
}
开发者ID:janker007,项目名称:cocoshun,代码行数:64,代码来源:FileDialogEx.cpp
示例11: ASSERT
void PASCAL CAsyncSocket::DetachHandle(SOCKET hSocket, BOOL bDead)
{
ASSERT(CAsyncSocket::LookupHandle(hSocket, bDead) != NULL);
AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
if (!bDead)
{
pThreadState->m_mapSocketHandle.RemoveKey((void*)hSocket);
if (pThreadState->m_mapSocketHandle.IsEmpty())
{
ASSERT(pThreadState->m_hSocketWindow != NULL);
CWnd* pWnd =
CWnd::FromHandlePermanent(pThreadState->m_hSocketWindow);
ASSERT_VALID(pWnd);
pWnd->DestroyWindow();
delete pWnd;
pThreadState->m_hSocketWindow = NULL;
pThreadState->m_mapDeadSockets.RemoveAll();
}
}
else
{
pThreadState->m_mapDeadSockets.RemoveKey((void*)hSocket);
}
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:28,代码来源:sockcore.cpp
示例12: dc
void CMDITabs::OnPaint()
{
CPaintDC dc(this);
if (GetItemCount() == 0) return; // do nothing
int dcState = dc.SaveDC();
// windows should draw the control as usual
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
pThreadState->m_lastSentMsg.wParam = WPARAM(HDC(dc));
Default();
dc.RestoreDC(dcState);
DWORD face = ::GetSysColor(COLOR_3DFACE);
if (m_bTop)
{
CRect rect(0, m_height - 7, m_width, m_height);
dc.FillSolidRect(&rect, face);
}
else
{
CRect rect(0, 0, m_width, 3);
dc.FillSolidRect(&rect, face);
}
}
开发者ID:RKelson93,项目名称:mushclient,代码行数:27,代码来源:MDITabs.cpp
示例13: AfxGetThreadState
COleControlLock::COleControlLock(REFCLSID clsid)
{
// initialize the object
m_pNextLock = NULL;
m_clsid = clsid;
m_pClassFactory = NULL;
// initialize OLE, if necessary
_AFX_THREAD_STATE* pState = AfxGetThreadState();
if (!pState->m_bNeedTerm && !AfxOleInit())
return;
// attempt to lock the class factory of the control
if (SUCCEEDED(::CoGetClassObject(clsid,
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, NULL, IID_IClassFactory,
(void**)&m_pClassFactory)))
{
ASSERT(m_pClassFactory != NULL);
if (FAILED(m_pClassFactory->LockServer(TRUE)))
{
m_pClassFactory->Release();
m_pClassFactory = NULL;
}
}
}
开发者ID:Rupan,项目名称:winscp,代码行数:25,代码来源:occlock.cpp
示例14: _AfxMsgFilterHook
static LRESULT CALLBACK _AfxMsgFilterHook(int code, WPARAM wParam, LPARAM lParam) {
CWinThread* pThread;
if (AfxGetModuleState()->m_bDLL || (code < 0 && code != MSGF_DDEMGR) || !(pThread = AfxGetThread()))
return AfxGetThreadState()->m_hookMsg.CallNext(code, wParam, lParam);
ASSERT(pThread != NULL);
return (LRESULT)pThread->ProcessMessageFilter(code, (LPMSG)lParam);
}
开发者ID:sirmax1,项目名称:coin,代码行数:7,代码来源:win-thread.cpp
示例15: AfxCriticalNewHandler
int AFX_CDECL AfxCriticalNewHandler(size_t nSize)
// nSize is already rounded
{
// called during critical memory allocation
// free up part of the app's safety cache
TRACE0("Warning: Critical memory allocation failed!\n");
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
if (pThreadState != NULL && pThreadState->m_pSafetyPoolBuffer != NULL)
{
size_t nOldBufferSize = _msize(pThreadState->m_pSafetyPoolBuffer);
if (nOldBufferSize <= nSize + MIN_MALLOC_OVERHEAD)
{
// give it all up
TRACE0("Warning: Freeing application's memory safety pool!\n");
free(pThreadState->m_pSafetyPoolBuffer);
pThreadState->m_pSafetyPoolBuffer = NULL;
}
else
{
BOOL bEnable = AfxEnableMemoryTracking(FALSE);
_expand(pThreadState->m_pSafetyPoolBuffer,
nOldBufferSize - (nSize + MIN_MALLOC_OVERHEAD));
AfxEnableMemoryTracking(bEnable);
TRACE3("Warning: Shrinking safety pool from %d to %d to satisfy request of %d bytes.\n",
nOldBufferSize, _msize(pThreadState->m_pSafetyPoolBuffer), nSize);
}
return 1; // retry it
}
TRACE0("ERROR: Critical memory allocation from safety pool failed!\n");
AfxThrowMemoryException(); // oops
return 0;
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:33,代码来源:winutil.cpp
示例16: AfxGetThreadState
//////////////////
// Like calling base class WindowProc, but with no args, so individual
// message handlers can do the default thing. Like CWnd::Default
//
LRESULT CSubclassWnd::Default()
{
// MFC stores current MSG in thread state
MSG& curMsg = AfxGetThreadState()->m_lastSentMsg;
// Note: must explicitly call CSubclassWnd::WindowProc to avoid infinte
// recursion on virtual function
return CSubclassWnd::WindowProc(curMsg.message, curMsg.wParam, curMsg.lParam);
}
开发者ID:SoyPay,项目名称:DacrsUI,代码行数:12,代码来源:Subclass.cpp
示例17: AfxGetThreadState
// ==> XP Style Menu [Xanatos] - Stulle
void CStatisticsTree::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
HMENU hMenu = AfxGetThreadState()->m_hTrackingMenu;
if(CMenu *pMenu = CMenu::FromHandle(hMenu))
pMenu->MeasureItem(lpMeasureItemStruct);
CTreeCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
开发者ID:brolee,项目名称:EMule-GIFC,代码行数:9,代码来源:StatisticsTree.cpp
示例18: AfxGetThreadState
void CDownloadClientsCtrl::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
HMENU hMenu = AfxGetThreadState()->m_hTrackingMenu;
CMenu *pMenu = CMenu::FromHandle(hMenu);
pMenu->MeasureItem(lpMeasureItemStruct);
CWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
开发者ID:BackupTheBerlios,项目名称:nextemf,代码行数:8,代码来源:DownloadClientsCtrl.cpp
示例19: AfxGetThreadState
// ==> XP Style Menu [Xanatos] - Stulle
void CPPgScheduler::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
HMENU hMenu = AfxGetThreadState()->m_hTrackingMenu;
if(CMenu *pMenu = CMenu::FromHandle(hMenu))
pMenu->MeasureItem(lpMeasureItemStruct);
CPropertyPage::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
开发者ID:rusingineer,项目名称:StulleMule,代码行数:9,代码来源:PPgScheduler.cpp
示例20: AfxGetThreadState
INT_PTR CColorDialog::DoModal()
/*****************************/
{
_AFX_THREAD_STATE *pState = AfxGetThreadState();
ASSERT( pState != NULL );
ASSERT( pState->m_pAlternateWndInit == NULL );
pState->m_pAlternateWndInit = this;
return( ::ChooseColor( &m_cc ) ? IDOK : IDCANCEL );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:9,代码来源:colordlg.cpp
注:本文中的AfxGetThreadState函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论