Ejemplo n.º 1
0
void w32g_rotate_playlist(int dest)
{
    int i, i1, i2;
    HWND hListBox;
    PlayListEntry save;
	char temp[1024];

    if(playlist.nfiles == 0)
	return;
    if(!(hListBox = playlist_box()))
	return;

    i1 = ListBox_GetCurSel(hListBox);
    i2 = playlist.nfiles - 1;
    if(i1 >= i2)
	return;

#ifdef W32G_RANDOM_IS_SHUFFLE
	w32g_shuffle_playlist_rotate(dest,i1,i2);
#endif
    if(dest > 0)
    {
	save = playlist.list[i2];
	for(i = i2; i > i1; i--) /* i: i2 -> i1 */
	    playlist.list[i] = playlist.list[i - 1];
	playlist.list[i] = save;
	ListBox_GetText(hListBox,i2,temp);
    ListBox_DeleteString(hListBox,i2);
    ListBox_InsertString(hListBox,i1,temp);
	ListBox_SetCurSel(hListBox,i1);
	if(playlist.selected == i2){
	    playlist.selected = i1;
		w32g_update_playlist_pos(playlist.selected);
	} else if(i1 <= playlist.selected && playlist.selected < i2){
	    playlist.selected++;
		w32g_update_playlist_pos(playlist.selected);
	}
    }
    else
    {
	save = playlist.list[i1];
	for(i = i1; i < i2; i++) /* i: i1 -> i2 */
	    playlist.list[i] = playlist.list[i + 1];
	playlist.list[i] = save;
	ListBox_GetText(hListBox,i1,temp);
    ListBox_DeleteString(hListBox,i1);
    ListBox_InsertString(hListBox,-1,temp);
	ListBox_SetCurSel(hListBox,i1);
	if(playlist.selected == i1){
	    playlist.selected = i2;
		w32g_update_playlist_pos(playlist.selected);
	} else if(i1 < playlist.selected && playlist.selected <= i2){
	    playlist.selected--;    
		w32g_update_playlist_pos(playlist.selected);
	}
    }
}
Ejemplo n.º 2
0
    void IAddUserType(HWND hList)
    {
        int type = fPB->GetInt(fTypeID);

        int idx = ListBox_AddString(hList, kUseParamBlockNodeString);
        if (type == plAnimObjInterface::kUseParamBlockNode && !fPB->GetINode(fNodeParamID))
            ListBox_SetCurSel(hList, idx);


        idx = ListBox_AddString(hList, kUseOwnerNodeString);
        if (type == plAnimObjInterface::kUseOwnerNode)
            ListBox_SetCurSel(hList, idx);
    }
Ejemplo n.º 3
0
/*
** Updates the list of skins.
**
*/
void DialogAbout::TabSkins::UpdateSkinList()
{
	// Delete all entries
	HWND item = GetControl(Id_SkinsListBox);
	ListBox_ResetContent(item);

	// Add entries for each skin
	std::wstring::size_type maxLength = 0;
	const std::map<std::wstring, Skin*>& windows = GetRainmeter().GetAllSkins();
	std::map<std::wstring, Skin*>::const_iterator iter = windows.begin();
	bool found = false;
	for ( ; iter != windows.end(); ++iter)
	{
		const std::wstring& skinName = (*iter).first;
		std::wstring::size_type curLength = skinName.length();
		if (curLength > maxLength)
		{
			maxLength = curLength;
		}
		
		const WCHAR* name = skinName.c_str();
		int index = ListBox_AddString(item, name);
		if (!found && m_SkinWindow == (*iter).second)
		{
			found = true;
			m_SkinWindow = (*iter).second;
			ListBox_SetCurSel(item, index);
		}
	}

	ListBox_SetHorizontalExtent(item, 6 * maxLength);

	if (!found)
	{
		if (windows.empty())
		{
			m_SkinWindow = nullptr;
			item = GetControl(Id_ItemsListView);
			ListView_DeleteAllItems(item);
		}
		else
		{
			// Default to first skin
			m_SkinWindow = (*windows.begin()).second;
			ListBox_SetCurSel(item, 0);
			UpdateMeasureList(m_SkinWindow);
		}
	}
}
Ejemplo n.º 4
0
/*
** Updates the list of skins.
**
*/
void CDialogAbout::CTabSkins::UpdateSkinList()
{
	// Delete all entries
	HWND item = GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTBOX);
	ListBox_ResetContent(item);

	// Add entries for each skin
	std::wstring::size_type maxLength = 0;
	const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
	std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
	bool found = false;
	for ( ; iter != windows.end(); ++iter)
	{
		const std::wstring& skinName = (*iter).first;
		std::wstring::size_type curLength = skinName.length();
		if (curLength > maxLength)
		{
			maxLength = curLength;
		}
		
		const WCHAR* name = skinName.c_str();
		int index = ListBox_AddString(item, name);
		if (!found && m_SkinWindow == (*iter).second)
		{
			found = true;
			m_SkinWindow = (*iter).second;
			ListBox_SetCurSel(item, index);
		}
	}

	ListBox_SetHorizontalExtent(item, 6 * maxLength);

	if (!found)
	{
		if (windows.empty())
		{
			m_SkinWindow = NULL;
			item = GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTVIEW);
			ListView_DeleteAllItems(item);
		}
		else
		{
			// Default to first skin
			m_SkinWindow = (*windows.begin()).second;
			ListBox_SetCurSel(item, 0);
			UpdateMeasureList(m_SkinWindow);
		}
	}
}
void plResponderProc::MoveCommand(int oldIdx, int newIdx)
{
    // Move data
    int insertIdx = (newIdx > oldIdx) ? newIdx+1 : newIdx;
    int deleteIdx = (newIdx < oldIdx) ? oldIdx+1 : oldIdx;

    ReferenceTarget *targ = fStatePB->GetReferenceTarget(kStateCmdParams, 0, oldIdx);
    fStatePB->Insert(kStateCmdParams, insertIdx, 1, &targ);
    fStatePB->Delete(kStateCmdParams, deleteIdx, 1);

    ReferenceTarget *wait = fStatePB->GetReferenceTarget(kStateCmdWait, 0, oldIdx);
    fStatePB->Insert(kStateCmdWait, insertIdx, 1, &wait);
    fStatePB->Delete(kStateCmdWait, deleteIdx, 1);

    BOOL oldEnabled = fStatePB->GetInt(kStateCmdEnabled, 0, oldIdx);
    BOOL newEnabled = fStatePB->GetInt(kStateCmdEnabled, 0, newIdx);
    fStatePB->SetValue(kStateCmdEnabled, 0, oldEnabled, newIdx);
    fStatePB->SetValue(kStateCmdEnabled, 0, newEnabled, oldIdx);

    ResponderWait::CmdMoved(fStatePB, oldIdx, newIdx);

    LoadList();

    // Reselect item
    // (This doesn't send the LBN_SELCHANGE message so we do that manually)
    ListBox_SetCurSel(fhList, newIdx);
    ICreateCmdRollups();
}
Ejemplo n.º 6
0
static void update_disasm(HWND hwnd)
{
	SCROLLINFO si;
	int i,highlight = -1;
	char str[128];
	HWND hctrl = GetDlgItem(hwnd,IDC_DISASMLIST);
	u32 p = pc;

	//clear listbox
	ListBox_ResetContent(hctrl);

	//draw lines
	for(i=0;i<29;i++) {
		memset(str,0,128);
		sprintf(str,"%04X:\t",p);
		if(nes->cpu.pc == p)
			highlight = i;
		p = cpu_disassemble(&str[6],p);
		str[14] = '\t';
		str[18] = '\t';
		ListBox_AddString(hctrl,str);
	}
	if(highlight >= 0)
		ListBox_SetCurSel(hctrl,highlight);
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_POS;
	si.nPos = pc;
	SetScrollInfo(GetDlgItem(hwnd,IDC_DISASMSCROLL),SB_CTL,&si,TRUE);
}
Ejemplo n.º 7
0
void AppendLog(char* str) {
	HWND list = GetDlgItem(ghWndOutput, IDC_LST_OUTPUT);

	ListBox_InsertString(list, -1,str);
	ListBox_SetCurSel(list, ListBox_GetCount(list) - 1);
	SetFocus(list);
}
Ejemplo n.º 8
0
BOOL ViewItems_OnInitDialog( HWND hwnd, HWND hwndFocus, LPARAM lParam )
{
  INT i;
  HWND hwndCtrl;

  hwndCtrl = GetDlgItem( hwnd, IDC_ITEM_LIST );

  for( i = 0; i < po->nItems; ++i )
  {
    ListBox_AddString( hwndCtrl, po->pItemData[i].item_name );
  }

  ListBox_SetCurSel( hwndCtrl, 0 );

  hwndCtrl = GetDlgItem( hwnd, IDC_ITEM_TYPE );
  Static_SetText( hwndCtrl, GetItemTypeString( po->pItemData[0].item_type ) );

  hwndCtrl = GetDlgItem( hwnd, IDC_ITEM_PIXEL_SIZE );
  Edit_LimitText( hwndCtrl, 8 );

  ViewItems_ItemChanged( hwnd );

  AllDialogs_OnInitDialog( hwnd, hwndFocus, lParam );

  return TRUE;

} // ViewItems_OnInitDialog
void plResponderProc::AddCommand()
{
    RECT rect;
    GetWindowRect(GetDlgItem(fhDlg, IDC_ADD_CMD), &rect);

    // Create the popup menu and get the option the user selects
    SetForegroundWindow(fhDlg);
    int type = TrackPopupMenu(fhMenu, TPM_RIGHTALIGN | TPM_NONOTIFY | TPM_RETURNCMD, rect.left, rect.top, 0, fhDlg, NULL);
    PostMessage(fhDlg, WM_USER, 0, 0);

    if (type == 0)
        return;

    CmdID& cmdID = fMenuCmds[type];
    plResponderCmd *cmd = cmdID.first;
    int cmdIdx = cmdID.second;

    IParamBlock2 *cmdPB = cmd->CreatePB(cmdIdx);
    fStatePB->Append(kStateCmdParams, 1, (ReferenceTarget**)&cmdPB);

    IParamBlock2 *waitPB = ResponderWait::CreatePB();
    fStatePB->Append(kStateCmdWait, 1, (ReferenceTarget**)&waitPB);

    BOOL enabled = TRUE;
    fStatePB->Append(kStateCmdEnabled, 1, &enabled);

    const char* name = GetCommandName(fStatePB->Count(kStateCmdParams)-1);
    int idx = ListBox_AddString(fhList, name);
    ListBox_SetCurSel(fhList, idx);

    ICreateCmdRollups();
}
Ejemplo n.º 10
0
BOOL ViewMarks_OnInitDialog( HWND hwnd, HWND hwndFocus, LPARAM lParam )
{
  INT i;
  HWND hwndCtrl;

  hwndCtrl = GetDlgItem( hwnd, IDC_MARK_LIST );

  for( i = 0; i < pLevel->nMarks; ++i )
  {
    ListBox_AddString( hwndCtrl, pLevel->pMarkData[i].mark_name );
  }

  if (pLevel->nLastMark < 0 || pLevel->nLastMark >= pLevel->nMarks)
  {
    pLevel->nLastMark = -1;
  }

  if (pLevel->nMarks > 0)
  {
    ListBox_SetCurSel( hwndCtrl, pLevel->nLastMark );
  }

  AllDialogs_OnInitDialog( hwnd, hwndFocus, lParam );

  return TRUE;

} // ViewMarks_OnInitDialog
Ejemplo n.º 11
0
/* 
 * LookListSetContents: Set contents & highlight of list box in Look dialog.
 */
void LookListSetContents(HWND hwndListBox, list_type contents, int flags)
{
   list_type l;
   object_node *obj;
   
   WindowBeginUpdate(hwndListBox);
   ListBox_ResetContent(hwndListBox);
   
   /* Fill in list box with stuff from passed-in list */
   for (l = contents; l != NULL; l = l->next)
   {
      /* We need to make a copy of this object, because the original object
         might be freed by the game before this dialog ends */
      obj = ObjectCopy((object_node *) (l->data));
      ItemListAddItem(hwndListBox, obj, -1, !(flags & LD_AMOUNTS));  /* Add to end */
   }
   WindowEndUpdate(hwndListBox);
   
   /* In single selection box, make 1st item default.  In multiple selection,
    * only highlight 1st item if there is just 1 item AND item doesn't need an amount */
   if ((flags & LD_MULTIPLESEL) && contents->next == NULL)
   {
      obj = (object_node *) contents->data;
      if (!(info->flags & LD_AMOUNTS) || !IsNumberObj(obj->id))
      {
         ListBox_SetSel(hwndListBox, TRUE, 0);
         info->selected[0] = True;
      }
   }
   else ListBox_SetCurSel(hwndListBox, 0); 
}
Ejemplo n.º 12
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
Ejemplo n.º 13
0
void w32g_setcur_playlist(void)
{
    HWND hListBox;
    if(!(hListBox = playlist_box()))
	return;
    ListBox_SetCurSel(hListBox, playlist.selected);
	SetNumListWnd(playlist.selected,playlist.nfiles);
}
Ejemplo n.º 14
0
    void IAddUserType(HWND hList)
    {
        int idx = ListBox_AddString(hList, kResponderNodeName);

        int type = fPB->GetInt(fTypeID);
        if (type == kNodeResponder)
            ListBox_SetCurSel(hList, idx);
    }
Ejemplo n.º 15
0
LOCAL void DragEnd(HWND hWindow)
/***********************************************************************/
{
// get the listbox data pointer, if we don't have one, get out
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;

// see if we ever started dragging
if (lpData->fDragging)
	{
	// if we had a cursor, reset it
	if (lpData->hCursor)
		SetCursor(lpData->hOldCursor);
    // do the move if we successfully dragged
    if (lpData->fSuccess) 
    	{
        int nItem, iTopItem;       
        TCHAR szString[256];  
        
		// save the top index, so we can reset it
		iTopItem = ListBox_GetTopIndex(hWindow);
        // turn of painting while working with list
		SetWindowRedraw(hWindow, FALSE);
        // save text of item
		ListBox_GetText(hWindow, lpData->iOldPos, szString);
        
        // delete the item
		ListBox_DeleteString(hWindow, lpData->iOldPos);
             
		// adjust index because of DeleteString
		int iNewPos = lpData->iNewPos;
        if (iNewPos > lpData->iOldPos)
        	iNewPos--;
      	// add the new string at the right spot                       
		nItem = ListBox_InsertString(hWindow, iNewPos, szString);

		// select the item we moved
		DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE);
		if (dwStyle & (LBS_MULTIPLESEL, LBS_EXTENDEDSEL))
	        ListBox_SetSel(hWindow, TRUE, nItem);
		else
	        ListBox_SetCurSel(hWindow, nItem);

		// reset the top index
		ListBox_SetTopIndex(hWindow, iTopItem);
		// turn drawing back on
		SetWindowRedraw(hWindow, TRUE);
		// inform the dialog of the move
		FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
							hWindow, LBN_MOVEITEM, SendMessage);
       	}
   	}
// turn off dragging
lpData->fDragging = FALSE;    
KillTimer(hWindow, lpData->idTimer);    
}
Ejemplo n.º 16
0
int w32g_refine_playlist(int *is_selected_removed)
{
    int nremoved;
    int i, j1, j2, cursel;
    HWND hListBox;

    hListBox = playlist_box();
    if(hListBox)
	cursel = ListBox_GetCurSel(hListBox);
    else
	cursel = -1;

    if(is_selected_removed != NULL)
	*is_selected_removed = 0;
    nremoved = 0;
    j1 = j2 = 0;
    while(j2 < playlist.nfiles) /* j1 <= j2 */
    {
	if(playlist.list[j2].info->format < 0)
	{
	    nremoved++;
	    free(playlist.list[j2].filename);
		if(j2 == playlist.selected &&
		   is_selected_removed != NULL &&
		   !*is_selected_removed)
		{
		    *is_selected_removed = 1;
		    playlist.selected = j1;
		}
		if(j2 < playlist.selected)
		    playlist.selected--;
		if(j2 < cursel)
		    cursel--;
	}
	else
	{
	    playlist.list[j1] = playlist.list[j2];
	    j1++;
	}
	j2++;
    }
    if(nremoved)
    {
	for(i = 0; i < nremoved; i++)
	    ListBox_DeleteString(hListBox, --playlist.nfiles);
	if(cursel >= playlist.nfiles)
	    cursel = playlist.nfiles - 1;
	if(cursel >= 0){
	    ListBox_SetCurSel(hListBox, cursel);
		SetNumListWnd(cursel,playlist.nfiles);
	}
	w32g_update_playlist();
    }
    return nremoved;
}
Ejemplo n.º 17
0
static BOOL OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
{
  HWND hwndIn = (HWND)lParam;
  HWND hwndList = GetDlgItem(hDlg, 100);
  SetProp(hDlg,gsPropName,(HANDLE)hwndIn);
  CenterWindowOnCursor(hDlg);
  FillListBox(hDlg,hwndIn);
  ListBox_SetCurSel(hwndList, 0);
  FORWARD_WM_NEXTDLGCTL(hDlg, hwndList, TRUE, PostMessage);
  return FALSE;
}
Ejemplo n.º 18
0
void AddText(HWND hWndLB, PCTSTR pszFormat, ...) {

   va_list argList;
   va_start(argList, pszFormat);

   TCHAR sz[20 * 1024];
   _vstprintf_s(sz, _countof(sz), pszFormat, argList);
   ListBox_SetCurSel(hWndLB, ListBox_AddString(hWndLB, sz));
   
   va_end(argList);
}
void plResponderProc::LoadList()
{
    ListBox_ResetContent(fhList);

    for (int i = 0; i < fStatePB->Count(kStateCmdParams); i++)
    {
        const char* name = GetCommandName(i);
        ListBox_AddString(fhList, name);
    }

    ListBox_SetCurSel(fhList, -1);
}
Ejemplo n.º 20
0
/*
 * StatsListLButton:  User clicked left button on stats list.
 */
void StatsListLButton(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
   int index;

   SetFocus(hwnd);
   index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd);

   if (index >= ListBox_GetCount(hwnd))
      return;

   ListBox_SetCurSel(hwnd, index);	
}
Ejemplo n.º 21
0
void AddMessage(PCTSTR pszFormat, ...) {

   va_list argList;
   va_start(argList, pszFormat);

   TCHAR szMsg[20 * 1024];
   _vstprintf_s(szMsg, _countof(szMsg), pszFormat, argList);
   HWND hListBox = GetDlgItem(g_hDlg, IDC_LB_STATUS);
   ListBox_SetCurSel(hListBox, ListBox_AddString(hListBox, szMsg));

   va_end(argList);
}
Ejemplo n.º 22
0
void CInstanceInfoWindow::SelectListItem(u32 id)
{
	u32 count = ListBox_GetCount(mInstancesListBox);
	for (u32 i = 0; i < count; i++)
	{
		u32 data = ListBox_GetItemData(mInstancesListBox, i);
		if (data == id)
		{
			ListBox_SetCurSel(mInstancesListBox, i);
			return;
		}
	}
}
Ejemplo n.º 23
0
void CCreateLightNodeWindow::SelectListItem(u32 id)
{
	u32 count = ListBox_GetCount(mLightNodesList);
	for (u32 i = 0; i < count; i++)
	{
		u32 data = ListBox_GetItemData(mLightNodesList, i);
		if (data == id)
		{
			ListBox_SetCurSel(mLightNodesList, i);
			return;
		}
	}
}
Ejemplo n.º 24
0
VOID EditTrigger_InitList( HWND hwnd )
{
  INT i;
  HWND hwndCtrl;

  hwndCtrl = GetDlgItem( hwnd, IDC_EDIT_TRIGGER_LIST );

  ListBox_ResetContent( hwndCtrl );

  if ( nListContent == 0 )
  {
    for( i = 0; i < NUM_ITEM_TYPES; ++i )
    {
      ListBox_AddString( hwndCtrl, GetItemTypeString( i ) );
    }

    ListBox_SetCurSel( hwndCtrl, nNewItemType );

    hwndCtrl = GetDlgItem(hwnd, IDC_EDIT_TRIGGER_LIST_STATIC);
    Static_SetText(hwndCtrl, (LPSTR)"Items:");
  }
  else
  {
    for( i = 0; i < po->nSounds; ++i )
    {
      ListBox_AddString( hwndCtrl, po->pSoundData[i].sound_name );
    }

    ListBox_SetCurSel( hwndCtrl, nNewSoundIndex );

    hwndCtrl = GetDlgItem(hwnd, IDC_EDIT_TRIGGER_LIST_STATIC);
    Static_SetText(hwndCtrl, (LPSTR)"Sounds:");
  }

  return;

} // EditTrigger_InitList
Ejemplo n.º 25
0
int ListBox_MoveStringUp(HWND hwndList, int nIndex)
{
    int nNewIndex;

    SetWindowRedraw(hwndList, FALSE);
    nNewIndex = ListBox_MoveString(hwndList, nIndex, -1, TRUE);
    ASSERT(nNewIndex != LB_ERR);
    if (ListBox_SetSel(hwndList, TRUE, nNewIndex) == LB_ERR)
    {
        // Try and use ListBox_SetCurSel() (for single selection listbox)
        ListBox_SetCurSel(hwndList, nNewIndex);
    }
    SetWindowRedraw(hwndList, TRUE);
    RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

    return (nNewIndex);
}
Ejemplo n.º 26
0
HRESULT OnInitDialog(HWND hwnd, ChooseDeviceParam *pParam)
{
    HRESULT hr = S_OK;

    HWND hList = GetDlgItem(hwnd, IDC_DEVICE_LIST);

    // Display a list of the devices.

    for (DWORD i = 0; i < pParam->count; i++)
    {
        WCHAR *szFriendlyName = NULL;

        hr = pParam->ppDevices[i]->GetAllocatedString(
            MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, 
            &szFriendlyName, 
            NULL
            );

        if (FAILED(hr)) 
        { 
            break; 
        }

        int index = ListBox_AddString(hList, szFriendlyName);

        ListBox_SetItemData(hList, index, i);

        CoTaskMemFree(szFriendlyName);
    }

    // Assume no selection for now.
    pParam->selection = (UINT32)-1;

    if (pParam->count == 0)
    {
        // If there are no devices, disable the "OK" button.
        EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
    }
    else
    {
        // Select the first device in the list.
        ListBox_SetCurSel(hList, 0);
    }

    return hr;
}
Ejemplo n.º 27
0
void FileChildWindow::activate_entry(Pane* pane)	///@todo enable using RETURN key accelerator
{
	Entry* entry = pane->_cur;

	if (!entry)
		return;

	WaitCursor wait;

	if ((entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||	// a directory?
		entry->_down)	// a file with NTFS sub-streams?
	{
		int scanned_old = entry->_scanned;

		if (!scanned_old)
			scan_entry(entry);

		if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('\0'))
			return;

		if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('.') && entry->_data.cFileName[2]==TEXT('\0')) {
			entry = _left->_cur->_up;
			collapse_entry(_left, entry);
			goto focus_entry;
		} else if (entry->_expanded)
			collapse_entry(pane, _left->_cur);
		else {
			expand_entry(_left->_cur);

			if (!pane->_treePane) focus_entry: {
				int idx = ListBox_FindItemData(_left_hwnd, ListBox_GetCurSel(_left_hwnd), entry);
				ListBox_SetCurSel(_left_hwnd, idx);

				set_curdir(entry);
			}
		}

		if (!scanned_old) {
			pane->calc_widths(false);

			pane->set_header();
		}
	} else {
		entry->launch_entry(_hwnd);
	}
}
Ejemplo n.º 28
0
/*
    index is set where the original font was in the listbox.
    Select the item at that index unless it is out of bounds
    then select the last one.
    If none exist in the new listbox then select nothing
    and gray out the Details and Delete buttons.
*/
void SelectNextBest(HWND hwnd, int index)
{
	int count;

	count = ListBox_GetCount(hwnd);
	if (count <= 0)
	{
		EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
		EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
	}
	else
	{
		if (index >= count)
		{
			index = count - 1;
		}
		ListBox_SetCurSel(hwnd, index);
	} // count > 0
} // SelectNextBest
Ejemplo n.º 29
0
VOID EditNoise_InitList(HWND hwnd)
{
    INT i;
    HWND hwndCtrl;

    hwndCtrl = GetDlgItem(hwnd, IDC_EDIT_NOISE_LIST);

    ListBox_ResetContent(hwndCtrl);

    for(i = 0; i < po->nSounds; ++i)
    {
        ListBox_AddString(hwndCtrl, po->pSoundData[i].sound_name);
    }

    ListBox_SetCurSel(hwndCtrl, nNewSoundIndex);

    return;

} // EditNoise_InitList
Ejemplo n.º 30
0
/*
 * OnCommand()
 */
void sd_OnCommand(HWND storeDlg, UINT cmdID, HWND ctrl, UINT notify)
{
    int lbxIndex;
    int itemGroupIndex;
    int lbxCount;

    switch (cmdID) {
        case IDOK:
            if (sd_itemToStore == SI_VCED) {
                itemGroupIndex = SI_VMEM;
                lbxCount = 16;
            } else { /* (sd_itemToStore == SI_PCED) */
                itemGroupIndex = SI_PMEM;
                lbxCount = 12;
            }
            *sd_destIndex = ListBox_GetCurSel(sd_lbx[0]);
            if (*sd_destIndex == -1) {
                *sd_destIndex = lbxCount + ListBox_GetCurSel(sd_lbx[1]);
            }
            *sd_destIndex += itemGroupIndex;
        case IDCANCEL:
            EndDialog(storeDlg, cmdID);
            break;
        case IDC_STORE1_LBX:
            lbxIndex = 0;
            goto LBX_INDEX_SET;
        case IDC_STORE2_LBX:
            lbxIndex = 1;
LBX_INDEX_SET:
            if (notify == LBN_SETFOCUS) {
                /*
                 * Allow only one selection among both list boxes.
                 */
                ListBox_SetCurSel(sd_lbx[1 - lbxIndex], -1);
            } else if (notify == LBN_DBLCLK) {
                /*
                 * Double clicking an item is equivalent to clicking OK.
                 */
                PostMessage(storeDlg, WM_COMMAND, IDOK, 0);
            }
            break;
    }
}