Esempio n. 1
0
INT_PTR CALLBACK HighlightDlgProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
	static BOOL fMask = FALSE;

	static HWND	hwndHV;
	size_w	offset, length;
	BOOKMARK bm = {0};

	static TCHAR title[100];
	static TCHAR text[200];
	static int count;
	static HBOOKMARK hbm;

	switch (iMsg)
	{
	case WM_INITDIALOG:

		hwndHV = GetActiveHexView(GetParent(hwnd));
		//	GetOwner(hwnd);//

		SendDlgItemMessage(hwnd, IDC_NAME, EM_SETCUEBANNER, TRUE, (LPARAM)TEXT("Enter some descriptive text here"));
		SendDlgItemMessage(hwnd, IDC_ANNOTATION, EM_SETCUEBANNER, 0, (LPARAM)TEXT("Enter some descriptive text here"));

		//MakeColourCombo(GetDlgItem(hwnd, IDC_COMBO1), fgcollist, fgtextlist, 16);
		MakeColourCombo(GetDlgItem(hwnd, IDC_COMBO4), bgcollist, bgtextlist, 16);

		hbm = (HBOOKMARK)lParam;

		if(hbm == 0)
		{
			HexView_GetSelStart(hwndHV, &offset);
			HexView_GetSelSize(hwndHV, &length);

			wsprintf(title, TEXT("bookmark-%03d"), ++count);
			//lstrcpy(title, TEXT(""));//TEXT("Enter some descriptive text here"));
			lstrcpy(text, TEXT(""));//TEXT("Enter some descriptive text here"));
		}
		else
		{
			HBOOKMARK hbm = (HBOOKMARK)lParam;
			BOOKMARK bm;

			HexView_GetBookmark(hwndHV, hbm, &bm);

			offset = bm.offset;
			length = bm.length;
			lstrcpy(title, bm.pszTitle);
			lstrcpy(text, bm.pszText);

			// Set the selected color
			for (int i = 0; i < 16; i++)
			{
				if (bm.backcol == bgcollist[i])
				{
					SendMessage(GetDlgItem(hwnd, IDC_COMBO4), CB_SETCURSEL, i, 0);
					break;
				}
			}
		}

		SetDlgItemBaseInt(hwnd, IDC_OFFSET, offset, 16, 1);
		SetDlgItemBaseInt(hwnd, IDC_LENGTH, length, 16, 1);
		SetDlgItemText(hwnd, IDC_NAME, title);
		SetDlgItemText(hwnd, IDC_ANNOTATION, text);
	
	//ClientToScreen(hwndParent, &pt);
		//GetCursorPos(&pt);
		//SetWindowPos(hwnd, 0, pt.x, pt.y, 0, 0, SWP_NOSIZE);
		CenterWindow(hwnd);
		return TRUE;
			
	case WM_CLOSE:
		EndDialog(hwnd, FALSE);
		return TRUE;
	
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDOK:
	
			GetDlgItemText(hwnd, IDC_ANNOTATION, text, 200);
			GetDlgItemText(hwnd, IDC_NAME, title, 100);

			bm.col		= 0;
			bm.backcol	= GetColourComboRGB(GetDlgItem(hwnd, IDC_COMBO4));//RGB(rand()+128, rand()+128, rand()+128);//0xffffff;
			bm.pszText	= text;
			bm.pszTitle = title;
			bm.offset	= GetDlgItemBaseInt(hwnd, IDC_OFFSET, 16);
			bm.length	= GetDlgItemBaseInt(hwnd, IDC_LENGTH, 16);
		
			if(hbm == 0)
			{
				HexView_AddBookmark(hwndHV, &bm);
			}
			else
			{
				HexView_SetBookmark(hwndHV, hbm, &bm);
			}
//
			DockWnd_UpdateContent(g_hwndMain, DWID_HIGHLIGHT);
			///UpdateHighlights(hwndHV, hwndGridView);

			EndDialog(hwnd, TRUE);
			return 0;

		case IDCANCEL:
			EndDialog(hwnd, FALSE);
			return 0;

		default:
			return FALSE;
		}

	default:
		break;
	}
	return FALSE;

}
Esempio n. 2
0
INT_PTR CALLBACK DisplayOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND	hwndPreview;

	switch(msg)
	{
	case WM_INITDIALOG:

		MakeFontCombo(hwnd, GetDlgItem(hwnd, IDC_FONTLIST));

		MakeColourCombo(GetDlgItem(hwnd, IDC_FGCOLCOMBO), crDefault, szTextList, 17);
		MakeColourCombo(GetDlgItem(hwnd, IDC_BGCOLCOMBO), crDefault, szTextList, 17);

		SetComboItemHeight(GetDlgItem(hwnd, IDC_FGCOLCOMBO), 14);
		SetComboItemHeight(GetDlgItem(hwnd, IDC_BGCOLCOMBO), 14);

		InitSizeList(GetDlgItem(hwnd, IDC_SIZELIST), TEXT("Courier New"));

		InitHexPreview(GetDlgItem(hwnd, IDC_HEXVIEW_PREVIEW));

	//
	//	Subclass the PREVIEW static control so we can custom-draw it
	//
	hwndPreview = GetDlgItem(hwnd, IDC_PREVIEW);
	oldPreviewProc = (WNDPROC)SetWindowLongPtr(hwndPreview, GWLP_WNDPROC, (LONG_PTR)PreviewWndProc);

		//AddColourListItem(hwnd, IDC_ITEMLIST, -1,				HVC_BACKGROUND,   TEXT("Background"));	
		AddColourListItem(hwnd, IDC_ITEMLIST, HVC_ADDRESS,		HVC_BACKGROUND,   TEXT("Address Column"));
		AddColourListItem(hwnd, IDC_ITEMLIST, HVC_HEXEVEN,		HVC_BACKGROUND,   TEXT("Hex Odd Columns"));
		AddColourListItem(hwnd, IDC_ITEMLIST, HVC_HEXODD,		HVC_BACKGROUND,   TEXT("Hex Even Columns"));
		AddColourListItem(hwnd, IDC_ITEMLIST, HVC_ASCII,		HVC_BACKGROUND,   TEXT("Ascii Column"));
		AddColourListItem(hwnd, IDC_ITEMLIST, HVC_SELECTION,	HVC_SELECTION,	  TEXT("Selected Data"));
		AddColourListItem(hwnd, IDC_ITEMLIST, HVC_SELECTION,	HVC_SELECTION,	  TEXT("Inactive Selection"));
		//AddColourListItem(hwnd, IDC_ITEMLIST, -1,					HVC_LONGLINE,	  TEXT("Modified Bytes"));
		//AddColourListItem(hwnd, IDC_ITEMLIST, HVC_CURRENTLINETEXT, HVC_CURRENTLINE,  TEXT("Current Line"));

		return TRUE;

	case WM_COMMAND:
		
		if(HIWORD(wParam) == LBN_SELCHANGE || HIWORD(wParam) == CBN_SELCHANGE)
		{
			int idx;
			

			switch(LOWORD(wParam))
			{
			case IDC_ITEMLIST:
				idx = SendDlgItemMessage(hwnd, IDC_ITEMLIST, LB_GETCURSEL, 0, 0);
				g_crPreviewFG = HexView_RealiseColour(g_colorItem[idx].fgColor);
				g_crPreviewBG = HexView_RealiseColour(g_colorItem[idx].bgColor);
				InvalidateRect(GetDlgItem(hwnd, IDC_PREVIEW), 0, 0);

				break;

			case IDC_SIZELIST:
			case IDC_FONTLIST:
				UpdateFontPreview(hwnd);
				break;
			}
		}
		


		return 0;

	case WM_MEASUREITEM:
		// can't do anything here because we haven't created
		// the fonts yet, so send a manual CB_SETITEMHEIGHT instead
		return FALSE;
	}

	return FALSE;
}