Пример #1
0
/*
    A font is currently selected at index.
    Get the string associated with that index.
    Enumerate the fonts again.
    Find the same string in the newly enumerated list, if it exists.
    If all goes well return the new index and font handle.
    If the font disappeared return RetryNotFound and
    the index and font handle are garbage.
    If something else goes wrong, return RetryFailure and
    the index and font handle are garbage.

*/
enum RetryStati RetryAndSelectString(HWND hwnd,
                                            int  *lpIndex,
                                            HCOMPONENT *lphFontHandle)
{
	LPTSTR lpszSelectedString;
	int   length;

	// Save away the name of the selected
	// font so we can find it in the new list.
	// It is possible for the name to be good
	// but the handle to be bad.

	if ((length = ListBox_GetTextLen(hwnd, *lpIndex)) IS LB_ERR)
		// length contains the length of the string in characters
	{
		return RetryFailure;
	}

	lpszSelectedString = (LPTSTR) HP_GLOBAL_ALLOC_DLL((length + 1) * sizeof(TCHAR));
	if (lpszSelectedString IS NULL)
	{
		return RetryFailure;
	}

	if (LB_ERR IS ListBox_GetText(hwnd, *lpIndex, lpszSelectedString))
	{
		HP_GLOBAL_FREE(lpszSelectedString);
		return RetryFailure;
	}

	// Enumerate again

	GetFontListAndDisplay(hDisk);

	// Try to find the previously selected string
	// in the new enumeration.

	*lpIndex = ListBox_FindStringExact(hwnd, 0, lpszSelectedString);
	if (*lpIndex IS LB_ERR)
	{
		HP_GLOBAL_FREE(lpszSelectedString);
		return RetryNotFound;
	} // *lpIndex = ListBox_FindStringExact

	// Select the new item
	// and get the new handle for the selected item.

	ListBox_SetCurSel(hwnd, *lpIndex);
 	if (!(*lphFontHandle =
	     (HCOMPONENT)ListBox_GetItemData(hwnd, *lpIndex)))
	{
		HP_GLOBAL_FREE(lpszSelectedString);
		return RetryFailure;
	}

	HP_GLOBAL_FREE(lpszSelectedString);
	return RetrySuccess;

} // RetryAndSelectString
Пример #2
0
int wxListBox::FindString(const wxString& s) const
{
    int pos = ListBox_FindStringExact(GetHwnd(), (WPARAM)-1, s);
    if (pos == LB_ERR)
        return wxNOT_FOUND;
    else
        return pos;
}
Пример #3
0
int wxListBox::FindString(const wxString& s, bool bCase) const
{
    // back to base class search for not native search type
    if (bCase)
       return wxItemContainerImmutable::FindString( s, bCase );

    int pos = ListBox_FindStringExact(GetHwnd(), -1, s.wx_str());
    if (pos == LB_ERR)
        return wxNOT_FOUND;
    else
        return pos;
}
Пример #4
0
VOID Dlg_PopulateModuleList(HWND hwnd) {

   HWND hwndModuleHelp = GetDlgItem(hwnd, IDC_MODULEHELP);
   ListBox_ResetContent(hwndModuleHelp);

   CToolhelp thProcesses(TH32CS_SNAPPROCESS);
   PROCESSENTRY32 pe = { sizeof(pe) };
   BOOL fOk = thProcesses.ProcessFirst(&pe);
   for (; fOk; fOk = thProcesses.ProcessNext(&pe)) {

      CToolhelp thModules(TH32CS_SNAPMODULE, pe.th32ProcessID);
      MODULEENTRY32 me = { sizeof(me) };
      BOOL fOk = thModules.ModuleFirst(&me);
      for (; fOk; fOk = thModules.ModuleNext(&me)) {
        int n = ListBox_FindStringExact(hwndModuleHelp, -1, me.szExePath);
         if (n == LB_ERR) {
            // This module hasn't been added before
            ListBox_AddString(hwndModuleHelp, me.szExePath);
         }
      }
   }

   HWND hwndList = GetDlgItem(hwnd, IDC_PROCESSMODULELIST);
   SetWindowRedraw(hwndList, FALSE);
   ComboBox_ResetContent(hwndList);
   int nNumModules = ListBox_GetCount(hwndModuleHelp);
   for (int i = 0; i < nNumModules; i++) {
      TCHAR sz[1024];
      ListBox_GetText(hwndModuleHelp, i, sz);
      // Place module name (without its path) in the list
      int nIndex = ComboBox_AddString(hwndList, _tcsrchr(sz, TEXT('\\')) + 1);
      // Associate the index of the full path with the added item
      ComboBox_SetItemData(hwndList, nIndex, i);
   }

   ComboBox_SetCurSel(hwndList, 0);  // Select the first entry

   // Simulate the user selecting this first item so that the
   // results pane shows something interesting
   FORWARD_WM_COMMAND(hwnd, IDC_PROCESSMODULELIST, 
      hwndList, CBN_SELCHANGE, SendMessage);

   SetWindowRedraw(hwndList, TRUE);
   InvalidateRect(hwndList, NULL, FALSE);
}
Пример #5
0
bool ListBox::AddStringUnique(LPCWSTR str)
{
    int index = ListBox_FindStringExact(ThisWindow, -1, str);

    if (index != LB_ERR)
    {
        WCHAR buffer[MAX_STR];
        GetString(index, buffer);
        if (!lstrcmp(buffer, str))
            return false;
    }

    if (index == LB_ERR && !lstrlen(str))
        return false;

    AddString(str);
    return true;
}
Пример #6
0
void perform(HWND hDlg, HWND hList, HWND hEditList,Plane::PlaneDirection direction
			 //,CountPlanesFunc cpf,LandOrLiftPlanesFunc lolpf,
			 )
{
	Plane * plane = gestor->criarAviaoPara(direction);
	ListBox_AddString(hList,plane->GetName());
	//_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10);
	loadIntoBufferPlanesCount(direction);
	
	Edit_SetText(hEditList,buffer);
	
	plane = executeLandOrListFunction(direction);
	
	EnterCriticalSection(&csDelFromLB);
	ListBox_DeleteString(hList,ListBox_FindStringExact(hList,0,plane->GetName()));
	LeaveCriticalSection(&csDelFromLB);

	//_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10);
	loadIntoBufferPlanesCount(direction);
	Edit_SetText(hEditList,buffer);

	if(!(plane->terminateQuickly()))
	{
		INT * animationEditTexts = getAnimationEditText(plane->_idLane);
		if(plane->GetDirection()==Plane::LAND)
		{
			for (int i=0; i < 26; ++i) {
				doAnimation(plane,hDlg,animationEditTexts[i]);
			}
		}
		else if(plane->GetDirection()==Plane::LIFTOFF)
		{
			for(int i = 25; i>=0;--i)
			{
				doAnimation(plane,hDlg,animationEditTexts[i]);
			}
		}
		gestor->libertarPista(plane);
	}
}
Пример #7
0
BOOL plClothingComponentProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    IParamBlock2 *pb = pm->GetParamBlock();
    HWND hList = GetDlgItem(hWnd, IDC_CLOTHING_LIST);
    HWND hGroup = GetDlgItem(hWnd, IDC_CLOTHING_GROUP);
    HWND hType = GetDlgItem(hWnd, IDC_CLOTHING_TYPE);
    HWND hLOD = GetDlgItem(hWnd, IDC_COMP_LOD_CLOTHING_STATE);
    switch (msg)
    {
    case WM_INITDIALOG:
        {
            ListBox_ResetContent(hList);
            int i;
            for (i = 0; i < pb->Count(plClothingComponent::kMaterials); i++)
                ListBox_AddString(hList, pb->GetMtl(ParamID(plClothingComponent::kMaterials), 0, i)->GetName());

            ListBox_SetCurSel(hList, -1);

            for (i = 0; i < plClothingMgr::kMaxGroup; i++)
                ComboBox_AddString(hGroup, plClothingMgr::GroupStrings[i]);
            ComboBox_SetCurSel(hGroup, pb->GetInt(plClothingComponent::kGroup));

            for (i = 0; i < plClothingMgr::kMaxType; i++)
                ComboBox_AddString(hType, plClothingMgr::TypeStrings[i]);
            ComboBox_SetCurSel(hType, pb->GetInt(plClothingComponent::kType));

            ComboBox_AddString(hLOD, "High");
            ComboBox_AddString(hLOD, "Medium");
            ComboBox_AddString(hLOD, "Low");
            ComboBox_SetCurSel(hLOD, pb->GetInt(plClothingComponent::kLODState));
        }
        return TRUE;


    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_CLOTHING_ADD)
            {
                Mtl *pickedMtl = plPickMaterialMap::PickMaterial(plMtlCollector::kClothingMtlOnly);
                if (pickedMtl != nil)
                {
                    LRESULT stringIdx = ListBox_FindStringExact(hList, -1, pickedMtl->GetName());
                    if (stringIdx == LB_ERR) // It's not already there, go and add it
                    {
                        pb->Append(ParamID(plClothingComponent::kMaterials), 1, &pickedMtl, 0);
                        ListBox_AddString(hList, pickedMtl->GetName());
                    }
                }
                return TRUE;
            }
            // Remove the currently selected material
            else if (LOWORD(wParam) == IDC_CLOTHING_REMOVE)
            {
                int sel = ListBox_GetCurSel(hList);
                if (sel != LB_ERR)
                {
                    pb->Delete(plClothingComponent::kMaterials, sel, 1);
                    ListBox_DeleteString(hList, sel);
                }
                return TRUE;
            }
            else if( LOWORD( wParam ) == IDC_CLOTHING_CLEARMESH )
            {
                int state = pb->GetInt(plClothingComponent::kLODState);
                pb->SetValue(plClothingComponent::kMeshNodeTab, 0, (INode*)nil, state );
                pb->Reset(plClothingComponent::kMeshNodeAddBtn);
            }
        }
        else if (LOWORD(wParam) == IDC_CLOTHING_GROUP)
        {
            int setIdx = ComboBox_GetCurSel(hGroup);
            pb->SetValue(plClothingComponent::kGroup, 0, setIdx);

            return TRUE;
        }
        else if (LOWORD(wParam) == IDC_CLOTHING_TYPE)
        {
            int setIdx = ComboBox_GetCurSel(hType);
            pb->SetValue(plClothingComponent::kType, 0, setIdx);

            return TRUE;
        }
        else
        {
            int state = pb->GetInt(plClothingComponent::kLODState);
                
            INode *node = pb->GetINode(plClothingComponent::kMeshNodeAddBtn);
            if (node)
                pb->SetValue(plClothingComponent::kMeshNodeTab, 0, node, state);

            if(LOWORD(wParam) == IDC_COMP_LOD_CLOTHING_STATE && HIWORD(wParam) == CBN_SELCHANGE)
            {
                int idx = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
                pb->SetValue(plClothingComponent::kLODState, 0, idx);
            
                node = pb->GetINode(plClothingComponent::kMeshNodeTab, 0, idx);
                if (node)
                    pb->SetValue(plClothingComponent::kMeshNodeAddBtn, 0, node);
                else
                    pb->Reset(plClothingComponent::kMeshNodeAddBtn);

                return TRUE;
            }
        }
    }

    return FALSE;
}