本文整理汇总了C++中ListBox_SetCurSel函数的典型用法代码示例。如果您正苦于以下问题:C++ ListBox_SetCurSel函数的具体用法?C++ ListBox_SetCurSel怎么用?C++ ListBox_SetCurSel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ListBox_SetCurSel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: w32g_rotate_playlist
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);
}
}
}
示例2: IAddUserType
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);
}
示例3: GetControl
/*
** 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);
}
}
}
示例4: GetDlgItem
/*
** 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);
}
}
}
示例5: LoadList
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();
}
示例6: update_disasm
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);
}
示例7: AppendLog
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);
}
示例8: ViewItems_OnInitDialog
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
示例9: GetWindowRect
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();
}
示例10: ViewMarks_OnInitDialog
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
示例11: LookListSetContents
/*
* 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);
}
示例12: RetryAndSelectString
/*
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
示例13: w32g_setcur_playlist
void w32g_setcur_playlist(void)
{
HWND hListBox;
if(!(hListBox = playlist_box()))
return;
ListBox_SetCurSel(hListBox, playlist.selected);
SetNumListWnd(playlist.selected,playlist.nfiles);
}
示例14: w32g_refine_playlist
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;
}
示例15: AddText
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);
}