/// Function name  : onDependenciesPage_ContextMenu
// Description     : Display the ScriptDependencies or VariableDependencies Popup Menu
// 
// SCRIPT_DOCUMENT*  pDocument : [in] Script document data
// HWND              hCtrl     : [in] Window handle of the control sending the message
// CONST UINT        iCursorX  : [in] Screen co-ordinate cursor X position
// CONST UINT        iCursorY  : [in] Screen co-ordinate cursor Y position
// 
// Return Value   : TRUE
// 
BOOL  onDependenciesPage_ContextMenu(SCRIPT_DOCUMENT*  pDocument, HWND  hCtrl, CONST UINT  iCursorX, CONST UINT  iCursorY)
{
   CUSTOM_MENU*  pCustomMenu;    // Custom Popup menu
   UINT          iSubMenuID;     // Popup submenu ID

   // [TRACK]
   CONSOLE_ACTION();

   // Determine submenu
   switch (GetWindowID(hCtrl))
   {
   /// [LISTVIEW] Display the appropriate popup menu
   case IDC_DEPENDENCIES_LIST:   iSubMenuID = IDM_DEPENDENCIES_POPUP;  CONSOLE("Displaying dependencies menu");  break;
   case IDC_VARIABLES_LIST:      iSubMenuID = IDM_VARIABLES_POPUP;     CONSOLE("Displaying variables menu");     break;
   case IDC_STRINGS_LIST:        iSubMenuID = IDM_STRINGS_POPUP;       CONSOLE("Displaying strings menu");       break;
   default:                      return FALSE;
   }

   // Create Dependencies Custom Popup menu
   pCustomMenu = createCustomMenu(TEXT("SCRIPT_MENU"), TRUE, iSubMenuID);

   /// [DEPENDENCIES] Disable 'Load script' if no item is selected
   if (GetWindowID(hCtrl) == IDC_DEPENDENCIES_LIST)
      EnableMenuItem(pCustomMenu->hPopup, IDM_DEPENDENCIES_LOAD, (ListView_GetSelectedCount(hCtrl) > 0 ? MF_ENABLED : MF_DISABLED));

   /// Display context menu
   TrackPopupMenu(pCustomMenu->hPopup, TPM_TOPALIGN WITH TPM_LEFTALIGN, iCursorX, iCursorY, NULL, GetParent(hCtrl), NULL);

   // Cleanup and return TRUE
   deleteCustomMenu(pCustomMenu);
   return TRUE;
}
Beispiel #2
0
void OBS::SelectSources()
{
    if(scene)
        scene->DeselectAll();

    HWND hwndSources = GetDlgItem(hwndMain, ID_SOURCES);
    UINT numSelected = ListView_GetSelectedCount(hwndSources);

    if(numSelected)
    {
        List<UINT> selectedItems;
        selectedItems.SetSize(numSelected);
        //SendMessage(hwndSources, LB_GETSELITEMS, numSelected, (LPARAM)selectedItems.Array());

        if(scene)
        {
            int iPos = ListView_GetNextItem(hwndSources, -1, LVNI_SELECTED);
            while (iPos != -1)
            {
                SceneItem *sceneItem = scene->GetSceneItem(iPos);
                sceneItem->bSelected = true;
                
                iPos = ListView_GetNextItem(hwndSources, iPos, LVNI_SELECTED);
            }
        }
    }
}
Beispiel #3
0
void ProcessPage_OnSetAffinity(void)
{
    LV_ITEM            lvitem;
    ULONG            Index;
    DWORD            dwProcessId;
    TCHAR            strErrorText[260];

    for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) {
        memset(&lvitem, 0, sizeof(LV_ITEM));
        lvitem.mask = LVIF_STATE;
        lvitem.stateMask = LVIS_SELECTED;
        lvitem.iItem = Index;
        SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
        if (lvitem.state & LVIS_SELECTED)
            break;
    }
    dwProcessId = PerfDataGetProcessId(Index);
    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
        return;
    hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
    if (!hProcessAffinityHandle) {
        GetLastErrorText(strErrorText, 260);
        MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
        return;
    }
    DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, AffinityDialogWndProc);
    if (hProcessAffinityHandle)    {
        CloseHandle(hProcessAffinityHandle);
        hProcessAffinityHandle = NULL;
    }
}
Beispiel #4
0
static void EnableDisableCtrls(HWND hwndDlg)
{
	BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_AUTO_USER);
	EnableWindow(GetDlgItem(hwndDlg, IDC_LANGUAGE_L), enabled);
	EnableWindow(GetDlgItem(hwndDlg, IDC_LANGUAGE), enabled);
	EnableWindow(GetDlgItem(hwndDlg, IDC_REPLACEMENTS), enabled);
	EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), enabled);
	EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT), enabled);
	EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE), enabled);
	if (!enabled)
		return;

	HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS);
	EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT), ListView_GetSelectedCount(hList) == 1);
	EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE), ListView_GetSelectedCount(hList) > 0);
}
Beispiel #5
0
void pListView::onChange(LPARAM lparam) {
  LPNMLISTVIEW nmlistview = (LPNMLISTVIEW)lparam;
  if(!(nmlistview->uChanged & LVIF_STATE)) return;

  unsigned selection = nmlistview->iItem;
  unsigned imagemask = ((nmlistview->uNewState & LVIS_STATEIMAGEMASK) >> 12) - 1;
  if(imagemask == 0 || imagemask == 1) {
    if(!locked) {
      listView.state.checked[selection] = !listView.state.checked[selection];
      if(listView.onToggle) listView.onToggle(selection);
    }
  } else if((nmlistview->uOldState & LVIS_FOCUSED) && !(nmlistview->uNewState & LVIS_FOCUSED)) {
    lostFocus = true;
    listView.state.selected = false;
    listView.state.selection = 0;
  } else if(!(nmlistview->uOldState & LVIS_SELECTED) && (nmlistview->uNewState & LVIS_SELECTED)) {
    lostFocus = false;
    listView.state.selected = true;
    listView.state.selection = selection;
    if(!locked && listView.onChange) listView.onChange();
  } else if(!lostFocus && !listView.state.selected) {
    lostFocus = false;
    listView.state.selected = false;
    listView.state.selection = 0;
    if(!locked && listView.onChange) listView.onChange();
  } else if(listView.selected() && ListView_GetSelectedCount(hwnd) == 0) {
    listView.state.selected = false;
    listView.state.selection = 0;
    if(!locked && listView.onChange) listView.onChange();
  }
}
Beispiel #6
0
int mxListView::getNumSelected() const
{
	if (!d_this)
		return 0;

	return ListView_GetSelectedCount( d_this->d_hwnd );
}
Beispiel #7
0
static DWORD    get_selected_pid(void)
{
    LVITEM      lvitem;
    ULONG       Index;
    DWORD       dwProcessId;

    for (Index = 0; Index < (ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
    {
        lvitem.mask = LVIF_STATE;
        lvitem.stateMask = LVIS_SELECTED;
        lvitem.iItem = Index;
        lvitem.iSubItem = 0;

        SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);

        if (lvitem.state & LVIS_SELECTED)
            break;
    }

    dwProcessId = PerfDataGetProcessId(Index);

    if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
        return 0;
    return dwProcessId;
}
/*****************************************************************************
DWORD CreateChecksumFiles(CONST HWND arrHwnd[ID_NUM_WINDOWS], CONST UINT uiMode)
	arrHwnd		: (IN) array with window handles
	uiMode		: (IN) create MD5/SFV/SHA1 files

Return Value:
	returns NOERROR or GetLastError()

Notes:
	- wrapper for the three parameter version
	- checks if selected files have the necessary info
	- calls FillFinalList to get its list
*****************************************************************************/
DWORD CreateChecksumFiles(CONST HWND arrHwnd[ID_NUM_WINDOWS], CONST UINT uiMode)
{
	list<FILEINFO*> finalList;
	DWORD checkReturn;
	TCHAR szErrorMessage[MAX_PATH_EX];

	// check if there are any item in our list (without checking an access violation could occur)
	if(ListView_GetItemCount(arrHwnd[ID_LISTVIEW]) == 0)
		return NOERROR;

	if(CheckIfRehashNecessary(arrHwnd,uiMode))
		return NOERROR;

	FillFinalList(arrHwnd[ID_LISTVIEW],&finalList,ListView_GetSelectedCount(arrHwnd[ID_LISTVIEW]));
	if(finalList.size()>1) {
		finalList.sort(ListPointerCompFunction);
		finalList.unique(ListPointerUniqFunction);
	}

	if((checkReturn = CreateChecksumFiles(arrHwnd,uiMode,&finalList)) != NOERROR) {
		StringCchPrintf(szErrorMessage, MAX_PATH_EX,
							TEXT("Error %u occured during checksum file creation"),
							checkReturn);
		MessageBox(arrHwnd[ID_MAIN_WND], szErrorMessage, TEXT("Error"), MB_OK);
	}

	return checkReturn;
}
Beispiel #9
0
void ShowWindowPropertyEditor(HWND hwndParent, HWND hwndTarget, BOOL bAddNew)
{
	HWND hwndList;
	LVITEM lvitem;
	PropertyEditState state;

	state.hwndTarget = hwndTarget;
	state.bAddNew = bAddNew;

	if(!bAddNew)
	{
		hwndList = GetDlgItem(hwndParent, IDC_LIST1);

		if(ListView_GetSelectedCount(hwndList) != 1)
			return;

		lvitem.mask = LVIF_TEXT | LVIF_PARAM;
		lvitem.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
		lvitem.iSubItem = 0;
		lvitem.pszText = state.szString;
		lvitem.cchTextMax = 256;

		ListView_GetItem(hwndList, &lvitem);

		state.aAtom = (ATOM)lvitem.lParam;
	}

	DialogBoxParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_PROPERTY_EDIT), hwndParent, PropertyEditProc, (LPARAM)&state);

	// Update the main display 
	SetPropertyInfo(hwndTarget);
}
Beispiel #10
0
//  Retrieves extended infomration on a dirlist item
int DirList_GetItemEx(HWND hwnd, int iItem, LPWIN32_FIND_DATA pfd) {

    LV_ITEM lvi;
    LPLV_ITEMDATA lplvid;

    if (iItem == -1) {

        if (ListView_GetSelectedCount(hwnd))

            iItem = ListView_GetNextItem(hwnd, -1, LVNI_ALL | LVNI_SELECTED);

        else

            return (-1);
    }

    lvi.mask = LVIF_PARAM;
    lvi.iItem = iItem;
    lvi.iSubItem = 0;

    if (!ListView_GetItem(hwnd, &lvi))
        return (-1);

    lplvid = (LPLV_ITEMDATA)lvi.lParam;

    if (NOERROR == SHGetDataFromIDList(lplvid->lpsf, lplvid->pidl, SHGDFIL_FINDDATA, pfd,
                                       sizeof(WIN32_FIND_DATA)))
        return iItem;

    else
        return (-1);
}
Beispiel #11
0
LRESULT CVideoMarkup::OnBeginDrag(int idCtrl, LPNMHDR pnmh, BOOL&) {
    POINT p;
    HIMAGELIST hImageListSingle, hImageListMerged;

    int numSelected = ListView_GetSelectedCount(m_sampleListView);
    int iSelection = -1;
    for (int iIndex=0; iIndex<numSelected; iIndex++) {
        iSelection = ListView_GetNextItem(m_sampleListView, iSelection, LVNI_SELECTED);
        if (iIndex == 0) { // first selected icon
            hDragImageList = ListView_CreateDragImage(m_sampleListView, iSelection, &p);
        } else { // subsequent icons
            hImageListSingle = ListView_CreateDragImage(m_sampleListView, iSelection, &p);
            hImageListMerged = ImageList_Merge(hDragImageList, 0, hImageListSingle, 0, iIndex*3, iIndex*3);
            ImageList_Destroy(hDragImageList);
            ImageList_Destroy(hImageListSingle);
            hDragImageList = hImageListMerged;
        }
    }

    ImageList_BeginDrag(hDragImageList, 0, LISTVIEW_SAMPLE_X/2, LISTVIEW_SAMPLE_Y/2);
    POINT pt = ((NM_LISTVIEW*)pnmh)->ptAction;
    RECT listViewRect;
    m_sampleListView.GetClientRect(&listViewRect);
    m_sampleListView.ClientToScreen(&pt);
    m_sampleListView.ClientToScreen(&listViewRect);

    ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
    draggingIcon = TRUE;
    SetCapture();
    return 0;
}
Beispiel #12
0
void ProcessPageUpdate(void)
{
    /* Enable or disable the "End Process" button */
    if (ListView_GetSelectedCount(hProcessPageListCtrl))
        EnableWindow(hProcessPageEndProcessButton, TRUE);
    else
        EnableWindow(hProcessPageEndProcessButton, FALSE);
}
Beispiel #13
0
BOOL WmTabCommand_DeleteFunction(HWND, UINT, WPARAM, LPARAM)
{
HWND hWnd = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_functions);
HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST);
int items = ListView_GetSelectedCount(list);

	if( items == 0 )
		// there must be at least one item selected
		return true;

	if( items > 1 )
	{
		// we're showing a message to confirm deleting
		if( MessageBox( hWnd,
						GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_delete_function_confirm),
						GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
						MB_ICONWARNING | MB_YESNO) == IDNO )
			return true;
	}

	int id;
	const int buffer_size = 300;
	char * buffer = new char[buffer_size];
	bool all_deleted = true;

	GetPrgRes()->ReadVariablesFunctionsFromFile();
	GetPrgRes()->GetThreadController()->StopCalculating();

	for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id )
	{
		if( ListView_GetItemState(list, id, LVIS_SELECTED) == LVIS_SELECTED )
		{
			ListView_GetItemText(list,id,0,buffer,buffer_size);
			if( GetPrgRes()->GetFunctions()->Delete(buffer) != ttmath::err_ok )
				all_deleted = false;
			else
				ListView_DeleteItem(list, id);

			GetPrgRes()->FunctionsChanged();
		}
	}
	
	
	GetPrgRes()->GetThreadController()->StartCalculating();
	GetPrgRes()->SaveToFile();

	delete [] buffer;

	if( !all_deleted )
		// there are some items which we've not deleted
		// probably an internal error
		MessageBox(	hWnd,
					GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_function_not_all_deleted),
					GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
					MB_ICONERROR);

return true;
}
Beispiel #14
0
static BOOL
AddSelectedGroupsToUser(HWND hwndDlg,
                        PMEMBERSHIP_USER_DATA pUserData)
{
    HWND hwndLV;
    INT nItem;
    TCHAR szGroupName[UNLEN];
    BOOL bResult = FALSE;
    BOOL bFound;
    DWORD i;
    LOCALGROUP_MEMBERS_INFO_3 memberInfo;
    NET_API_STATUS status;

    hwndLV = GetDlgItem(hwndDlg, IDC_USER_ADD_MEMBERSHIP_LIST);

    if (ListView_GetSelectedCount(hwndLV) > 0)
    {
        nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
        while (nItem != -1)
        {
            /* Get the new user name */
            ListView_GetItemText(hwndLV,
                                 nItem, 0,
                                 szGroupName,
                                 UNLEN);

            bFound = FALSE;
            for (i = 0; i < pUserData->dwGroupCount; i++)
            {
                if (_tcscmp(pUserData->pGroupData[i].lgrui0_name, szGroupName) == 0)
                    bFound = TRUE;
            }

            if (!bFound)
            {
                memberInfo.lgrmi3_domainandname = pUserData->szUserName;

                status = NetLocalGroupAddMembers(NULL, szGroupName, 3,
                                                 (LPBYTE)&memberInfo, 1);
                if (status == NERR_Success)
                {
                    DebugPrintf(_TEXT("Selected group: %s"), szGroupName);
                    bResult = TRUE;
                }
                else
                {
                    TCHAR szText[256];
                    wsprintf(szText, TEXT("Error: %u"), status);
                    MessageBox(NULL, szText, TEXT("NetLocalGroupAddMembers"), MB_ICONERROR | MB_OK);
                }
            }

            nItem = ListView_GetNextItem(hwndLV, nItem, LVNI_SELECTED);
        }
    }

    return bResult;
}
Beispiel #15
0
void ApplicationPageShowContextMenu2(void)
{
    HMENU  hMenu;
    HMENU  hSubMenu;
    POINT  pt;

    GetCursorPos(&pt);

    hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_APPLICATION_PAGE_CONTEXT2));
    hSubMenu = GetSubMenu(hMenu, 0);

    if (ListView_GetSelectedCount(hApplicationPageListCtrl) == 1)
    {
        EnableMenuItem(hSubMenu, ID_WINDOWS_TILEHORIZONTALLY, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_TILEVERTICALLY, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_MINIMIZE, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_MAXIMIZE, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_CASCADE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_BRINGTOFRONT, MF_BYCOMMAND|MF_ENABLED);
    }
    else if (ListView_GetSelectedCount(hApplicationPageListCtrl) > 1)
    {
        EnableMenuItem(hSubMenu, ID_WINDOWS_TILEHORIZONTALLY, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_TILEVERTICALLY, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_MINIMIZE, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_MAXIMIZE, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_CASCADE, MF_BYCOMMAND|MF_ENABLED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_BRINGTOFRONT, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
    }
    else
    {
        EnableMenuItem(hSubMenu, ID_WINDOWS_TILEHORIZONTALLY, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_TILEVERTICALLY, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_MINIMIZE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_MAXIMIZE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_CASCADE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        EnableMenuItem(hSubMenu, ID_WINDOWS_BRINGTOFRONT, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
    }

    SetMenuDefaultItem(hSubMenu, ID_APPLICATION_PAGE_SWITCHTO, MF_BYCOMMAND);

    TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);

    DestroyMenu(hMenu);
}
/* Returns a selected item or -1 if no selection.
   Assumes that the list is single-sel */
int lv_get_selection_pos(HWND hwnd)
{
    int selection;
    int selected_count = ListView_GetSelectedCount(hwnd);
    assert(selected_count <= 1);
    if (0 == selected_count)
        return -1;
    selection = ListView_GetSelectionMark(hwnd);
    return selection;
}
Beispiel #17
0
void CPlayListDlg::OnContextMenu(NMRGINFO* pnmri)
{
	HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST);
	
	HMENU hMenu = LoadMenu(GetInst(), (LPCTSTR)IDR_POPUP);
	HMENU hSub = GetSubMenu(hMenu, 
		ListView_GetSelectedCount(hwndLV) == 1 ? IDM_SUBMENU_PLAYLIST1 : IDM_SUBMENU_PLAYLIST2);

	TrackPopupMenu(hSub, TPM_LEFTALIGN | TPM_TOPALIGN, 
				pnmri->ptAction.x, pnmri->ptAction.y, 0, m_hWnd, NULL);
	DestroyMenu(hMenu);
}
/*****************************************************************************
static bool CheckIfRehashNecessary(CONST HWND arrHwnd[ID_NUM_WINDOWS],CONST UINT uiMode)
	arrHwnd			: (IN) array with window handles
	uiMode			: (IN) create MD5 or SFV files

Return Value:
	returns true if rehash was/is necessary

Notes:
	- checks if the necessary hash has been calculated for all selected files
    - if hashes are missing the user is asked if he wants a rehash of those lists that
	  are missing the hashes
*****************************************************************************/
static bool CheckIfRehashNecessary(CONST HWND arrHwnd[ID_NUM_WINDOWS],CONST UINT uiMode)
{
	LVITEM lvitem={0};
	bool doRehash=false;
	bool needRehash=false;
	UINT uiIndex;
	list<lFILEINFO*> *doneList;
	list<lFILEINFO*> rehashList;
	lFILEINFO *pList;

	if(ListView_GetSelectedCount(arrHwnd[ID_LISTVIEW])==0) {
		doneList = SyncQueue.getDoneList();
		for(list<lFILEINFO*>::iterator it=doneList->begin();it!=doneList->end();it++) {
            if( uiMode != MODE_NORMAL && !(*it)->bCalculated[uiMode] )
				rehashList.push_back(*it);
		}
		SyncQueue.releaseDoneList();
	} else {
		uiIndex = ListView_GetNextItem(arrHwnd[ID_LISTVIEW],-1,LVNI_SELECTED);
		lvitem.mask = LVIF_PARAM;
		do {
			lvitem.iItem = uiIndex;
			ListView_GetItem(arrHwnd[ID_LISTVIEW],&lvitem);
			pList = ((FILEINFO *)lvitem.lParam)->parentList;
			if( uiMode != MODE_NORMAL && !pList->bCalculated[uiMode] )
				rehashList.push_back(pList);
		} while((uiIndex = ListView_GetNextItem(arrHwnd[ID_LISTVIEW],uiIndex,LVNI_SELECTED))!=-1);
		rehashList.sort();
		rehashList.unique();
	}
	if(!rehashList.empty())
		needRehash=true;
	
	if( needRehash ){
        TCHAR *hashName = g_hash_names[uiMode];
		TCHAR msgString[MAX_PATH_EX];
		StringCchPrintf(msgString,MAX_PATH_EX,TEXT("You have to calculate the %s checksums first. Click OK to do that now."),hashName);
		if( MessageBox(arrHwnd[ID_MAIN_WND],
			msgString,
			TEXT("Question"),MB_OKCANCEL | MB_ICONQUESTION | MB_APPLMODAL | MB_SETFOREGROUND) == IDCANCEL)
			return true;
		doRehash = true;
	}
	if(doRehash) {
		for(list<lFILEINFO*>::iterator it=rehashList.begin();it!=rehashList.end();it++) {
			SyncQueue.deleteFromList(*it);
			(*it)->bDoCalculate[uiMode] = true;
			SyncQueue.pushQueue(*it);
		}
		PostMessage(arrHwnd[ID_MAIN_WND], WM_START_THREAD_CALC, NULL, NULL);
	}
	return needRehash;
}
Beispiel #19
0
//  Shows standard Win95 Property Dlg for selected Item
BOOL DirList_PropertyDlg(HWND hwnd, int iItem) {

    LV_ITEM lvi;
    LPLV_ITEMDATA lplvid;
    LPCONTEXTMENU lpcm;
    CMINVOKECOMMANDINFO cmi;
    BOOL bSuccess = TRUE;

    static const char* lpVerb = "properties";

    if (iItem == -1) {
        if (ListView_GetSelectedCount(hwnd))
            iItem = ListView_GetNextItem(hwnd, -1, LVNI_ALL | LVNI_SELECTED);

        else
            return FALSE;
    }

    lvi.mask = LVIF_PARAM;
    lvi.iItem = iItem;
    lvi.iSubItem = 0;

    if (!ListView_GetItem(hwnd, &lvi))
        return FALSE;

    lplvid = (LPLV_ITEMDATA)lvi.lParam;

    if (NOERROR ==
        lplvid->lpsf->GetUIObjectOf(GetParent(hwnd),               // Owner
                                    1,                             // Number of objects
                                    (LPCITEMIDLIST*)&lplvid->pidl, // pidl
                                    IID_IContextMenu, NULL, (void**)&lpcm)) {

        cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
        cmi.fMask = 0;
        cmi.hwnd = GetParent(hwnd);
        cmi.lpVerb = lpVerb;
        cmi.lpParameters = NULL;
        cmi.lpDirectory = NULL;
        cmi.nShow = SW_SHOWNORMAL;
        cmi.dwHotKey = 0;
        cmi.hIcon = NULL;

        if (NOERROR != lpcm->InvokeCommand(&cmi))
            bSuccess = FALSE;

        lpcm->Release();
    } else
        bSuccess = FALSE;

    return bSuccess;
}
Beispiel #20
0
void CPpcMainWnd::OnListViewDblClk(NMHDR* pnmh)
{
	if (!ListView_GetSelectedCount(m_hwndLV))
		return;

	int nCount = ListView_GetItemCount(m_hwndLV);
	for (int i = 0; i < nCount; i++) {
		if (ListView_GetItemState(m_hwndLV, i, LVIS_FOCUSED)) {
			Play(i);
			break;
		}
	}
}
Beispiel #21
0
	int ListView_GetSelItems(HWND hwnd , int count , int * buff) {
		int i = 0;
		int sc = ListView_GetSelectedCount(hwnd);
		int c = ListView_GetItemCount(hwnd);
		for (int j = 0; j < c; j++) {
			if (ListView_GetItemState(hwnd , j , LVIS_SELECTED)) {
				buff[i]=j;
				i++;
				if (i>=count || i>=sc) return i;
			}
		}
		return i;
	}
Beispiel #22
0
void CPlayListDlg::ShowMenu(int x, int y)
{
	HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST);
	
	HMENU hMenu = LoadMenu(GetInst(), (LPCTSTR)IDR_POPUP);
	HMENU hSub = GetSubMenu(hMenu, 
		ListView_GetSelectedCount(hwndLV) == 1 ? IDM_SUBMENU_PLAYLIST1 : IDM_SUBMENU_PLAYLIST2);

	POINT pt = {x, y};
	ClientToScreen(hwndLV, &pt);
	TrackPopupMenu(hSub, TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, m_hWnd, NULL);
	DestroyMenu(hMenu);
}
Beispiel #23
0
void CPpcMainWnd::OnFileUp()
{
	if (!ListView_GetSelectedCount(m_hwndLV))
		return;

	int nCount = ListView_GetItemCount(m_hwndLV);
	if (ListView_GetItemState(m_hwndLV, 0, LVIS_SELECTED))
		return;

	for (int i = 1; i < nCount; i++) {
		if (ListView_GetItemState(m_hwndLV, i, LVIS_SELECTED))
			UpFile(i);
	}
}
Beispiel #24
0
void CPpcMainWnd::OnFileDown()
{
	if (!ListView_GetSelectedCount(m_hwndLV))
		return;

	int nCount = ListView_GetItemCount(m_hwndLV);
	if (ListView_GetItemState(m_hwndLV, nCount - 1, LVIS_SELECTED))
		return;

	for (int i = nCount - 2; i >= 0; i--) {
		if (ListView_GetItemState(m_hwndLV, i, LVIS_SELECTED))
			DownFile(i);
	}
}
/*****************************************************************************
VOID ActionCrcIntoFilename(CONST HWND arrHwnd[ID_NUM_WINDOWS])
	arrHwnd : (IN) window handle array

Return Value:
	returns nothing

Notes:
	- wrapper for the three parameter version
	- calls FillFinalList to get its list
*****************************************************************************/
VOID ActionHashIntoFilename(CONST HWND arrHwnd[ID_NUM_WINDOWS], UINT uiHashType)
{
	list<FILEINFO*> finalList;

	if(CheckIfRehashNecessary(arrHwnd, uiHashType))
		return;

	FillFinalList(arrHwnd[ID_LISTVIEW],&finalList,ListView_GetSelectedCount(arrHwnd[ID_LISTVIEW]));
	if(finalList.size()>1) {
		finalList.sort(ListPointerCompFunction);
		finalList.unique(ListPointerUniqFunction);
	}
	ActionHashIntoFilename(arrHwnd, FALSE, &finalList, uiHashType);
}
Beispiel #26
0
void _activate_page( )
{
	HWND h_tab  = GetDlgItem( __dlg, IDT_INFO );

	_dnode *node = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) );
	_dact  *act  = _create_act_thread( node, -1, -1 );

	if ( ListView_GetSelectedCount( __lists[HMAIN_DRIVES] ) && node && !node->is_root && act )
	{
		NMHDR mhdr = { 0, 0, TCN_SELCHANGE };

		TabCtrl_SetCurSel( h_tab, 1 );
		SendMessage( __dlg, WM_NOTIFY, IDT_INFO, (LPARAM)&mhdr );
	}
}
/*****************************************************************************
VOID ActionCrcIntoStream(CONST HWND arrHwnd[ID_NUM_WINDOWS])
	arrHwnd : (IN) window handle array

Return Value:
	returns nothing

Notes:
	- wrapper for the three parameter version
	- calls FillFinalList to get its list
*****************************************************************************/
VOID ActionCrcIntoStream(CONST HWND arrHwnd[ID_NUM_WINDOWS])
{
	list<FILEINFO*> finalList;

	if(CheckIfRehashNecessary(arrHwnd,MODE_SFV))
		return;

	FillFinalList(arrHwnd[ID_LISTVIEW],&finalList,ListView_GetSelectedCount(arrHwnd[ID_LISTVIEW]));
	if(finalList.size()>1) {
		finalList.sort(ListPointerCompFunction);
		finalList.unique(ListPointerUniqFunction);
	}

	ActionCrcIntoStream(arrHwnd,FALSE,&finalList);
}
void AP_Win32Dialog_CollaborationAccounts::_updateSelection()
{
	bool hasSelection = ListView_GetSelectedCount(m_hAccountList);
	if (hasSelection)
	{
		// TODO: Uncomment this line when Preferences does something.
		//m_pWin32Dialog->enableControl(AP_RID_DIALOG_COLLABORATIONACCOUNTS_PROPERTIES_BUTTON, true);
		m_pWin32Dialog->enableControl(AP_RID_DIALOG_COLLABORATIONACCOUNTS_DELETE_BUTTON, true);
	}
	else
	{
		m_pWin32Dialog->enableControl(AP_RID_DIALOG_COLLABORATIONACCOUNTS_PROPERTIES_BUTTON, false);
		m_pWin32Dialog->enableControl(AP_RID_DIALOG_COLLABORATIONACCOUNTS_DELETE_BUTTON, false);
	}
}
/*****************************************************************************
VOID ActionCrcIntoFilename(CONST HWND arrHwnd[ID_NUM_WINDOWS],BOOL noPrompt,list<FILEINFO*> *finalList)
	arrHwnd		: (IN) window handle array
	noPrompt	: (IN) determines if confirmation prompt is displayed
	finalList	: (IN) pointer to list of fileinfo pointers on which the action is to be performed

Return Value:
	returns nothing

Notes:
	- Renames the files in the list
	- noPrompt is used to suppress the prompt when called by the shell extension
*****************************************************************************/
VOID ActionHashIntoFilename(CONST HWND arrHwnd[ID_NUM_WINDOWS], BOOL noPrompt, list<FILEINFO*> *finalList, UINT uiHashType)
{
	TCHAR szFilenameTemp[MAX_PATH_EX];
	BOOL bAFileWasProcessed;
	FILEINFO * pFileinfo;
	UINT uiNumSelected;

	uiNumSelected = ListView_GetSelectedCount(arrHwnd[ID_LISTVIEW]);

	if(noPrompt || MessageBox(arrHwnd[ID_MAIN_WND],
				(uiNumSelected?
				TEXT("\'OK\' to put the hash value into the filename of the selected files"):
				TEXT("\'OK\' to put the hash value into the filename of the files that are missing a hash")),
				TEXT("Question"),
				MB_OKCANCEL | MB_ICONQUESTION | MB_APPLMODAL | MB_SETFOREGROUND) == IDOK){
		bAFileWasProcessed = FALSE;
		for(list<FILEINFO*>::iterator it=finalList->begin();it!=finalList->end();it++) {
			pFileinfo = (*it);
            if(uiNumSelected || (pFileinfo->dwError == NO_ERROR) && (pFileinfo->hashInfo[uiHashType].dwFound != HASH_FOUND_FILENAME) ){
					bAFileWasProcessed = TRUE;
                    GenerateNewFilename(szFilenameTemp, pFileinfo->szFilename, pFileinfo->hashInfo[uiHashType].szResult, g_program_options.szFilenamePattern);
					if(MoveFile(pFileinfo->szFilename, szFilenameTemp)){
                        pFileinfo->szFilename = szFilenameTemp;
                        pFileinfo->szFilenameShort = pFileinfo->szFilename.GetBuffer() + lstrlen(pFileinfo->parentList->g_szBasePath);
						// this updates pFileinfo->szFilenameShort automatically
                        memcpy((BYTE *)&pFileinfo->hashInfo[uiHashType].f, (BYTE *)&pFileinfo->hashInfo[uiHashType].r, g_hash_lengths[uiHashType]);
						pFileinfo->hashInfo[uiHashType].dwFound = HASH_FOUND_FILENAME;
                        UpdateFileInfoStatus(pFileinfo, arrHwnd[ID_LISTVIEW]);
					}
					else{
						pFileinfo->dwError = GetLastError();
						StringCchPrintf(szFilenameTemp, MAX_PATH_EX,
							TEXT("Error %u occured while renaming file :\r\n %s"),
							pFileinfo->dwError, pFileinfo->szFilenameShort);
						MessageBox(arrHwnd[ID_MAIN_WND], szFilenameTemp, TEXT("Error"), MB_OK);
					}
			}
		}
		if(bAFileWasProcessed){
			UpdateListViewStatusIcons(arrHwnd[ID_LISTVIEW]);
			DisplayStatusOverview(arrHwnd[ID_EDIT_STATUS]);
            InvalidateRect(arrHwnd[ID_LISTVIEW], NULL, FALSE);
		}
		else
			MessageBox(arrHwnd[ID_MAIN_WND], TEXT("No files missing a found"), TEXT("Info"), MB_OK);
	}
	return;
}
/// Function name  : onDependenciesLoadSelectedScripts
// Description     : Loads the selected script dependencies
// 
// PROPERTIES_DATA*  pSheetData   : [in] Properties sheet dialog data
// HWND              hPage        : [in] Window handle of the dependencies page
// 
VOID   onDependenciesPage_LoadSelectedScripts(HWND  hPage, SCRIPT_FILE*  pScriptFile, AVL_TREE*  pDependenciesTree)
{
   SCRIPT_DEPENDENCY*   pDependency;      // ScriptDependency associated with the selected item
   LOADING_OPTIONS      oOptions;         // Used for highlighting caller
   HWND                 hListView;        // Dependencies ListView
   TCHAR*               szFolder;         // Folder of input script
   LIST*                pDependencyList;  // List of selected ScriptDepdencies
   INT                  iSelected;        // Index of the selected item
            
   /// [CHECK] Are any dependencies selected?
   if (ListView_GetSelectedCount(hListView = GetDlgItem(hPage, IDC_DEPENDENCIES_LIST)) == 0)
      return;
   
   // [VERBOSE]
   CONSOLE_COMMAND();

   // Prepare
   utilZeroObject(&oOptions, LOADING_OPTIONS);
   pDependencyList = createList(NULL);
   
   /// Extract ScriptDependencies for selected scripts
   for (iSelected = ListView_GetSelected(hListView); findObjectInAVLTreeByIndex(pDependenciesTree, iSelected, (LPARAM&)pDependency); iSelected = ListView_GetNextItem(hListView, iSelected, LVNI_SELECTED))
   {
      appendObjectToList(pDependencyList, (LPARAM)pDependency);
      debugScriptDependency(pDependency);
   }

   // Clear selection
   ListView_SetItemState(hListView, -1, NULL, LVIS_SELECTED);
   szFolder = utilDuplicateFolderPath(pScriptFile->szFullPath);

   /// Attempt to open each selected script
   for (LIST_ITEM*  pIterator = getListHead(pDependencyList); pDependency = extractListItemPointer(pIterator, SCRIPT_DEPENDENCY); pIterator = pIterator->pNext)
   {
      //// Highlight Scriptcall on load
      //oOptions.bHighlight = TRUE;
      //StringCchCopy(oOptions.szSearchText, 256, pScriptFile->szScriptname);

      /// Attempt to open .pck / .xml version of script
      if (!commandLoadScriptDependency(getMainWindowData(), szFolder, pDependency, !pIterator->pNext, &oOptions))  // Activate the final document
         // [ERROR] "The script dependency '%s' could not be found in '%s'"
         displayMessageDialogf(hPage, IDS_GENERAL_DEPENDENCY_NOT_FOUND, MDF_OK WITH MDF_ERROR, pDependency->szScriptName, szFolder);
   }

   // Cleanup
   deleteList(pDependencyList);
   utilDeleteString(szFolder);
}