Esempio n. 1
0
BOOL LoadHighlights(HWND hwndHexView)
{
	TCHAR szBookPath[MAX_PATH];

	if(!GetBookmarkFileName(hwndHexView, NULL, szBookPath))
		return FALSE;

	HexView_ClearBookmarks(hwndHexView);
	EnumHighlights(szBookPath, AddBookmarkCallback, hwndHexView);

	return TRUE;
}
Esempio n. 2
0
BOOL SaveHighlights(HWND hwndHexView)
{
	TCHAR szBookPath[MAX_PATH];
	TCHAR szFilePath[MAX_PATH];
	BOOKMARK bm;
	HBOOKMARK hbm;
	HCONFIG config, filedata, bookmarks;

	if (!GetBookmarkFileName(hwndHexView, NULL, szBookPath))
		return FALSE;

	config	  = CreateConfig();
	filedata  = CreateConfigSection(config, TEXT("hexFileData"));

	HexView_GetFileName(hwndHexView, szFilePath, MAX_PATH);

	// only save if the file exists
	if(GetFileAttributes(szFilePath) != INVALID_FILE_ATTRIBUTES)
	{
		SetConfigStr(filedata, TEXT("filePath"), szFilePath);
	}

	bookmarks = CreateConfigSection(filedata, TEXT("bookmarks"));

	for(hbm = 0; (hbm = HexView_EnumBookmark(hwndHexView, hbm, &bm)) != 0; )
	{
		if((bm.flags & HVBF_NOPERSIST) == 0)
		{
			HCONFIG bookmark = CreateConfigSection(bookmarks, TEXT("bookmark"));

			SetConfigStr(bookmark, TEXT("name"), bm.pszTitle);
			SetConfigStr(bookmark, TEXT("desc"), bm.pszText);
			SetConfigI64(bookmark, TEXT("offset"), bm.offset);
			SetConfigI64(bookmark, TEXT("length"), bm.length);
			SetConfigH32(bookmark, TEXT("fgcol"), bm.col);
			SetConfigH32(bookmark, TEXT("bgcol"), bm.backcol);
		}
	}

	SaveConfig(szBookPath, config);

	return TRUE;
}
Esempio n. 3
0
BOOL UpdateHighlight(LPCTSTR pszFilePath, TCHAR * pszBookPath, BOOL fAlways)
{
	HWND hwndGV;
	HWND hwndHV;

	HGRIDITEM hItem  = 0;  
	GVITEM    gvitem = { GVIF_TEXT };

	// get the bookmark window's gridview
	if ((hwndGV = GetDlgItem(GetBookmarkWnd(), IDC_HIGHLIGHT_GRIDVIEW)) == 0)
		return FALSE;

	// find the gridview item for specified filename
	// (search for the matching filename)
	if(pszFilePath)
	{
		gvitem.pszText = (WCHAR *)pszFilePath;
		hItem = GridView_FindChild(hwndGV, NULL, &gvitem);
	}

	// file already open?
	if((hwndHV = HexIsOpen(g_hwndMain, pszFilePath, 0)) != 0)
	{
		// yes - update bookmarks from the hexview
		if(hItem == 0)
			hItem = CreateBookmarkFileRoot(GVI_ROOT, pszFilePath, hwndGV, TRUE);

		gvitem.mask  = GVIF_PARAM|GVIF_FONT;
		gvitem.iFont = 1; // bold
		gvitem.param = (UINT64)hwndHV;
		GridView_SetItem(hwndGV, hItem, &gvitem);

		GridView_DeleteChildren(hwndGV, hItem);
		FillHexViewHighlights(hItem, hwndHV, hwndGV, RGB(0,0,0));
		//		UpdateHighlights(
	}
	else if(fAlways)
	{
		// no - update bookmarks from the bookmark file
		TCHAR szBookPath[MAX_PATH] = { 0 };

		if(pszBookPath == 0)
		{
			pszBookPath = szBookPath;
			GetBookmarkFileName(0, pszFilePath, pszBookPath);
		}

		//if(hItem == 0 && pszFilePath)
		//	hItem = CreateBookmarkFileRoot(GVI_ROOT, pszFilePath, hwndGV, FALSE);

		UpdateHighlightsFromConfig(hItem, hwndGV, pszBookPath, RGB(128, 128, 128));

		InvalidateRect(hwndGV, 0, 0);
	}
	else 
	{
		if(hItem)
			GridView_DeleteItem(hwndHV, hItem);
	}
	//UpdateHighlights(

	return TRUE;
}