コード例 #1
0
ファイル: guisup.c プロジェクト: lei720/processhacker2
PPH_STRING PhGetListBoxString(
    _In_ HWND hwnd,
    _In_ INT Index
    )
{
    PPH_STRING string;
    ULONG length;

    if (Index == -1)
    {
        Index = ListBox_GetCurSel(hwnd);

        if (Index == -1)
            return NULL;
    }

    length = ListBox_GetTextLen(hwnd, Index);

    if (length == LB_ERR)
        return NULL;
    if (length == 0)
        return PhReferenceEmptyString();

    string = PhCreateStringEx(NULL, length * 2);

    if (ListBox_GetText(hwnd, Index, string->Buffer) != LB_ERR)
    {
        return string;
    }
    else
    {
        PhDereferenceObject(string);
        return NULL;
    }
}
コード例 #2
0
ファイル: pcp_listbox.c プロジェクト: now/slackedit
int ListBox_MoveString(HWND hwndListBox, int iIndex, int iNewIndex, BOOL bRelativeToOld)
{
    int iCount = ListBox_GetCount(hwndListBox);
    int nExactNewIndex;

    if (iIndex == 0 && iNewIndex < 0)
        iNewIndex = 0;

    nExactNewIndex = bRelativeToOld ? (iIndex + iNewIndex) : iNewIndex;

    if ((bRelativeToOld && (iIndex + iNewIndex) >= iCount) ||
        (iNewIndex >= iCount))
    {
        return (LB_ERR);
    }
    else
    {
        LPTSTR pszBuffer = (LPTSTR)Mem_AllocStr(ListBox_GetTextLen(hwndListBox, iIndex) + SZ);
        LPVOID lpVoid = (LPVOID)ListBox_GetItemData(hwndListBox, iIndex);

        ListBox_GetText(hwndListBox, iIndex, pszBuffer);
        ListBox_DeleteString(hwndListBox, iIndex);
        ListBox_InsertString(hwndListBox, nExactNewIndex, pszBuffer);
        ListBox_SetItemData(hwndListBox, nExactNewIndex, lpVoid);
    
        Mem_Free(pszBuffer);
    }

    return (nExactNewIndex);
}
コード例 #3
0
ファイル: SetDlgNetwork.cpp プロジェクト: abt8WG/EDCB
void CSetDlgNetwork::OnBnClickedButtonAddTcp()
{
	// TODO: ここにコントロール通知ハンドラー コードを追加します。
	DWORD ip = 0;
	SendDlgItemMessage(m_hWnd, IDC_IPADDRESS_TCP, IPM_GETADDRESS, 0, (LPARAM)&ip);
	UINT tcpPort = GetDlgItemInt(m_hWnd, IDC_EDIT_PORT_TCP, NULL, FALSE);

	NW_SEND_INFO item;
	item.ip = ip;
	item.port = tcpPort;
	Format(item.ipString, L"%d.%d.%d.%d",
		(item.ip&0xFF000000)>>24,
		(item.ip&0x00FF0000)>>16,
		(item.ip&0x0000FF00)>>8,
		(item.ip&0x000000FF) );

	wstring add = L"";
	Format(add, L"%s:%d",item.ipString.c_str(), item.port);
	item.broadcastFlag = FALSE;

	HWND hItem = GetDlgItem(IDC_LIST_IP_TCP);
	for( int i=0; i<ListBox_GetCount(hItem); i++ ){
		WCHAR buff[256]=L"";
		int len = ListBox_GetTextLen(hItem, i);
		if( 0 <= len && len < 256 ){
			ListBox_GetText(hItem, i, buff);
			if(lstrcmpi(buff, add.c_str()) == 0 ){
				return ;
			}
		}
	}
	int index = ListBox_AddString(hItem, add.c_str());
	ListBox_SetItemData(hItem, index, (int)tcpSendList.size());
	tcpSendList.push_back(item);
}
コード例 #4
0
ファイル: dsksheet.c プロジェクト: mingpen/OpenNT
/*
    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
コード例 #5
0
ファイル: listbox.cpp プロジェクト: Zombiebest/Dolphin
// Find string for position
wxString wxListBox::GetString(unsigned int n) const
{
    wxCHECK_MSG( IsValid(n), wxEmptyString,
                 wxT("invalid index in wxListBox::GetString") );

    int len = ListBox_GetTextLen(GetHwnd(), n);

    // +1 for terminating NUL
    wxString result;
    ListBox_GetText(GetHwnd(), n, (wxChar*)wxStringBuffer(result, len + 1));

    return result;
}
コード例 #6
0
ファイル: listbox.cpp プロジェクト: gitrider/wxsj2
// Find string for position
wxString wxListBox::GetString(int N) const
{
    wxCHECK_MSG( N >= 0 && N < m_noItems, wxEmptyString,
                 wxT("invalid index in wxListBox::GetString") );

    int len = ListBox_GetTextLen(GetHwnd(), N);

    // +1 for terminating NUL
    wxString result;
    ListBox_GetText(GetHwnd(), N, (wxChar*)wxStringBuffer(result, len + 1));

    return result;
}
コード例 #7
0
ファイル: pcp_listbox.c プロジェクト: now/slackedit
int ListBox_AddNoDuplicateString(HWND hwndListBox, LPTSTR pszString)
{
    int iCount = ListBox_GetCount(hwndListBox), iIndex, iLen;
    LPTSTR pszBuffer;

    for (iIndex = 0; iIndex < iCount; iIndex++)
    {
        iLen = ListBox_GetTextLen(hwndListBox, iIndex);
        pszBuffer = (LPTSTR)Mem_AllocStr(iLen + SZ); /* SZ to be sure */
        if (ListBox_GetText(hwndListBox, iIndex, pszBuffer) != LB_ERR);
            if (_tcsicmp(pszString, pszBuffer) == 0)
                return (-1);

        Mem_Free(pszBuffer);
    }

    return (ListBox_AddString(hwndListBox, pszString));
}
コード例 #8
0
const string ProjectConfigDialog::makeSearchPath(void)
{
    HWND listbox = GetDlgItem(m_hwndDialog, IDC_LIST_PACKAGE_SEARCH_PATHS);
    int count = ListBox_GetCount(listbox);
    string path;
    for (int index = 0; index < count; ++index)
    {
        int buffsize = ListBox_GetTextLen(listbox, index);
        WCHAR *wbuff = new WCHAR[buffsize + 1];
        ListBox_GetText(listbox, index, wbuff);
        char *buff = new char[buffsize * 2 + 1];
        WideCharToMultiByte(CP_UTF8, 0, wbuff, -1, buff, buffsize * 2, NULL, NULL);
        path.append(buff);
        if (index < count - 1) path.append(";");
        delete []buff;
        delete []wbuff;
    }
    return path;
}
コード例 #9
0
ファイル: statlist.c プロジェクト: Darkman-M59/Meridian59_115
/*
 * StatsListLButtonDblClk:  User double-clicked left button on stats list.			ajw
 */
void StatsListLButtonDblClk(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
   char pszLabel[256];
   char pszCommand[256];
   int iLabelLen;
   int index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd);
   
   if (index >= ListBox_GetCount(hwnd))
      return;

   if ((GetPlayerInfo()->viewID != 0) && (GetPlayerInfo()->viewID != GetPlayerInfo()->id))
   {
      if (!(GetPlayerInfo()->viewFlags & REMOTE_VIEW_CAST))
         return;
   }
   ListBox_SetCurSel(hwnd, index);
   iLabelLen = ListBox_GetTextLen( hwnd, index );

   if( ListBox_GetText( hwnd, index, pszLabel ) != LB_ERR )
   {
      if( StatsGetCurrentGroup() == STATS_SPELLS )
      {
	 strcpy( pszCommand, "zaubern " );
      }
      else if (StatsGetCurrentGroup() == STATS_SKILLS)
      {
	 strcpy( pszCommand, "perform " );
	 return; // not implimented yet
      }
      else
      {
	 return;  // not going to do anything for non skills/stats
      }
      strcat( pszCommand, pszLabel );
      PerformAction( A_GOTOMAIN, NULL );	//	For targeting icon to appear, focus must be on main view window.
      PerformAction( A_TEXTCOMMAND, pszCommand );
   }
}
コード例 #10
0
ファイル: w32g_playlist.c プロジェクト: Distrotech/TiMidity
void w32g_update_playlist(void)
{
#if 0
    int i, cur, modified;
    HWND hListBox;

    if(!(hListBox = playlist_box()))
	return;

    cur = ListBox_GetCurSel(hListBox);
    modified = 0;
    for(i = 0; i < playlist.nfiles; i++)
    {
	char *filename, *title, *item1, *item2;
	int maxlen, item2_len;

	filename = playlist.list[i].filename;
	title = playlist.list[i].title;
	if(title == NULL || title[0] == '\0')
	{
	    if(playlist.list[i].info->file_type == IS_ERROR_FILE)
		title = " --SKIP-- ";
	    else
		title = " -------- ";
	}
	maxlen = strlen(filename) + strlen(title) + 32;
	item1 = (char *)new_segment(&tmpbuffer, maxlen);
	if(i == playlist.selected)
	    snprintf(item1, maxlen, "==>%04d %s (%s)", i + 1, title, filename);
	else
	    snprintf(item1, maxlen, "   %04d %s (%s)", i + 1, title, filename);
	item2_len = ListBox_GetTextLen(hListBox, i);
	item2 = (char *)new_segment(&tmpbuffer, item2_len + 1);
	ListBox_GetText(hListBox, i, item2);
	if(strcmp(item1, item2) != 0)
	{
	    ListBox_DeleteString(hListBox, i);
	    ListBox_InsertString(hListBox, i, item1);
	    modified = 1;
	}
	reuse_mblock(&tmpbuffer);
    }

    if(modified)
    {
	if(cur < 0)
	    cur = playlist.selected;
	else if(cur >= playlist.nfiles - 1)
	    cur = playlist.nfiles - 1;
	ListBox_SetCurSel(hListBox, cur);
	SetNumListWnd(cur,playlist.nfiles);
    }
#else
    int i, cur, modified;
    HWND hListBox;

    if(!(hListBox = playlist_box()))
	return;

    cur = ListBox_GetCurSel(hListBox);
    modified = 0;
    for(i = 0; i < playlist.nfiles; i++)
    {
		w32g_update_playlist_pos(i);
    }

    if(modified)
    {
	if(cur < 0)
	    cur = playlist.selected;
	else if(cur >= playlist.nfiles - 1)
	    cur = playlist.nfiles - 1;
	ListBox_SetCurSel(hListBox, cur);
	SetNumListWnd(cur,playlist.nfiles);
    }
#endif
}
コード例 #11
0
ファイル: statlist.c プロジェクト: Darkman-M59/Meridian59_115
/*
 * StatListKey:  User pressed a key on stat list box.
 *   Return True iff key should NOT be passed on to Windows for default processing.
 */
Bool StatListKey(HWND hwnd, UINT key, Bool fDown, int cRepeat, UINT flags)
{
   Bool held_down = (flags & 0x4000) ? True : False;  /* Is key being held down? */
   int old_top, new_top, old_pos, new_pos;

   UserDidSomething();

   old_pos = ListBox_GetCurSel(hwnd);
   new_top = old_top = ListBox_GetTopIndex(hwnd);

   // Handle keys manually to prevent Windows from copying list box background, which would
   // cause background to flash when it's redrawn in the correct location.
   switch (key)
   {
   case VK_UP:
     WindowBeginUpdate(hwnd);
     new_pos = max(0, old_pos - 1);
     if (new_pos < old_top)
       new_top = new_pos;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

   case VK_DOWN:
     WindowBeginUpdate(hwnd);
     new_pos = min(old_pos + 1, ListBox_GetCount(hwnd) - 1);
     if (new_pos > old_top + num_visible)
       new_top = new_pos - num_visible;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

   case VK_PRIOR:
     WindowBeginUpdate(hwnd);
     new_pos = max(0, old_pos - num_visible);
     new_top = new_pos;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

   case VK_NEXT:
     WindowBeginUpdate(hwnd);
     new_pos = min(old_pos + num_visible, ListBox_GetCount(hwnd) - 1);
     new_top = new_pos - num_visible;
     ListBox_SetTopIndex(hwnd, new_top);
     ListBox_SetCurSel(hwnd, new_pos);
     SetScrollPos(hwnd, SB_VERT, new_top, TRUE); 
     WindowEndUpdate(hwnd);
     return True;

	case VK_RETURN:	//	ajw
		{
			int iLabelLen = ListBox_GetTextLen( hwnd, old_pos );
			char* pszLabel = (char*)SafeMalloc( ( iLabelLen + 1 ) * sizeof( char ) );
			if( ListBox_GetText( hwnd, old_pos, pszLabel ) != LB_ERR )
			{
				//	ajwxxx Hard-coded group number constants for spells list. There may be a var that could be used instead.
				char* pszCommand;
				if( StatsGetCurrentGroup() == STATS_SPELLS )
				{
					pszCommand = (char*)SafeMalloc( ( iLabelLen + 6 ) * sizeof( char ) );
					strcpy( pszCommand, "zaubern " );
				}
				else
				{
					pszCommand = (char*)SafeMalloc( ( iLabelLen + 9 ) * sizeof( char ) );
					strcpy( pszCommand, "perform " );
				}
				strcat( pszCommand, pszLabel );
				PerformAction( A_GOTOMAIN, NULL );	//	For targeting icon to appear, focus must be on main view window.
				PerformAction( A_TEXTCOMMAND, pszCommand );
				SafeFree( pszCommand );
			}
			SafeFree( pszLabel );
		}
		return True;
   }

   return StatInputKey(hwnd, key, fDown, cRepeat, flags);
}