예제 #1
0
void CSSE2Surface32Intrinsic::BlurBits()
{
    int height = GetVisibleHeight();
    ULONGLONG *pCur  = (ULONGLONG *)GetPixelAddress(0,0);
	ASSERT((DWORD_PTR(pCur) & 0xF) == 0);

	CSSE2 cFader;
	CSSE2 cRight, cLeft;
	CSSE2 cUp, cDown, cCur;
	CSSE2 cResult;

	cFader.UnpackBytesLo( 0x0101010101010101u );
	cLeft.Clear();

	do {
		int width = m_width;
		ASSERT((DWORD_PTR(pCur) & 0xF) == 0);
		do {
			RGBQUAD *pdwCur = (RGBQUAD*)pCur;
			ULONGLONG *pNext = (ULONGLONG*)(pdwCur+1);

			// Load pixels and do the mmx unpack
			cCur.UnpackBytesLo( *pCur );
			cRight.UnpackBytesLo( *pNext );
			cUp.UnpackBytesLo( pCur[-m_qwpl] );
			cDown.UnpackBytesLo( pCur[m_qwpl] );

			// Actual math. Don't step on current, or right.
			// Sum the 4 around and double the middle
			
			// Do current pixel in this line
			cResult = (cDown+cUp+cLeft+cRight+(cCur<<2))>>3;

			// Do next pixel
			cLeft = cRight; 		// Slide left!
			cCur.UnpackBytesLo( pCur[1] );
			cRight.UnpackBytesLo( pNext[1] );
			cUp.UnpackBytesLo( pCur[-m_qwpl+1] );
			cDown.UnpackBytesLo( pCur[m_qwpl+1] );
			cCur = (cDown+cUp+cLeft+cRight+(cCur<<2))>>3;

#if defined(TRIPPY)
			cCur += cFader; // increase the fade to white
			cResult += cFader; // increase the fade to white
#elif defined (FAST_FADE)
    	    cCur -= cFader; // increase the fade to black
    	    cResult -= cFader; // increase the fade to black
#endif
			cLeft = cRight; 		// Slide left!
	
			cResult.PackBytes(pCur, cCur);
			pCur += 2;
		} while (--width > 0);
	} while (--height > 0);
}
예제 #2
0
void CFolderListCtrl::AddFileItem(const _tfinddata_t &fd, int nLargeIconInd, int nSmallIconInd, CString &strExt)
{
	CString sFileName;
	int nItemPos;
	if( m_sFolderPath.GetLength() && 
		( m_sFolderPath[m_sFolderPath.GetLength()-1] == _T('\\') ||
		  m_sFolderPath[m_sFolderPath.GetLength()-1] == _T('/') ) )
		sFileName = m_sFolderPath+ fd.name;
	else
		sFileName = m_sFolderPath + (  _T("\\") ) + fd.name;
	
	CFLCItemData * pData;
	pData = new CFLCItemData( sFileName, strExt );
	pData->m_nSize = fd.size;
	pData->m_tModified = fd.time_write;
	pData->m_nLargeIconInd = nLargeIconInd;
	pData->m_nSmallIconInd = nSmallIconInd;

	nItemPos = InsertItem( m_nItemCount, fd.name, FLC_IMAGE_EMPTY );
	SetItemData( nItemPos, DWORD_PTR(pData) );
	SetItemText( nItemPos, 1, SizeToStr( pData->m_nSize ) );
	SetItemText( nItemPos, 2, TimeToStr( pData->m_tModified ) );
	SetValidItemImage( nItemPos );
	m_nItemCount++;
	if (m_strSelectedPath.CompareNoCase(sFileName)==0)
	{
		SetItemState(nItemPos, LVIS_SELECTED, LVIS_SELECTED);
	}
}
예제 #3
0
BOOL CBanTypeDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    TRANSLATE(*this, IDD);

    CString szText = _T("Ban IP-address");
    TRANSLATE_ITEM(IDC_STATIC_IPADDR, szText);
    int i = m_wndBanType.AddString(szText);
    m_wndBanType.SetItemData(i, DWORD_PTR(BANTYPE_IPADDR));
    szText = _T("Ban username");
    TRANSLATE_ITEM(IDC_STATIC_USERNAME, szText);
    i = m_wndBanType.AddString(szText); 
    m_wndBanType.SetItemData(i, DWORD_PTR(BANTYPE_USERNAME));
    m_wndBanType.SetCurSel(0);
    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
}
예제 #4
0
/**
	@brief	

	@author HumKyung.BAEK	

	@date 2009-04-11 오전 9:04:34	

	@param	

	@return		
**/
int CAssignLoadToBusDlg::DisplayBusItem(const bool& bUpdate)
{
	m_wndBusListCtrl.SetRedraw(FALSE);
	if(false == bUpdate) m_wndBusListCtrl.DeleteAllItems();
	
	CELoadDocData& docData = CELoadDocData::GetInstance();
	list<CELoadItem*> BusGroupItemList;
	docData.GetELoadItemListOf(BusGroupItemList , CBusGroupItem::TypeString());
	//if(pItemList)
	{
		int i = 0;
		for(list<CELoadItem*>::iterator itr = BusGroupItemList.begin();itr != BusGroupItemList.end();++itr)
		{
			CBusGroupItem* pBusGroupItem = static_cast<CBusGroupItem*>(*itr);
			if(pBusGroupItem->IsDeleted() || (INCOMING == pBusGroupItem->GetName())) continue;

			for(vector<CBusItem*>::iterator jtr = pBusGroupItem->m_BusRefEntry.begin();jtr != pBusGroupItem->m_BusRefEntry.end();++jtr)
			{
				if((*jtr)->IsDeleted()) continue;

				const string rBusID = (*jtr)->GetName();
				double nKW = 0.f , nKVAR = 0.f;
				(*jtr)->GetLoadSummaryResultData(nKW , nKVAR);
				const double nKVA = SAFE_ROUND(sqrt(nKW*nKW + nKVAR*nKVAR) , 2);

				ostringstream oss;
				oss << nKVA;
				if(false == bUpdate)
				{
					const int nIconNo = docData.GetIconNo(*jtr);
					const int nItem = m_wndBusListCtrl.InsertItem(i++,rBusID.c_str(), nIconNo);
					if(-1 != nItem)
					{
						m_wndBusListCtrl.SetItemText(nItem , 1 , oss.str().c_str());
						m_wndBusListCtrl.SetItemText(nItem , 2 , oss.str().c_str());
						m_wndBusListCtrl.SetItemData(nItem , DWORD_PTR(*jtr));
					}
				}
				else
				{
					LVFINDINFO info;
					info.flags = LVFI_PARTIAL|LVFI_STRING;
					info.psz = rBusID.c_str();

					const int nItem = m_wndBusListCtrl.FindItem(&info);
					if(-1 != nItem)
					{
						m_wndBusListCtrl.SetItemText(nItem , 2 , oss.str().c_str());
					}
				}
			}
		}
	}
	m_wndBusListCtrl.SetRedraw(TRUE);

	return ERROR_SUCCESS;
}
예제 #5
0
void CWZPropertyPage::ShowHelp(const CString &topicFile)
{
  if (!app.GetHelpFileName().IsEmpty()) {
    const CString cs_HelpTopic = app.GetHelpFileName() + topicFile;
    HtmlHelp(DWORD_PTR((LPCWSTR)cs_HelpTopic), HH_DISPLAY_TOPIC);
  } else {
    CGeneralMsgBox gmb;
    gmb.AfxMessageBox(IDS_HELP_UNAVALIABLE, MB_ICONERROR);
  }
}
예제 #6
0
// COptionsGeneral message handlers
BOOL COptionsGeneral::OnInitDialog() 
{
	CDialog::OnInitDialog();

	UpdateThumbnail();
	size_t nDFI = CSCAD3DMdlSettings::Get3DS() ? CSCAD3DMdlSettings::Get3DS()->GetEFISize() : 0;
	int nItemPos;
	const FPTExtFuncInfo * pEFI;
	UINT i;
	CRect r;

	m_ViewProperty = m_rViewerOptions.m_ViewProp;
	for( i = 0; i < nDFI; i++ )
	{
		pEFI = CSCAD3DMdlSettings::Get3DS()->GetEFIAt( i );
		nItemPos = m_FileTypeList.AddString( pEFI->m_sDescript );
		m_FileTypeList.SetItemData( nItemPos, DWORD_PTR(pEFI) );
		if( std::find( m_ViewProperty.m_vsExt.begin(), m_ViewProperty.m_vsExt.end(), pEFI->m_sExt ) != m_ViewProperty.m_vsExt.end() )
			m_FileTypeList.SetSel( nItemPos, TRUE );
	}

	for( i = 0; i < SCADDefProj::GetDefProjSize(); i++ )
	{
		nItemPos = m_DefProjList.AddString( SCADDefProj::GetDesc( SCDefProjType(i) ) );
		m_DefProjList.SetItemData( nItemPos, DWORD(i) );
		if( m_ViewProperty.m_DefProj == int(i) )
			m_DefProjList.SetCurSel( nItemPos );
	}
	//m_ViewProperty.m_DefProj = m_rViewerOptions.nDefaultView;
	m_ThumbWidthSlider.GetClientRect( &r );
	m_ThumbWidthSlider.SetRange( 10, r.Width() );
	m_ThumbWidthSlider.SetTicFreq( 10 );
	m_ThumbWidthSlider.SetPos( m_ViewProperty.m_nItemCX);
	m_ThumbHeightSlider.GetClientRect( &r );
	m_ThumbHeightSlider.SetRange( 10, r.Height() );
	m_ThumbHeightSlider.SetTicFreq( 10 );
	m_ThumbHeightSlider.SetPos( m_ViewProperty.m_nItemCY);

	static_cast<CButton*>(GetDlgItem( IDC_SIZE_PROP ))->SetBitmap( m_LockBmp );
	static_cast<CButton*>(GetDlgItem( IDC_SIZE_PROP ))->SetCheck( m_bSyncChangeThumbSize ? BST_CHECKED : BST_UNCHECKED );

	nItemPos = m_Languages.AddString( _T("English") );
	m_Languages.SetItemData( nItemPos, 1033 );
	if( m_nLangID == 1033 )
		m_Languages.SetCurSel( nItemPos );
	nItemPos = m_Languages.AddString( _T("–усский") );
	m_Languages.SetItemData( nItemPos, 1049 );
	if( m_nLangID == 1049 )
		m_Languages.SetCurSel( nItemPos );


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
예제 #7
0
void CCPUFrequencyMonitor::StartThreads()
{
	UIETWASSERT(!hExitEvent_);
	if (!hExitEvent_)
	{
		// Must do all this before creating the child threads.
		SYSTEM_INFO systemInfo;
		GetSystemInfo(&systemInfo);
		numCPUs_ = systemInfo.dwNumberOfProcessors;
		// Clamp to the number of processors that can be identified by
		// SetThreadAffinityMask - 32 or 64.
		if (numCPUs_ > sizeof(DWORD_PTR) * 8)
			numCPUs_ = sizeof(DWORD_PTR) * 8;
		threads_.resize(numCPUs_);
		quit_ = false;

		workStartSemaphore_ = CreateSemaphore(nullptr, 0, numCPUs_, nullptr);
		resultsDoneSemaphore_ = CreateSemaphore(nullptr, 0, numCPUs_, nullptr);
		if (!workStartSemaphore_ || !resultsDoneSemaphore_)
			return;

		// Create numCPUs_ threads, set their affinity to individual CPU
		// cores, and raise their priority. This will mostly ensure that they
		// run promptly and on the desired CPU core.
		for (unsigned i = 0; i < numCPUs_; ++i)
		{
			threads_[i].pOwner = this;
			threads_[i].cpuNumber = i;
			HANDLE hThread = CreateThread(nullptr, 0x10000, StaticPerCPUSamplingThread, &threads_[i], 0, nullptr);
			if (hThread)
			{
				SetThreadAffinityMask(hThread, DWORD_PTR(1) << i);
				SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST);
			}
			threads_[i].hThread = hThread;
		}

		// Get the initial frequency
		QPCElapsedTimer timer;
		// Run the test long enough so that the OS will ramp up the CPU to
		// full speed.
		startFrequency_ = MeasureFrequency(600);
		float testElapsed = static_cast<float>(timer.ElapsedSeconds());

		ETWMark2F("Startup CPU frequency (MHz) and measurement time (s)", startFrequency_, testElapsed);

		// Once the monitor thread is created the other threads will start
		// being told to do measurements occasionally.
		hExitEvent_ = CreateEvent(nullptr, FALSE, FALSE, nullptr);
		hThread_ = CreateThread(NULL, 0, StaticMonitorThread, this, 0, NULL);
	}
}
예제 #8
0
  /*! set the affinity of a given thread */
  void setAffinity(HANDLE thread, ssize_t affinity)
  {
#if _WIN32_WINNT >= _WIN32_WINNT_WIN7
    typedef WORD (WINAPI *GetActiveProcessorGroupCountFunc)();
    typedef DWORD (WINAPI *GetActiveProcessorCountFunc)(WORD);
    typedef BOOL (WINAPI *SetThreadGroupAffinityFunc)(HANDLE, const GROUP_AFFINITY *, PGROUP_AFFINITY);
    typedef BOOL (WINAPI *SetThreadIdealProcessorExFunc)(HANDLE, PPROCESSOR_NUMBER, PPROCESSOR_NUMBER);
    HMODULE hlib = LoadLibrary("Kernel32");
    GetActiveProcessorGroupCountFunc pGetActiveProcessorGroupCount = (GetActiveProcessorGroupCountFunc)GetProcAddress(hlib, "GetActiveProcessorGroupCount");
    GetActiveProcessorCountFunc pGetActiveProcessorCount = (GetActiveProcessorCountFunc)GetProcAddress(hlib, "GetActiveProcessorCount");
    SetThreadGroupAffinityFunc pSetThreadGroupAffinity = (SetThreadGroupAffinityFunc)GetProcAddress(hlib, "SetThreadGroupAffinity");
    SetThreadIdealProcessorExFunc pSetThreadIdealProcessorEx = (SetThreadIdealProcessorExFunc)GetProcAddress(hlib, "SetThreadIdealProcessorEx");
    if (pGetActiveProcessorGroupCount && pGetActiveProcessorCount && pSetThreadGroupAffinity && pSetThreadIdealProcessorEx) 
    {
      int groups = pGetActiveProcessorGroupCount();
      int totalProcessors = 0, group = 0, number = 0;
      for (int i = 0; i<groups; i++) {
        int processors = pGetActiveProcessorCount(i);
        if (totalProcessors + processors > affinity) {
          group = i;
          number = (int)affinity - totalProcessors;
          break;
        }
        totalProcessors += processors;
      }
  
      GROUP_AFFINITY groupAffinity;
      groupAffinity.Group = (WORD)group;
      groupAffinity.Mask = (KAFFINITY)(uint64_t(1) << number);
      groupAffinity.Reserved[0] = 0;
      groupAffinity.Reserved[1] = 0;
      groupAffinity.Reserved[2] = 0;
      if (!pSetThreadGroupAffinity(thread, &groupAffinity, nullptr))
        WARNING("SetThreadGroupAffinity failed"); // on purpose only a warning
  
      PROCESSOR_NUMBER processorNumber;
      processorNumber.Group = group;
      processorNumber.Number = number;
      processorNumber.Reserved = 0;
      if (!pSetThreadIdealProcessorEx(thread, &processorNumber, nullptr))
        WARNING("SetThreadIdealProcessorEx failed"); // on purpose only a warning
    } 
    else 
#endif
    {
      if (!SetThreadAffinityMask(thread, DWORD_PTR(uint64_t(1) << affinity)))
        WARNING("SetThreadAffinityMask failed"); // on purpose only a warning
      if (SetThreadIdealProcessor(thread, (DWORD)affinity) == (DWORD)-1)
        WARNING("SetThreadIdealProcessor failed"); // on purpose only a warning
      }
  }
예제 #9
0
    void set_thread_affinity_mask(
        boost::thread& thrd
      , mask_type mask
      , error_code& ec = throws
        ) const
    { // {{{
        if (!SetThreadAffinityMask(thrd.native_handle(), DWORD_PTR(mask)))
        {
            HPX_THROWS_IF(ec, kernel_error
              , "hpx::threads::windows_topology::set_thread_affinity_mask"
              , boost::str(boost::format(
                    "failed to set thread %1% affinity mask")
                    % mask));
        }

        else if (&ec != &throws)
            ec = make_success_code();
    } // }}}
예제 #10
0
		MMRESULT Open(unsigned int deviceId)
		{
			// open midi input
			MMRESULT mmResult;
			mmResult = midiInOpen(&handle, deviceId, DWORD_PTR(Proc), NULL, CALLBACK_FUNCTION);
			if (mmResult)
			{
				char buf[256];
				GetLastErrorMessage(buf, 256);
				DebugPrint("Error opening MIDI input: %s", buf);
				return mmResult;
			}

			// prepare input buffer
			header.lpData = sysexbuffer;
			header.dwBufferLength = sizeof(sysexbuffer);
			header.dwFlags = 0;
			mmResult = midiInPrepareHeader(handle, &header, sizeof(MIDIHDR));
			if (mmResult)
			{
				char buf[256];
				GetLastErrorMessage(buf, 256);
				DebugPrint("Error preparing MIDI header: %s", buf);
				return mmResult;
			}

			// queue input buffer
			mmResult = midiInAddBuffer(handle, &header, sizeof(MIDIHDR));
			if (mmResult)
			{
				char buf[256];
				GetLastErrorMessage(buf, 256);
				DebugPrint("Error adding MIDI input buffer: %s", buf);
				return mmResult;
			}

			return mmResult;
		}
예제 #11
0
  /*! set the affinity of a given thread */
  void setAffinity(HANDLE thread, ssize_t affinity)
  {
#if (_WIN32_WINNT >= 0x0601) // FIXME: use getProcAddress to activate this feature only if supported by Windows
    int groups = GetActiveProcessorGroupCount();
    int totalProcessors = 0, group = 0, number = 0;
    for (int i = 0; i<groups; i++) {
      int processors = GetActiveProcessorCount(i);
      if (totalProcessors + processors > affinity) {
        group = i;
        number = (int)affinity - totalProcessors;
        break;
      }
      totalProcessors += processors;
    }

    GROUP_AFFINITY groupAffinity;
    groupAffinity.Group = (WORD)group;
    groupAffinity.Mask = (KAFFINITY)(uint64(1) << number);
    groupAffinity.Reserved[0] = 0;
    groupAffinity.Reserved[1] = 0;
    groupAffinity.Reserved[2] = 0;
    if (!SetThreadGroupAffinity(thread, &groupAffinity, NULL))
      THROW_RUNTIME_ERROR("cannot set thread group affinity");

    PROCESSOR_NUMBER processorNumber;
    processorNumber.Group = group;
    processorNumber.Number = number;
    processorNumber.Reserved = 0;
    if (!SetThreadIdealProcessorEx(thread, &processorNumber, NULL))
      THROW_RUNTIME_ERROR("cannot set ideal processor");
#else
    if (!SetThreadAffinityMask(thread, DWORD_PTR(uint64(1) << affinity)))
      THROW_RUNTIME_ERROR("cannot set thread affinity mask");
    if (SetThreadIdealProcessor(thread, (DWORD)affinity) == (DWORD)-1)
      THROW_RUNTIME_ERROR("cannot set ideal processor");
#endif
  }
예제 #12
0
파일: thread.cpp 프로젝트: Qirix/embree
  /*! set the affinity of a given thread */
  void setAffinity(HANDLE thread, ssize_t affinity)
  {
#if (_WIN32_WINNT >= 0x0601)
    int groups = GetActiveProcessorGroupCount();
    int totalProcessors = 0, group = 0, number = 0;
    for (int i = 0; i<groups; i++) {
      int processors = GetActiveProcessorCount(i);
      if (totalProcessors + processors > affinity) {
        group = i;
        number = (int)affinity - totalProcessors;
        break;
      }
      totalProcessors += processors;
    }

    GROUP_AFFINITY groupAffinity;
    groupAffinity.Group = (WORD)group;
    groupAffinity.Mask = (KAFFINITY)(uint64(1) << number);
    groupAffinity.Reserved[0] = 0;
    groupAffinity.Reserved[1] = 0;
    groupAffinity.Reserved[2] = 0;
    if (!SetThreadGroupAffinity(thread, &groupAffinity, NULL))
      throw std::runtime_error("cannot set thread group affinity");

    PROCESSOR_NUMBER processorNumber;
    processorNumber.Group = group;
    processorNumber.Number = number;
    processorNumber.Reserved = 0;
    if (!SetThreadIdealProcessorEx(thread, &processorNumber, NULL))
      throw std::runtime_error("cannot set thread ideal processor");
#else
    if (!SetThreadAffinityMask(thread, DWORD_PTR(uint64(1) << affinity)))
      throw std::runtime_error("cannot set thread affinity mask");
    if (SetThreadIdealProcessor(thread, (DWORD)affinity) == (DWORD)-1)
      throw std::runtime_error("cannot set thread ideal processor");
#endif
  }
BOOL CALLBACK InternalEmulatorSettingsProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG: {
		DialogData *d;
		std::string s;

		for (unsigned i = 0; i < 16; i++) {
			std::stringstream ss;
			ss << "JOY" << i;
			SendMessage(GetDlgItem(hWnd, IDC_IEJOYNUM), CB_ADDSTRING, 0, (LPARAM)ss.str().c_str());
		}
		s = "DISABLE";
		SendMessage(GetDlgItem(hWnd, IDC_IEJOYNUM), CB_ADDSTRING, 0, (LPARAM)s.c_str());
		SendMessage(GetDlgItem(hWnd, IDC_IEJOYNUM), CB_SETCURSEL, set.joyNum, 0);

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::UP)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYUP), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYUP), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::DOWN)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYDOWN), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYDOWN), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::LEFT)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYLEFT), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYLEFT), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::RIGHT)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYRIGHT), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYRIGHT), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::A)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYA), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYA), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::B)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYB), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYB), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::X)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYX), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYX), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::Y)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYY), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYY), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::L)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYL), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYL), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::R)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYR), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYR), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::SELECT)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYSELECT), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYSELECT), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::START)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYSTART), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYSTART), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::NEXTSTATE)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYNEXTSTATE), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYNEXTSTATE), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::PREVSTATE)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYPREVSTATE), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYPREVSTATE), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::SAVESTATE)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYSAVESTATE), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYSAVESTATE), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::LOADSTATE)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYLOADSTATE), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYLOADSTATE), s.c_str());

		d = new DialogData;
		d->setting = set.emulatorButtons[unsigned(InternalEmulatorButtonType::FASTFORWARD)];
		SetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYFASTFORWARD), InternalEmulatorInputDialogProc, 0, DWORD_PTR(d));
		s = GetButtonText(d);
		SetWindowText(GetDlgItem(hWnd, IDC_IEKEYFASTFORWARD), s.c_str());

		SendMessage(GetDlgItem(hWnd, IDC_IEVOLUME), TBM_SETRANGEMIN, 0, DSBVOLUME_MIN + 10000);
		SendMessage(GetDlgItem(hWnd, IDC_IEVOLUME), TBM_SETRANGEMAX, 0, DSBVOLUME_MAX + 10000);
		SendMessage(GetDlgItem(hWnd, IDC_IEVOLUME), TBM_SETPOS, 1, set.volume + 10000);

		break;
	}
	case WM_COMMAND: {
		switch (LOWORD(wParam))
		{
		case IDC_IESAVE: {
			DialogData *d;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYUP), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::UP)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYDOWN), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::DOWN)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYLEFT), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::LEFT)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYRIGHT), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::RIGHT)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYA), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::A)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYB), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::B)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYX), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::X)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYY), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::Y)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYL), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::L)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYR), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::R)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYSELECT), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::SELECT)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYSTART), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::START)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYNEXTSTATE), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::NEXTSTATE)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYPREVSTATE), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::PREVSTATE)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYSAVESTATE), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::SAVESTATE)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYLOADSTATE), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::LOADSTATE)] = d->setting;
			GetWindowSubclass(GetDlgItem(hWnd, IDC_IEKEYFASTFORWARD), InternalEmulatorInputDialogProc, NULL, (DWORD_PTR *)(&d));
			set.emulatorButtons[unsigned(InternalEmulatorButtonType::FASTFORWARD)] = d->setting;

			set.volume = SendMessage(GetDlgItem(hWnd, IDC_IEVOLUME), TBM_GETPOS, NULL, NULL) - 10000;
			set.joyNum = SendMessage(GetDlgItem(hWnd, IDC_IEJOYNUM), CB_GETCURSEL, 0, 0);

			DeleteState(hWnd);
			EndDialog(hWnd, 0);

			break;
		}
		case IDC_IECANCEL: {
			DeleteState(hWnd);
			EndDialog(hWnd, 0);
			break;
		}
		}
		break;
	}
	case WM_HSCROLL: {
		unsigned v = SendMessage(GetDlgItem(hWnd, IDC_IEVOLUME), TBM_GETPOS, NULL, NULL) - 10000;
		SetVolume(v);
		break;
	}
	case WM_CLOSE: {
		DeleteState(hWnd);
		EndDialog(hWnd, 0);
		break;
	}
	default:
		return FALSE;
	}
	return TRUE;
}
예제 #14
0
	bool MScheduler::Init( uint32 numThreads )
	{
		static const uint32 cProcessors = GetCPUThreadCount();
		AX_ASSERT( cProcessors > 0 );

		const uint32 cDesiredThreads = numThreads > 0 ? numThreads : cProcessors;
		const uint32 cThreads = cDesiredThreads >= kMaxWorkers ? kMaxWorkers : cDesiredThreads;

		for( uint32 i = 0; i < cThreads; ++i ) {
#ifdef _MSC_VER
# pragma warning( push )
# pragma warning( disable:4316 ) //object allocated on the heap may not be aligned 64
#endif
			m_pWorkers[ i ] = new LWorker( *this, i );
#ifdef _MSC_VER
# pragma warning( pop )
#endif
			if( !AX_VERIFY_NOT_NULL( m_pWorkers[ i ] ) ) {
				while( i > 0 ) {
					delete m_pWorkers[ i - 1 ];
					--i;
				}

				return false;
			}
		}

#ifdef _WIN32
		// Peg the main thread to one specific processor core for QueryPerformanceCounter() improvement
		SetThreadAffinityMask( GetCurrentThread(), 1<<0 );
#endif

		m_pThreads[ 0 ] = nullptr;
		for( uint32 i = 1; i < cThreads; ++i ) {
			m_pThreads[ i ] = new LWorkerThread( *m_pWorkers[ i ] );
			if( !AX_VERIFY_NOT_NULL( m_pThreads[ i ] ) ) {
				while( i > 0 ) {
					delete m_pThreads[ i - 1 ];
					--i;
				}

				for( i = 0; i < cThreads; ++i ) {
					delete m_pWorkers[ i ];
				}

				return false;
			}

#if AX_THREAD_MODEL == AX_THREAD_MODEL_WINDOWS
			const HANDLE hThread = m_pThreads[ i ]->GetNative_MSWin();
			SetThreadAffinityMask( hThread, DWORD_PTR( 1 )<<i );
#endif
		}

		m_cWorkers = cThreads;

		m_cSleepingWorkers = 0;
		m_bIsQuitting = false;
		m_cFrameChains = 0;
		m_cFrameTasks = 0;
#if !AX_ASYNC_LOCAL_WORK_ENABLED
		m_cSubmittedChains = 0;
#endif
#if !AX_ASYNC_PER_WORKER_IDLE_FLAG_ENABLED
		m_cIdleWorkers = m_cWorkers;
#endif

		AX_MEMORY_BARRIER(); //must be set before threads start (this is just paranoia)

		for( uint32 i = 1; i < cThreads; ++i ) {
			m_pThreads[ i ]->Start();
		}

		return true;
	}
예제 #15
0
void CImportTextDlg::OnHelp() 
{
  CString cs_HelpTopic;
  cs_HelpTopic = app.GetHelpFileName() + L"::/html/import.html";
  HtmlHelp(DWORD_PTR((LPCWSTR)cs_HelpTopic), HH_DISPLAY_TOPIC);
}
예제 #16
0
void ClauncherDlg::OnCbnSelchangeAdapter()
{
    int adapterId = m_Adapter.GetCurSel();

    // reset list box
    m_VideoMode.ResetContent();

    // enumerate videomodes
    char str[512];
    D3DDISPLAYMODE displayMode;
    int numModes = m_iDirect3D9->GetAdapterModeCount( adapterId, D3DFMT_X8R8G8B8 );
	int i;
    for( i=0; i<numModes; i++ )
    {
        m_iDirect3D9->EnumAdapterModes( adapterId, D3DFMT_X8R8G8B8, i, &displayMode );
        if( displayMode.Width >= 640 && displayMode.Height >= 480 )
        {
            sprintf( str, "%dx%dx%d", displayMode.Width, displayMode.Height, displayMode.RefreshRate );
            int stringId = m_VideoMode.AddString( str );
            m_VideoMode.SetItemData( stringId, DWORD_PTR( i ) );
        }
    }

    // configuration element 
    TiXmlElement* video = getConfigElement( "video" ); assert( video );
    int width, height, rate;
    video->Attribute( "width", &width );
    video->Attribute( "height", &height );
    video->Attribute( "rate", &rate );

    // try to select corresponding videomode in list
    bool modeIsSelected = false;
    for( i=0; i<m_VideoMode.GetCount(); i++ )
    {
        m_iDirect3D9->EnumAdapterModes( 
            adapterId, 
            D3DFMT_X8R8G8B8, 
            int( m_VideoMode.GetItemData( i ) ), 
            &displayMode 
        );
        if( displayMode.Width == width && displayMode.Height == height && displayMode.RefreshRate == rate )
        {
            m_VideoMode.SetCurSel( i );
            modeIsSelected = true;
        }
    }

    // if can't select mode - choose first
    if( !modeIsSelected )
    {
        m_iDirect3D9->EnumAdapterModes( 
            adapterId, 
            D3DFMT_X8R8G8B8, 
            int( m_VideoMode.GetItemData( 0 ) ), 
            &displayMode 
        );
        video->SetAttribute( "width", displayMode.Width );
        video->SetAttribute( "height", displayMode.Height );
        video->SetAttribute( "rate", displayMode.RefreshRate );
        m_VideoMode.SetCurSel( 0 );
    }

    // save config
    m_config->SaveFile();
}
예제 #17
0
BOOL ClauncherDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

    // registar game copy (web-edition only)
    Register();

    // load config
    m_config = new TiXmlDocument( "./cfg/config.xml" );
    bool configIsLoaded = m_config->LoadFile();
    assert( configIsLoaded );

	// initialize directx
    m_iDirect3D9  = Direct3DCreate9( D3D_SDK_VERSION ); assert( m_iDirect3D9 );

    // enumerate adapters
    m_numAdapters = m_iDirect3D9->GetAdapterCount();
	int i;
    for( i=0; i<m_numAdapters; i++ )
    {
        // retrieve adapter ID
        D3DADAPTER_IDENTIFIER9 adapterIdentifier;
        m_iDirect3D9->GetAdapterIdentifier( i, 0, &adapterIdentifier );
        // fill checkbox item
        m_Adapter.AddString( adapterIdentifier.Description );
    }

    // configuration element 
    TiXmlElement* video = getConfigElement( "video" ); assert( video );
    int adapterId;
    video->Attribute( "adapter", &adapterId );

    // show adapter & mode
    m_Adapter.SetCurSel( adapterId );
    OnCbnSelchangeAdapter();

    // show fullscreen
    int windowed;
    video->Attribute( "windowed", &windowed );
    if( windowed == 0 )
    {
        m_Fullscreen.SetCheck( 1 );
    }
    else
    {
        m_Fullscreen.SetCheck( 0 );
    }

    // show sync
    int sync;
    video->Attribute( "sync", &sync );
    if( sync == 1 )
    {
        m_Sync.SetCheck( 1 );
    }
    else
    {
        m_Sync.SetCheck( 0 );
    }

    // show afterfx
    int afterfx;
    video->Attribute( "afterfx", &afterfx );
    if( afterfx == 1 )
    {
        m_AfterFx.SetCheck( 1 );
    }
    else
    {
        m_AfterFx.SetCheck( 0 );
    }

    // fill skin shader listbox
    int stringId = m_SkinShader.AddString( "4x" );
    m_SkinShader.SetItemData( stringId, DWORD_PTR( 4 ) );
    stringId = m_SkinShader.AddString( "8x" );
    m_SkinShader.SetItemData( stringId, DWORD_PTR( 8 ) );
    stringId = m_SkinShader.AddString( "16x" );
    m_SkinShader.SetItemData( stringId, DWORD_PTR( 16 ) );
    stringId = m_SkinShader.AddString( "32x" );
    m_SkinShader.SetItemData( stringId, DWORD_PTR( 32 ) );
    stringId = m_SkinShader.AddString( "64x" );
    m_SkinShader.SetItemData( stringId, DWORD_PTR( 64 ) );

    TiXmlElement* skinnedMesh = this->getConfigElement( "skinnedMesh" );
    int bonePalette;
    skinnedMesh->Attribute( "bonePalette", &bonePalette );
    
    // choose skin shader option
    int optionIsSelected = false;
    for( i=0; i<m_SkinShader.GetCount(); i++ )
    {
        if( bonePalette == int( m_SkinShader.GetItemData( i ) ) )
        {
            m_SkinShader.SetCurSel( i );
            optionIsSelected = true;
        }
    }

    // select default option
    if( !optionIsSelected )
    {
        m_SkinShader.SetCurSel( 0 );
        skinnedMesh->SetAttribute( "bonePalette", 4 );
        skinnedMesh->SetAttribute( "lightPalette", 2 );
        m_config->SaveFile();
    }

    // show grass option
    TiXmlElement* details = this->getConfigElement( "details" ); assert( details );
    int grass;
    details->Attribute( "grass", &grass );
    if( grass == 0 )
    {
        m_Grass.SetCheck( 0 );
    }
    else
    {
        m_Grass.SetCheck( 1 );
    }

    // show shadows option
    int shadows;
    video->Attribute( "shadows", &shadows );
    if( shadows == 0 )
    {
        m_Shadows.SetCheck( 0 );
    }
    else
    {
        m_Shadows.SetCheck( 1 );
    }

    // fill crow density control
    stringId = m_Crowd.AddString( "0%" );
    m_Crowd.SetItemData( stringId, 0 );
    stringId = m_Crowd.AddString( "25%" );
    m_Crowd.SetItemData( stringId, 25 );
    stringId = m_Crowd.AddString( "50%" );
    m_Crowd.SetItemData( stringId, 50 );
    stringId = m_Crowd.AddString( "75%" );
    m_Crowd.SetItemData( stringId, 75 );
    stringId = m_Crowd.AddString( "100%" );
    m_Crowd.SetItemData( stringId, 100 );

    // fill traffic density control
    stringId = m_Traffic.AddString( "0%" );
    m_Traffic.SetItemData( stringId, 0 );
    stringId = m_Traffic.AddString( "25%" );
    m_Traffic.SetItemData( stringId, 25 );
    stringId = m_Traffic.AddString( "50%" );
    m_Traffic.SetItemData( stringId, 50 );
    stringId = m_Traffic.AddString( "75%" );
    m_Traffic.SetItemData( stringId, 75 );
    stringId = m_Traffic.AddString( "100%" );
    m_Traffic.SetItemData( stringId, 100 );

    // fill forest density control
    stringId = m_Forest.AddString( "Disabled" );
    m_Forest.SetItemData( stringId, 0 );
    stringId = m_Forest.AddString( "100m" );
    m_Forest.SetItemData( stringId, 10 );
    stringId = m_Forest.AddString( "250m" );
    m_Forest.SetItemData( stringId, 25 );
    stringId = m_Forest.AddString( "500m" );
    m_Forest.SetItemData( stringId, 50 );
    stringId = m_Forest.AddString( "750m" );
    m_Forest.SetItemData( stringId, 75 );
    stringId = m_Forest.AddString( "1000m" );
    m_Forest.SetItemData( stringId, 100 );

    // show crowd density
    double value;
    details->Attribute( "crowd", &value );
    float crowd = float( value );
    optionIsSelected = false;
    for( i=0; i<m_Crowd.GetCount(); i++ )
    {
        float itemData = float( m_Crowd.GetItemData( i ) ) / 100.0f;
        if( crowd == itemData )
        {
            m_Crowd.SetCurSel( i );
            optionIsSelected = true;
            break;
        }
    }
    if( !optionIsSelected )
    {
        m_Crowd.SetCurSel( 0 );
        
        char str[512];
        sprintf( str, "%3.2f", float( m_Crowd.GetItemData( 0 ) ) / 100.0f );
        details->SetAttribute( "crowd", str );
        m_config->SaveFile();
    }

    // show traffic density
    details->Attribute( "traffic", &value );
    float traffic = float( value );
    optionIsSelected = false;
    for( i=0; i<m_Traffic.GetCount(); i++ )
    {
        float itemData = float( m_Traffic.GetItemData( i ) ) / 100.0f;
        if( traffic == itemData )
        {
            m_Traffic.SetCurSel( i );
            optionIsSelected = true;
            break;
        }
    }
    if( !optionIsSelected )
    {
        m_Traffic.SetCurSel( 0 );

        char str[512];
        sprintf( str, "%3.2f", float( m_Traffic.GetItemData( 0 ) ) / 100.0f );
        details->SetAttribute( "traffic", str );
        m_config->SaveFile();
    }

    // show forest range
    details->Attribute( "forest", &value );
    float forest = float( value );
    optionIsSelected = false;
    for( i=0; i<m_Forest.GetCount(); i++ )
    {
        float itemData = float( m_Forest.GetItemData( i ) ) / 100.0f;
        if( forest == itemData )
        {
            m_Forest.SetCurSel( i );
            optionIsSelected = true;
            break;
        }
    }
    if( !optionIsSelected )
    {
        m_Forest.SetCurSel( 0 );

        char str[512];
        sprintf( str, "%3.2f", float( m_Forest.GetItemData( 0 ) ) / 100.0f );
        details->SetAttribute( "forest", str );
        m_config->SaveFile();
    }

    // show music volume
    TiXmlElement* sound = this->getConfigElement( "sound" ); assert( sound );
    value = 0.0f;
    sound->Attribute( "musicVolume", &value );
    if( value < 0 ) value = 0;
    if( value > 1 ) value = 1;
    m_MusicVolume.SetRange( 0, 100, TRUE );
    m_MusicVolume.SetPos( int( value * 100 ) );

    // show pitch shift options
    int pitchShift;
    sound->Attribute( "pitchShift", &pitchShift );
    if( pitchShift == 0 )
    {
        m_PitchShift.SetCheck( 0 );
    }
    else
    {
        m_PitchShift.SetCheck( 1 );
    }

    // show action mapping
    forAllMappings( SetupMappingControl, NULL );
    m_config->SaveFile();
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
예제 #18
0
void __cdecl SplashThread(void *arg)
{
	IGraphBuilder *pGraph = NULL;
	IMediaControl *pControl = NULL;

	if (options.playsnd) {
		// Initialize the COM library.
		CoInitialize(NULL);

		// Create the filter graph manager and query for interfaces.
		CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);

		// Get MediaControl Interface
		pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);

		// Build the graph. IMPORTANT: Change this string to a file on your system.
		pGraph->RenderFile(szSoundFile, NULL);

		// Run the graph.
		pControl->Run();
	}

	WNDCLASSEX wcl;
	wcl.cbSize = sizeof(wcl);
	wcl.lpfnWndProc = SplashWindowProc;
	wcl.style = 0;
	wcl.cbClsExtra = 0;
	wcl.cbWndExtra = 0;
	wcl.hInstance = hInst;
	wcl.hIcon = NULL;
	wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
	wcl.lpszMenuName = NULL;
	wcl.lpszClassName = _T(SPLASH_CLASS);
	wcl.hIconSm = NULL;
	RegisterClassEx(&wcl);

	RECT DesktopRect;
	int w = GetSystemMetrics(SM_CXSCREEN);
	int h = GetSystemMetrics(SM_CYSCREEN);
	DesktopRect.left = 0;
	DesktopRect.top = 0;
	DesktopRect.right = w;
	DesktopRect.bottom = h;

	RECT WindowRect;
	WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2;
	WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2;
	WindowRect.right = WindowRect.left + SplashBmp->getWidth();
	WindowRect.bottom = WindowRect.top + SplashBmp->getHeight();

	hwndSplash = CreateWindowEx(
		WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx
		_T(SPLASH_CLASS), //Class name
		NULL, //Title
		DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle
		WindowRect.left, // x
		WindowRect.top, // y
		SplashBmp->getWidth(), // Width
		SplashBmp->getHeight(), // Height
		HWND_DESKTOP, //Parent
		NULL, //menu handle
		hInst, //Instance
		NULL);

	RECT rc; GetWindowRect(hwndSplash, &rc);
	POINT ptDst = { rc.left, rc.top };
	POINT ptSrc = { 0, 0 };
	SIZE sz = { rc.right - rc.left, rc.bottom - rc.top };
	bool splashWithMarkers = false;

	BLENDFUNCTION blend;
	blend.BlendOp = AC_SRC_OVER;
	blend.BlendFlags = 0;
	blend.SourceConstantAlpha = 0;
	blend.AlphaFormat = AC_SRC_ALPHA;

	if (options.showversion) {
		// locate text markers:
		int i, x = -1, y = -1;

		int splashWidth = SplashBmp->getWidth();
		for (i = 0; i < splashWidth; ++i)
			if (SplashBmp->getRow(0)[i] & 0xFF000000) {
				if (x < 0) {
					x = i - 1; // 1 pixel for marker line
					splashWithMarkers = true;
				}
				else {
					x = -1;
					splashWithMarkers = false;
					break;
				}
			}
		int splashHeight = SplashBmp->getHeight();
		for (i = 0; splashWithMarkers && (i < splashHeight); ++i)
			if (SplashBmp->getRow(i)[0] & 0xFF000000) {
				if (y < 0) {
					y = i - 1; // 1 pixel for marker line
					splashWithMarkers = true;
				}
				else {
					y = -1;
					splashWithMarkers = false;
					break;
				}
			}

		TCHAR verString[256] = { 0 };
		TCHAR *mirandaVerString = mir_a2t(szVersion);
		mir_sntprintf(verString, _T("%s%s"), szPrefix, mirandaVerString);
		mir_free(mirandaVerString);
		LOGFONT lf = { 0 };
		lf.lfHeight = 14;
		mir_tstrcpy(lf.lfFaceName, _T("Verdana"));
		SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf));
		if (!splashWithMarkers) {
			SIZE v_sz = { 0, 0 };
			GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)mir_tstrlen(verString), &v_sz);
			x = SplashBmp->getWidth() / 2 - (v_sz.cx / 2);
			y = SplashBmp->getHeight() - (SplashBmp->getHeight()*(100 - 90) / 100);
		}

		SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL - SplashBmp->getRow(y)[x]) & 0x00FFFFFFUL);
		SetBkMode(SplashBmp->getDC(), TRANSPARENT);
		SplashBmp->DrawText(verString, x, y);
	}

	SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED);
	UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);

	ShowWindow(hwndSplash, SW_SHOWNORMAL);

	if (options.fadein) {
		// Fade in
		for (int i = 0; i < 255; i += options.fisteps) {
			blend.SourceConstantAlpha = i;
			UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
			Sleep(1);
		}
	}
	blend.SourceConstantAlpha = 255;
	UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);

	if (DWORD_PTR(arg) > 0) {
		if (SetTimer(hwndSplash, 6, DWORD_PTR(arg), 0)) {
#ifdef _DEBUG
			logMessage(_T("Timer TimeToShow"), _T("set"));
#endif
		}
	}
	else
		if (bmodulesloaded) {
			if (SetTimer(hwndSplash, 8, 2000, 0)) {
#ifdef _DEBUG
				logMessage(_T("Timer Modules loaded"), _T("set"));
#endif
			}
		}

	// The Message Pump
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump.
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	if (options.playsnd) {
		pControl->Release();
		pGraph->Release();
		CoUninitialize();
	}
}
예제 #19
0
static void initialize_hardware_concurrency_info () {
#if __TBB_WIN8UI_SUPPORT
    // For these applications processor groups info is unavailable
    // Setting up a number of processors for one processor group
    theProcessorGroups[0].numProcs = theProcessorGroups[0].numProcsRunningTotal = std::thread::hardware_concurrency();
#else /* __TBB_WIN8UI_SUPPORT */
    dynamic_link( "Kernel32.dll", ProcessorGroupsApiLinkTable,
                  sizeof(ProcessorGroupsApiLinkTable)/sizeof(dynamic_link_descriptor) );
    SYSTEM_INFO si;
    GetNativeSystemInfo(&si);
    DWORD_PTR pam, sam, m = 1;
    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
    int nproc = 0;
    for ( size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
        if ( pam & m )
            ++nproc;
    }
    __TBB_ASSERT( nproc <= (int)si.dwNumberOfProcessors, NULL );
    // By default setting up a number of processors for one processor group
    theProcessorGroups[0].numProcs = theProcessorGroups[0].numProcsRunningTotal = nproc;
    // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present
    if ( nproc == (int)si.dwNumberOfProcessors && TBB_GetActiveProcessorCount ) {
        // The process does not have restricting affinity mask and multiple processor groups are possible
        ProcessorGroupInfo::NumGroups = (int)TBB_GetActiveProcessorGroupCount();
        __TBB_ASSERT( ProcessorGroupInfo::NumGroups <= MaxProcessorGroups, NULL );
        // Fail safety bootstrap. Release versions will limit available concurrency
        // level, while debug ones would assert.
        if ( ProcessorGroupInfo::NumGroups > MaxProcessorGroups )
            ProcessorGroupInfo::NumGroups = MaxProcessorGroups;
        if ( ProcessorGroupInfo::NumGroups > 1 ) {
            TBB_GROUP_AFFINITY ga;
            if ( TBB_GetThreadGroupAffinity( GetCurrentThread(), &ga ) )
                ProcessorGroupInfo::HoleIndex = ga.Group;
            int nprocs = 0;
            for ( WORD i = 0; i < ProcessorGroupInfo::NumGroups; ++i ) {
                ProcessorGroupInfo  &pgi = theProcessorGroups[i];
                pgi.numProcs = (int)TBB_GetActiveProcessorCount(i);
                __TBB_ASSERT( pgi.numProcs <= (int)sizeof(DWORD_PTR) * CHAR_BIT, NULL );
                pgi.mask = pgi.numProcs == sizeof(DWORD_PTR) * CHAR_BIT ? ~(DWORD_PTR)0 : (DWORD_PTR(1) << pgi.numProcs) - 1;
                pgi.numProcsRunningTotal = nprocs += pgi.numProcs;
            }
            __TBB_ASSERT( nprocs == (int)TBB_GetActiveProcessorCount( TBB_ALL_PROCESSOR_GROUPS ), NULL );
        }
    }
#endif /* __TBB_WIN8UI_SUPPORT */

    PrintExtraVersionInfo("Processor groups", "%d", ProcessorGroupInfo::NumGroups);
    if (ProcessorGroupInfo::NumGroups>1)
        for (int i=0; i<ProcessorGroupInfo::NumGroups; ++i)
            PrintExtraVersionInfo( "----- Group", "%d: size %d", i, theProcessorGroups[i].numProcs);
}
예제 #20
0
void COptionsShortcuts::OnHelp()
{
  CString cs_HelpTopic;
  cs_HelpTopic = app.GetHelpFileName() + L"::/html/shortcuts_tab.html";
  HtmlHelp(DWORD_PTR((LPCWSTR)cs_HelpTopic), HH_DISPLAY_TOPIC);
}
예제 #21
0
/**
	@brief	DISPLAY LOAD ITEM

	@author KHS	

	@return		
**/
int CCableRouteAssignTOLoadDlg::DisplayLoadHasRouteGroup(CMFCTextColorListCtrl& ListCtrl , const string& rRouteGroup, const string& rArea, const string rBusId)
{
	CELoadDocData& docData = CELoadDocData::GetInstance();
	list<CELoadItem*> LoadItemList;
	docData.GetELoadItemListOf(LoadItemList , CLoadItem::TypeString(), "*");
	///if(pItemList)
	{
		int i = 0;

		ListCtrl.SetRedraw(FALSE);
		ListCtrl.DeleteAllItems();
		ListCtrl.m_ItemColorMap.clear();
		for(list<CELoadItem*>::iterator itr = LoadItemList.begin();itr != LoadItemList.end();++itr)
		{
			if((*itr)->IsDeleted()) continue;

			CLoadItem* pLoadItem = static_cast<CLoadItem*>(*itr);
			if(pLoadItem)
			{
				CELoadItemProp *pItemProp = pLoadItem->prop();
				const string rValue = pItemProp->GetValue(_T("Cable Route") , _T("Route Group"));
				const string rLocationArea = pItemProp->GetValue(_T("Location") , _T("Area"));
				const string rPanelBusId = pItemProp->GetValue(_T("Panel"), _T("Bus ID"));

				if((rArea != "*") && (rArea != rLocationArea)) continue;
				if((rBusId != "*") && (rBusId != rPanelBusId)) continue;
				if(rValue != rRouteGroup) continue;
				
				const int nImage = docData.GetIconNo(pLoadItem);
				const int nItem = ListCtrl.InsertItem(i++ , pLoadItem->GetName().c_str() , nImage);
				if(-1 != nItem)
				{
					ListCtrl.SetItemData(nItem , DWORD_PTR(pLoadItem));

					double nRatingCapacity = 0.f;
					pLoadItem->CalcRatingCapacity(nRatingCapacity);
					
					ostringstream oss;
					oss << nRatingCapacity;
					ListCtrl.SetItemText(nItem , 1 , oss.str().c_str());
					

					////////////////
					map<CELoadItem*,string>::iterator where = m_LoadRouteGroupMap.find(pLoadItem);
					if(where != m_LoadRouteGroupMap.end())
					{
						ListCtrl.SetItemText(nItem , 2 , rLocationArea.c_str());

						if(rRouteGroup != where->second)
						{
							ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
							ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
							ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
						}
						else
						{
							ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
							ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
							ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
						}
					}
				}
			}
		}
		ListCtrl.SetRedraw(TRUE);
		ListCtrl.RedrawItems(0 , ListCtrl.GetItemCount());
	}
	
	return ERROR_SUCCESS;
}
예제 #22
0
int WaveOutput::Open(int32_t rate, uint32_t chn, int32_t bits, int32_t bufferlenms, int32_t prebufferms)
{
	//int8_t	str[256];
	int32_t	error,i;


	if (chn>2) return -1;						//No more than stereo

	if (open) Close();						//Verify device was closed

	//if (cfg.changed)	{
		blk.num=4;//cfg.numBlk;
		blk.min=2*1024;//cfg.minBlk*1024;
		blk.max=64*1024;//cfg.maxBlk*1024;
    SafeDeleteArray(&buffer.pOut);
    buffer.pOut= new uint8_t[(blk.num * blk.max)];
  //}

	//Build format structure -------------------
	wav.fmt.Format.wFormatTag				= WAVE_FORMAT_EXTENSIBLE;
	wav.fmt.Format.nChannels				= chn;
	wav.fmt.Format.nSamplesPerSec			= rate;
	wav.fmt.Format.wBitsPerSample			= (bits+7)&~7;		//Round bits per sample up to nearest byte
	wav.fmt.Format.nBlockAlign			= chn * wav.fmt.Format.wBitsPerSample>>3;
	wav.fmt.Format.nAvgBytesPerSec		= wav.fmt.Format.nBlockAlign * wav.fmt.Format.nSamplesPerSec;
	wav.fmt.Format.cbSize					= 22;
	wav.fmt.Samples.wValidBitsPerSample	= bits;
	wav.fmt.dwChannelMask					= chn==2 ? 3 : 4;	//Select left & right (stereo) or center (mono)
	wav.fmt.SubFormat						= KSDATAFORMAT_SUBTYPE_PCM;

  int cfbufferLen = 2000;
	//Check size of ring buffer ----------------
	buffer.size=(wav.fmt.Format.nSamplesPerSec *
				wav.fmt.Format.nBlockAlign * 
				cfbufferLen) / 1000;

	if (buffer.asize < buffer.size)				//If allocated size is less than needed size
	{
		//buffer.pIn=realloc(buffer.pIn,buffer.size);
    SafeDeleteArray(&buffer.pIn);
    buffer.pIn = new uint8_t[buffer.size];
		buffer.asize=buffer.size;
	}

	//Open audio device ------------------------
  int cfg_direct = 0;//WAVE_FORMAT_DIRECT
	error=waveOutOpen(&wav.handle,device,(tWAVEFORMATEX*)&wav.fmt,DWORD_PTR(WaveOutDone),DWORD_PTR(this),CALLBACK_FUNCTION|WAVE_ALLOWSYNC|cfg_direct);
	switch (error)
	{
	case(MMSYSERR_NOERROR):
		wav.idle=(uint32_t)~0>>(32-blk.num);		//All blocks are free

		//Initialize wave blocks ---------------
		for (i=0;i<blk.num;i++)
		{
			memset(&wav.hdr[i],0,sizeof(WAVEHDR));

			wav.hdr[i].lpData=(LPSTR)buffer.pOut+(blk.max*i);
			wav.hdr[i].dwBufferLength=blk.max;
			waveOutPrepareHeader(wav.handle,&wav.hdr[i],sizeof(WAVEHDR));

			wav.hdr[i].dwBufferLength=0;
			wav.hdr[i].dwUser=(DWORD_PTR)(1<<i);			//Bit corresponding to block
			wav.hdr[i].dwFlags|=WHDR_DONE;
		}

		memset(&wav.time,0,sizeof(MMTIME));
		wav.time.wType=TIME_SAMPLES;
		wav.samples=0;
		wav.smpCnt=0;

		buffer.bytes=0;							//No bytes have been written

		buffer.length=0;							//Nothing is in input buffer
		buffer.queued_length=0;
		buffer.write=0;
		buffer.read=0;

		blk.cnt=0;
		blk.size=0;

		paused=0;								//Output isn't paused
		open=1;								//Device is open

		return ((buffer.size / wav.fmt.Format.nBlockAlign) * 1000) / wav.fmt.Format.nSamplesPerSec;

	case(MMSYSERR_ALLOCATED):
		//sprintf(str,"%s is already in use",wav.cap.szPname);
		//MessageBox(outMod.hMainWindow,str,"WaveOut WDM",MB_ICONERROR|MB_OK);
		break;

	case(MMSYSERR_BADDEVICEID):
		//sprintf(str,"Invalid output device ID [%i].  Check your configuration.",cfg.device);
		//MessageBox(outMod.hMainWindow,str,"WaveOut WDM",MB_ICONERROR|MB_OK);
		break;

	case(MMSYSERR_NODRIVER):
		//sprintf(str,"No driver is loaded for %s",wav.cap.szPname);
		//MessageBox(outMod.hMainWindow,str,"WaveOut WDM",MB_ICONERROR|MB_OK);
		break;

	case(MMSYSERR_NOMEM):
		//MessageBox(outMod.hMainWindow,"Unable to allocate memory for output device","WaveOut WDM",MB_ICONERROR|MB_OK);
		break;

	case(WAVERR_BADFORMAT):
		//MessageBox(outMod.hMainWindow,"The extensible format is not supported by your driver.  Get the WDM drivers for your soundcard.","WaveOut WDM",MB_ICONERROR|MB_OK);
		break;

	default:
		//sprintf(str,"Unknown error [%i] trying to open output device %s",error,wav.cap.szPname);
		//MessageBox(outMod.hMainWindow,str,"WaveOut WDM",MB_ICONERROR|MB_OK);
    break;
	}

	return S_FALSE;
}
예제 #23
0
/**
	@brief	Bus ID를 가진 Load를 표시한다.

	@author BHK	

	@date 2009-04-11 오전 9:06:00	

	@param	

	@return		
**/
int CAssignLoadToBusDlg::DisplayLoadInBus(CMFCTextColorListCtrl& ListCtrl , const string& rBusID , const string& rInterestingArea)
{
	CItemSelectionSet SelectionSet;
	CELoadDocData& docData = CELoadDocData::GetInstance();
	docData.GetLoadItemSetInBus(SelectionSet , rBusID);

	ListCtrl.SetRedraw(FALSE);
	ListCtrl.DeleteAllItems();
	ListCtrl.m_ItemColorMap.clear();
	for(int i = 0;i < SelectionSet.GetItemCount();++i)
	{
		CLoadItem* pLoadItem = static_cast<CLoadItem*>(SelectionSet.GetItemAt(i));
		if(pLoadItem)
		{
			CELoadItemProp *pItemProp = pLoadItem->prop();
			const string rArea = pItemProp->GetValue(_T("Location") , _T("Area"));
			if((_T("*") != rInterestingArea) && (rArea != rInterestingArea)) continue;
			
			const int nImage = docData.GetIconNo(pLoadItem);
			const int nItem = ListCtrl.InsertItem(0 , pLoadItem->GetName().c_str() , nImage);
			if(-1 != nItem)
			{
				ListCtrl.SetItemData(nItem , DWORD_PTR(pLoadItem));

				//! 2011.01.25 - added by HumKyung
				const string sRatedVoltage = pItemProp->GetValue(_T("Rating") , _T("Rated Voltage"));
				ListCtrl.SetItemText(nItem , 1 , sRatedVoltage.c_str());
				//! 

				double nRatingCapacity = 0.f;
				pLoadItem->CalcRatingCapacity(nRatingCapacity);
				
				ostringstream oss;
				oss << nRatingCapacity;
				ListCtrl.SetItemText(nItem , 2 , oss.str().c_str());
				
				map<CELoadItem*,BusInfo>::iterator where = m_LoadBusInfoMap.find(pLoadItem);
				if(where != m_LoadBusInfoMap.end())
				{
					ListCtrl.SetItemText(nItem , 3 , where->second.rBusID.c_str());

					if(pLoadItem->GetBusId() != where->second.rBusID)
					{
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(255,0,0));
					}
					else
					{
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
						ListCtrl.m_ItemColorMap[DWORD_PTR(pLoadItem)].push_back(RGB(0,0,0));
					}
				}
			}
		}
	}
	ListCtrl.SetRedraw(TRUE);
	ListCtrl.RedrawItems(0 , m_wndLoadListCtrl.GetItemCount());
	
	return ERROR_SUCCESS;
}
BOOL CPasskeyEntry::OnInitDialog(void)
{
  CPKBaseDlg::OnInitDialog();

  Fonts::GetInstance()->ApplyPasswordFont(GetDlgItem(IDC_PASSKEY));
  m_pctlPasskey->SetPasswordChar(PSSWDCHAR);

  switch(m_index) {
    case GCP_FIRST:
      // At start up - give the user the option unless file is R-O
      GetDlgItem(IDC_READONLY)->EnableWindow(m_bForceReadOnly ? FALSE : TRUE);
      GetDlgItem(IDC_READONLY)->ShowWindow(SW_SHOW);
      GetDlgItem(IDC_VERSION)->SetWindowText(m_appversion);
      break;
    case GCP_NORMAL:
      // otherwise during open - user can - again unless file is R-O
      if (m_bHideReadOnly) {
        GetDlgItem(IDC_READONLY)->EnableWindow(FALSE);
        GetDlgItem(IDC_READONLY)->ShowWindow(SW_HIDE);
      } else {
        GetDlgItem(IDC_READONLY)->EnableWindow(m_bForceReadOnly ? FALSE : TRUE);
        GetDlgItem(IDC_READONLY)->ShowWindow(SW_SHOW);
      }
      break;
    case GCP_RESTORE:
    case GCP_WITHEXIT:
      GetDlgItem(IDC_READONLY)->EnableWindow(m_bForceReadOnly ? FALSE : TRUE);
      GetDlgItem(IDC_READONLY)->ShowWindow(SW_SHOW);
      break;
    case GCP_CHANGEMODE:
      GetDlgItem(IDC_READONLY)->EnableWindow(FALSE);
      GetDlgItem(IDC_READONLY)->ShowWindow(SW_HIDE);
      break;
    default:
      ASSERT(FALSE);
  }

  // Only show virtual Keyboard menu if we can load DLL
  if (!CVKeyBoardDlg::IsOSKAvailable()) {
    GetDlgItem(IDC_VKB)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_VKB)->EnableWindow(FALSE);
  }

  if (m_index == GCP_FIRST) {
    GetDlgItem(IDC_SELECTED_DATABASE)->ShowWindow(SW_HIDE);

    CRecentFileList *mru = app.GetMRU();
    ASSERT(mru != NULL);

    int N = mru->GetSize();

    std::vector<CSecString> cs_tooltips;

    if (!m_filespec.IsEmpty()) {
      cs_tooltips.push_back(m_filespec);
      m_MRU_combo.AddString(NarrowPathText(m_filespec));
      m_MRU_combo.SelectString(-1, NarrowPathText(m_filespec));
      m_MRU_combo.SetItemData(0, DWORD_PTR(-1));
    }

    for (int i = 0; i < N; i++) {
      const CString &str = (*mru)[i];
      if (str != m_filespec && !str.IsEmpty()) {
        cs_tooltips.push_back(str);
        int li = m_MRU_combo.AddString(NarrowPathText(str));
        if (li != CB_ERR && li != CB_ERRSPACE)
          m_MRU_combo.SetItemData(li, i);
      }
    }
    if ((N > 0) || !m_filespec.IsEmpty()) {
      // Add an empty row to allow NODB
      int li = m_MRU_combo.AddString(L"");
      if (li != CB_ERR && li != CB_ERRSPACE) {
        m_MRU_combo.SetItemData(li, DWORD_PTR(-2)); // -1 already taken, but a < 0 value is easier to check than N
        CString cs_empty(MAKEINTRESOURCE(IDS_EMPTY_DB));
        cs_tooltips.push_back(cs_empty);
        N++; // for SetHeight
      }
    }

    if (N > 0) {
      SetHeight(N);
    }

    m_MRU_combo.SetToolTipStrings(cs_tooltips);
  }

  /*
   * this bit makes the background come out right on the bitmaps
   */

  if (m_index == GCP_FIRST) {
    m_ctlLogoText.ReloadBitmap(IDB_PSLOGO);
    m_ctlLogo.ReloadBitmap(IDB_CLOGO);
  } else {
    m_ctlLogo.ReloadBitmap(IDB_CLOGO_SMALL);
  }

  // Set the icon for this dialog.  The framework does this automatically
  //  when the application's main window is not a dialog

  SetIcon(m_hIcon, TRUE);  // Set big icon
  SetIcon(m_hIcon, FALSE); // Set small icon

  if (app.WasHotKeyPressed()) {
    // Reset it
    app.SetHotKeyPressed(false);
    // Following (1) brings to top when hotkey pressed,
    // (2) ensures focus is on password entry field, where it belongs.
    // This is "stronger" than BringWindowToTop().
    SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    SetActiveWindow();
    SetForegroundWindow();
    m_pctlPasskey->SetFocus();
    return FALSE;
  }

  // Following works fine for other (non-hotkey) cases:
  SetForegroundWindow();

  // If the dbase field's !empty, the user most likely will want to enter
  // a password:
  if (m_index == GCP_FIRST && !m_filespec.IsEmpty()) {
    m_MRU_combo.SetEditSel(-1, -1);
    m_pctlPasskey->SetFocus();
    return FALSE;
  }

  return TRUE;
}
예제 #25
0
static void initialize_hardware_concurrency_info () {
    dynamic_link( GetModuleHandleA( "Kernel32.dll" ), ProcessorGroupsApiLinkTable,
                  sizeof(ProcessorGroupsApiLinkTable)/sizeof(dynamic_link_descriptor) );
    SYSTEM_INFO si;
    GetSystemInfo(&si);
    DWORD_PTR pam, sam, m = 1;
    GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam );
    int nproc = 0;
    for ( size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) {
        if ( pam & m )
            ++nproc;
    }
    __TBB_ASSERT( nproc <= (int)si.dwNumberOfProcessors, NULL );
    if ( nproc == (int)si.dwNumberOfProcessors && TBB_GetMaximumProcessorCount ) {
        // The process does not have restricting affinity mask and multiple processor groups are possible
        ProcessorGroupInfo::NumGroups = (int)TBB_GetMaximumProcessorGroupCount();
        __TBB_ASSERT( ProcessorGroupInfo::NumGroups <= MaxProcessorGroups, NULL );
        // Fail safety bootstrap. Release versions will limit available concurrency
        // level, while debug ones would assert.
        if ( ProcessorGroupInfo::NumGroups > MaxProcessorGroups )
            ProcessorGroupInfo::NumGroups = MaxProcessorGroups;
        if ( ProcessorGroupInfo::NumGroups > 1 ) {
            TBB_GROUP_AFFINITY ga;
            if ( TBB_GetThreadGroupAffinity( GetCurrentThread(), &ga ) )
                ProcessorGroupInfo::HoleIndex = ga.Group;
            int nprocs = 0;
            for ( WORD i = 0; i < ProcessorGroupInfo::NumGroups; ++i ) {
                ProcessorGroupInfo  &pgi = theProcessorGroups[i];
                pgi.numProcs = (int)TBB_GetMaximumProcessorCount(i);
                __TBB_ASSERT( pgi.numProcs <= (int)sizeof(DWORD_PTR) * CHAR_BIT, NULL );
                pgi.mask = pgi.numProcs == sizeof(DWORD_PTR) * CHAR_BIT ? ~(DWORD_PTR)0 : (DWORD_PTR(1) << pgi.numProcs) - 1;
                pgi.numProcsRunningTotal = nprocs += pgi.numProcs;
            }
            __TBB_ASSERT( nprocs == (int)TBB_GetMaximumProcessorCount( TBB_ALL_PROCESSOR_GROUPS ), NULL );
            return;
        }
    }
    // Either the process has restricting affinity mask or only a single processor groups is present
    theProcessorGroups[0].numProcs = theProcessorGroups[0].numProcsRunningTotal = nproc;

    PrintExtraVersionInfo("Processor groups", "%d", ProcessorGroupInfo::NumGroups);
    if (ProcessorGroupInfo::NumGroups>1)
        for (int i=0; i<ProcessorGroupInfo::NumGroups; ++i)
            PrintExtraVersionInfo( "----- Group", "%d: size %d", i, theProcessorGroups[i].numProcs);
}
예제 #26
0
파일: FileView.cpp 프로젝트: DimaKirk/rrr3d
void CFileView::SetItemData(HTREEITEM item, ItemData* value)
{
	LSL_ASSERT(item);

	m_wndFileView.SetItemData(item, DWORD_PTR(value));
}