Exemple #1
0
void
AdjustHyperLink(
	HWND hWndStatic,
	CHyperLink& wndHyperLink)
{
	CString strHyperLink;
	CString strHyperLinkText;

	strHyperLink.LoadString(IDS_ABOUTDLG_HYPERLINK);

	if (0 == strHyperLink.CompareNoCase(_T("about:")))
	{
		//
		// when the hyperlink is not set, do not use hyperlink
		//
		HKEY hKey;
		LONG lResult = ::RegOpenKey(HKEY_LOCAL_MACHINE, _T("Software\\NDAS\\Install"), &hKey);
		if (ERROR_SUCCESS != lResult)
		{
			ATLTRACE(_T("Cannot open the registry key\n"));
			return;
		}
		const DWORD cchMaxValue = 255;
		DWORD cbSize = cchMaxValue * sizeof(TCHAR);
		lResult = ::RegQueryValueEx(
			hKey, 
			_T("SupportURL"),
			NULL, 
			NULL, 
			(LPBYTE) strHyperLink.GetBuffer(cchMaxValue),
			&cbSize);
		if (ERROR_SUCCESS != lResult)
		{
			ATLTRACE(_T("Cannot read Support URL\n"));
			return;
		}
		ATLTRACE(_T("SupportURL: %s\n"), strHyperLink);
		lResult = ::RegQueryValueEx(
			hKey,
			_T("SupportText"),
			NULL,
			NULL,
			(LPBYTE) strHyperLinkText.GetBuffer(cchMaxValue),
			&cbSize);
		if (ERROR_SUCCESS != lResult)
		{
			strHyperLinkText = strHyperLink;
		}
		ATLTRACE(_T("SupportText: %s\n"), strHyperLinkText);

		wndHyperLink.SubclassWindow(hWndStatic);
		wndHyperLink.SetHyperLink(strHyperLink);
		wndHyperLink.SetLabel(strHyperLinkText);
	}
	else
	{
		wndHyperLink.SubclassWindow(hWndStatic);
		wndHyperLink.SetHyperLink(strHyperLink);
	}
}
Exemple #2
0
void CMainTab::StandardizeHyperLink(CHyperLink& HyperLink, HICON hIcon)
{
	HyperLink.SetFont(_T("Arial"), 16, FW_NORMAL, false/*bItalic*/);
	HyperLink.UnderlineAlways(false);
	HyperLink.IsLink(false);
	HyperLink.SetColors(RGB(0,0,255)/*crLinkUp*/, RGB(0,0,0)/*crLinkHover*/, RGB(100,100,100)/*crLinkDown*/, GetSysColor(COLOR_BTNFACE)/*crBackGround*/);
	if (hIcon)
		HyperLink.SetIcons(hIcon/*Up*/, hIcon/*Hover*/, hIcon/*Down*/, CHyperLink::SI_ICONUP_ON|CHyperLink::SI_ICONHOVER_ON|CHyperLink::SI_ICONDOWN_ON/*uShowIcons*/);
}
/**
 * @brief WM_DESTROY handler of simplified dialog.
 * @param hwnd - window handle.
 */
static void SimpleDlg_OnDestroy(HWND hwnd)
{
	hwnd;

	g_hlURL.Detach();
	g_hlMailTo.Detach();

	if (g_hwndToolTip)
	{
		DestroyWindow(g_hwndToolTip);
		g_hwndToolTip = NULL;
	}
}
static BOOL CALLBACK AboutDlgProc(
                                    HWND hDlg,
                                    UINT message,
                                    WPARAM wParam,
                                    LPARAM lParam
                                    )
{
    //DEBUGMESSAGE(("AboutDlgProc"));

    switch (message)
    {
    case WM_INITDIALOG:
        {
            DEBUGMESSAGE(("AboutDlgProc - WM_INITDIALOG"));
            LPPROPSHEETPAGE page = (LPPROPSHEETPAGE ) lParam;
    
            // attach to our property sheet page an instance of our data holder class
            CHyperLink *hyperLink = new CHyperLink();
            SetWindowLongPtr(hDlg, DWL_USER, (LONG) hyperLink);

            // transform the static text into an hyperlink!
            // it couldn't be easier - many thanks to Olivier Langlois
            hyperLink->ConvertStaticToHyperlink(
                        hDlg, IDC_PROJECT_URL,
                        TEXT("http://emfprinter.sourceforge.net"));

            // set about text
            TCHAR txt[256];
            StringCchPrintf(txt, 256, 
                TEXT("This is EmfPrinter %d.%d.%d by Francesco Montorsi (c) 2007.\n")
                TEXT("Licensed under the terms of the GNU General Public License."),
                emfVERSION_MAJOR, emfVERSION_MINOR, emfVERSION_RELEASE);
            HWND hwnd = GetDlgItem(hDlg, IDC_ABOUT_TEXT);
            SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)txt);
        } 
        break;

    default:
        //DEBUGMESSAGE(("AboutDlgProc - unhandled message %d", message));
        return FALSE;
    }

    return TRUE;
}
/**
 * @brief Initialize dialog controls.
 * @param hwnd - window handle.
 */
static void InitControls(HWND hwnd)
{
	HWND hwndMailTo = GetDlgItem(hwnd, IDC_MAILTO);
	HWND hwndSubmitBug = GetDlgItem(hwnd, IDC_SUBMIT_BUG);
	HWND hwndMore = GetDlgItem(hwnd, IDC_MORE);
	HWND hwndClose = GetDlgItem(hwnd, IDCANCEL);

	g_hlMailTo.Attach(hwndMailTo);
	g_hwndToolTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX,
	                               CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
	                               hwnd, NULL, g_hInstance, 0l);
	if (g_hwndToolTip)
	{
		RECT rcCtl;
		GetClientRect(hwndClose, &rcCtl);
		SendMessage(g_hwndToolTip, TTM_SETMAXTIPWIDTH, 0, rcCtl.right * 2);

		TOOLINFO tinfo;
		ZeroMemory(&tinfo, sizeof(tinfo));
		tinfo.cbSize = sizeof(tinfo);
		tinfo.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
		tinfo.hinst = g_hInstance;

		tinfo.uId = (UINT_PTR)hwndMailTo;
		tinfo.lpszText = (PTSTR)IDS_MAILTO_TIP;
		SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);

		tinfo.uId = (UINT_PTR)hwndSubmitBug;
		tinfo.lpszText = (PTSTR)IDS_SUBMIT_BUG_TIP;
		SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);

		tinfo.uId = (UINT_PTR)hwndMore;
		tinfo.lpszText = (PTSTR)IDS_MORE_TIP;
		SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);

		tinfo.uId = (UINT_PTR)hwndClose;
		tinfo.lpszText = (PTSTR)IDS_CLOSE_TIP;
		SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
	}

	if (*g_szSupportHost == _T('\0') || g_nSupportPort == 0)
	{
		ShowWindow(hwndMailTo, SW_HIDE);
		if (*g_szSupportEMail == _T('\0'))
			EnableWindow(hwndSubmitBug, FALSE);
	}
	else
	{
		if (*g_szSupportEMail == _T('\0'))
			ShowWindow(hwndMailTo, SW_HIDE);
	}

	HWND hwndFocus = IsWindowEnabled(hwndSubmitBug) ? hwndSubmitBug : hwndClose;
	SetFocus(hwndFocus);
	SendMessage(hwnd, DM_SETDEFID, GetDlgCtrlID(hwndFocus), 0l);
}
Exemple #6
0
LRESULT CALLBACK CHyperLink::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	//pointer la obiectul de clasa CHyperLink ce are ca fereastra hWnd.
	CHyperLink* pThis = (CHyperLink*)GetWindowLongPtrW(hWnd, GWL_USERDATA);

	if (pThis)
		switch (uMsg)
	{
		case WM_SETTEXT:
			{
				HDC hDC = GetDC(hWnd);
				RECT rect = {0};
				WCHAR* wsText = (WCHAR*)lParam;
				DrawText(hDC, wsText, -1, &rect, DT_CALCRECT);
				//se redimensioneaza controlul.
				SetWindowPos(hWnd, 0, 0, 0, rect.right, rect.bottom, SWP_NOMOVE | SWP_NOZORDER);
				ReleaseDC(hWnd, hDC);
			}
			break;

		case WM_PAINT: pThis->OnPaint(); return 0;
		case WM_LBUTTONUP: 
			{
				if (pThis->m_bIsLink)
					pThis->onClickProc();
				break;
			}

		//trimis cand cursorul mouse-ului paraseste controlul
		case WM_MOUSELEAVE:
			{
				if (pThis->m_bUnderline)
				{
					pThis->m_bUnderline = false;
					InvalidateRect(hWnd, 0, 1);
				}
			}
			break;
		case WM_MOUSEMOVE: pThis->OnMouseMove(); break;
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Exemple #7
0
void CAboutDlg::LeftAlignHyperLinkLabel(CHyperLink& hl)
{
	CRect rLinkCtl;
	hl.GetClientRect(&rLinkCtl);

	CRect rLinkLabel(hl.m_rcLink);	
	rLinkLabel.OffsetRect(rLinkCtl.left - rLinkLabel.left, 0);
	
	CopyRect(&hl.m_rcLink, rLinkLabel);
}
Exemple #8
0
void CMainFrame::OnLanguageSelection( UINT nID ) 
{
    CDocTemplate*	pTemplate = NULL;
    POSITION		pos;
    CDocument*		pDocument = NULL;

	int nLanguageSelection = nID - ID_LANGUAGE_START;


	if ( 0 == nLanguageSelection )
	{
		WORD nLanguage;

		CHyperLink myLink;

		CUString strVersions;
		// FIXME
		strVersions.Format( _W("cdexversion=1.70&beta=8&cdexdir=%s" ), (LPCWSTR)g_config.GetAppPath() );

		for ( nLanguage=0; nLanguage < g_language.GetNumLanguageStrings(); nLanguage++)
		{
			CUString strLangName( g_language.GetLanguageString( nLanguage ) );
			CUString strLangVersion;
			strLangVersion.Format( _W("%s=%s"), (LPCWSTR)strLangName, (LPCWSTR)g_language.GetRevisionLevel( strLangName ) );
			strVersions += _W( "&" ) + strLangVersion;
		}

//		myLink.GotoURL( _T("www.cdex.n3.net/lang/langcheck.php?") + strVersions , SW_SHOW );
		myLink.GotoURL( _T("cdexos.sourceforge.net/lang/cdex_v1.70"), SW_SHOW );
	}
	else
	{
//		nLanguageSelection--;

		// Switch to selected language
		CString strMenu;

		m_pPopupMenu->GetMenuString( nLanguageSelection, strMenu, MF_BYPOSITION );

		g_language.SetLanguage( CUString( strMenu ) );

		// get document template
		pos = AfxGetApp()->GetFirstDocTemplatePosition();

		pTemplate = AfxGetApp()->GetNextDocTemplate( pos );

		POSITION docpos = pTemplate->GetFirstDocPosition( );

		// Loop through documents in this template
		while ( docpos )
		{
			VERIFY( pDocument = pTemplate->GetNextDoc(docpos) );

			// update all view attached to this document
			pDocument->UpdateAllViews( NULL,WM_CDEX_INITIAL_UPDATE, NULL );
		}

		g_config.SetLanguage( g_language.GetLanguage() );
		g_config.Save();

		SetLanguageMenu( );
	}
}
Exemple #9
0
HRESULT CHyperLink::NewProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
	CHyperLink *pHLink = (CHyperLink *)GetWindowLong(hWnd, GWL_USERDATA);
	if (pHLink == NULL || pHLink->m_hWnd == NULL) {
		return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	switch(uMsg) {
	case WM_LBUTTONDOWN:
		return 0;
	case WM_LBUTTONUP:	//左键up出发超链接,用上边的down也可以,看个人爱好。
		{
			TCHAR szUrl[MAX_URL_LEN] = {0};
			LPCTSTR lpszUrl;
			if(*pHLink->m_szUrl == _T('\0'))	//未指定url时,用控件本身text当作url。
			{
				GetWindowText(hWnd, szUrl, MAX_TEXT_LEN);
				lpszUrl = szUrl;
			}
			else
				lpszUrl = pHLink->m_szUrl;
			ShellExecute(NULL, _T("open"), lpszUrl, NULL, NULL, SW_SHOWNORMAL);
		}
		return 0;
	case WM_PAINT:		//绘制控件为超链接样式
		{
			COLORREF crText;
			if (pHLink->m_bMouseOn) {
				crText = RGB(255, 0, 0);
			}
			else{
				crText = RGB(0, 0, 255);
			}
			LPCTSTR lpszText;
			TCHAR szText[MAX_TEXT_LEN] = {0};

			if(*pHLink->m_szText == _T('\0'))	//未指定text时,用控件本身的。
			{
				GetWindowText(hWnd, szText, MAX_TEXT_LEN);
				lpszText = szText;
			}
			else
				lpszText = pHLink->m_szText;

			RECT rcDraw = {0};
			GetClientRect(pHLink->m_hWnd, &rcDraw);

			PAINTSTRUCT ps = {0};
			BeginPaint(hWnd, &ps);

			SelectObject(ps.hdc, pHLink->m_hFont);
			SetTextColor(ps.hdc, crText);
			SetBkMode(ps.hdc, TRANSPARENT);
			DrawText(ps.hdc, lpszText, -1, &rcDraw, DT_VCENTER | DT_SINGLELINE);	//这里为了偷懒用了整个客户区的rect,此处还可优化

			EndPaint(hWnd, &ps);
		}
		return TRUE;
	case WM_SETCURSOR:	//设置鼠标为手型
		SetCursor(LoadCursor(NULL, IDC_HAND));
		return TRUE;
	case WM_MOUSEMOVE:	
		pHLink->OnMouseMove(wParam, lParam);
		return 0;
	case WM_CAPTURECHANGED: //鼠标捕获结束,此消息重要
		pHLink->m_bMouseOn = FALSE;
		return 0;
	case WM_DESTROY:
		pHLink->Detach();
		break;
	default:
		break;
	}
	return CallWindowProc(pHLink->m_pOldProc, hWnd, uMsg, wParam, lParam);
}
Exemple #10
0
/*
 * Function CHyperLink::_HyperlinkProc
 *
 * Note: Processed messages are not passed back to the static control
 *       procedure. It does work fine but be aware that it could cause
 *       some problems if the static control is already subclassed.
 *       Consider the example where the static control would be already
 *       subclassed with the ToolTip control that needs to process mouse
 *       messages. In that situation, the ToolTip control would not work
 *       as expected.
 */
LRESULT CALLBACK CHyperLink::_HyperlinkProc(HWND hwnd, UINT message,
		                                   WPARAM wParam, LPARAM lParam)
{
	CHyperLink *pHyperLink = (CHyperLink *)GetProp(hwnd, PROP_OBJECT_PTR);

	switch (message)
	{
	case WM_MOUSEMOVE:
		{
			if ( pHyperLink->m_bOverControl )
			{
				// This is the most common case for static branch prediction
				// optimization
				RECT rect;
				GetClientRect(hwnd,&rect);

				POINT pt = { LOWORD(lParam), HIWORD(lParam) };

				if (!PTINRECT(&rect,pt))
				{
					ReleaseCapture();
				}
			}
			else
			{
				pHyperLink->m_bOverControl = TRUE;
				SendMessage(hwnd, WM_SETFONT,
					        (WPARAM)CHyperLink::g_UnderlineFont, FALSE);
				InvalidateRect(hwnd, NULL, FALSE);
				pHyperLink->OnSelect();
				SetCapture(hwnd);
			}
			return 0;
		}
	case WM_SETCURSOR:
		{
			SetCursor(CHyperLink::g_hLinkCursor);
			return TRUE;
		}
	case WM_CAPTURECHANGED:
		{
			pHyperLink->m_bOverControl = FALSE;
			pHyperLink->OnDeselect();
			SendMessage(hwnd, WM_SETFONT,
				        (WPARAM)pHyperLink->m_StdFont, FALSE);
			InvalidateRect(hwnd, NULL, FALSE);
			return 0;
		}
	case WM_KEYUP:
		{
			if( wParam != VK_SPACE )
			{
				break;
			}
		}
						// Fall through
	case WM_LBUTTONUP:
		{
			pHyperLink->Navigate();
			return 0;
		}
	case WM_SETFOCUS:	// Fall through
	case WM_KILLFOCUS:
		{
			if( message == WM_SETFOCUS )
			{
				pHyperLink->OnSelect();
			}
			else		// WM_KILLFOCUS
			{
				pHyperLink->OnDeselect();
			}
			CHyperLink::DrawFocusRect(hwnd);
			return 0;
		}
	case WM_DESTROY:
		{
			SetWindowLongPtr(hwnd, GWLP_WNDPROC,
				          (LONG) pHyperLink->m_pfnOrigCtlProc);

			SendMessage(hwnd, WM_SETFONT, (WPARAM) pHyperLink->m_StdFont, 0);

			if( --CHyperLink::g_counter <= 0 )
			{
				destroyGlobalResources();
			}

			RemoveProp(hwnd, PROP_OBJECT_PTR);
			break;
		}
	}

	return CallWindowProc(pHyperLink->m_pfnOrigCtlProc, hwnd, message,
		                  wParam, lParam);
}