Exemplo n.º 1
0
BOOL CSkinnedLabel::Attach(HWND hWnd)
{
TRY_CATCH

	ATLASSERT(::IsWindow(hWnd));
	BOOL bRet = CWindowImplEx<CSkinnedLabel, CStatic>::SubclassWindow(hWnd);
	TCHAR buf[MAX_PATH];

	/// Getting default text
	if (Text.empty())
	{
		if (FALSE == GetWindowText(buf, MAX_PATH))
		{
			Text = _T("Failed to get label text ");
			Log.WinError(_ERROR_,Text.c_str());
		}
		Text = buf;
	}

	/// Getting default font
	if (_tcscmp(Font.lfFaceName,NOFONT) == FALSE)
	{
		HFONT hFont = reinterpret_cast<HFONT>(SendMessage(WM_GETFONT, 0, 0));
		if (hFont != NULL)
		{
			LOGFONT font;
			if ( FALSE == GetObject(hFont, sizeof(LOGFONT), &font) )
				Log.WinError(_WARNING_,_T("Failed to get default font for label "));
			else
				Font = font;
		} else
			Log.WinError(_WARNING_,_T("Failed to get default font for label "));
	}

	/// Getting text alignment
	LONG style = GetWindowLong(GWL_STYLE);
	if (SS_CENTER == (style & SS_CENTER))
		TextAlign = DT_CENTER;
	else
	if (SS_RIGHT == (style & SS_RIGHT))
		TextAlign = DT_RIGHT;
	else
	if (SS_LEFT == (style & SS_LEFT))
		TextAlign = DT_LEFT;

	OnSkinChanged();
	return bRet;

CATCH_THROW()
}
BOOL CXTPSkinManager::LoadSkin(LPCTSTR lpszResourcePath, LPCTSTR lpszIniFileName)
{
    CMDTARGET_RELEASE(m_pSchema);

    CXTPSkinManagerApiHook* pApiHook = CXTPSkinManagerApiHook::GetInstance();
    pApiHook->FinalizeHookManagement();

    XTPSoundManager()->StopThread();

    BOOL bEnabled = m_bEnabled;

    if (XTPColorManager()->IsLowResolution() ||
            !CXTPSkinManagerModuleList::IsEnumeratorExists() ||
            !ReadSkinData(lpszResourcePath, lpszIniFileName))
    {
        m_bEnabled = FALSE;

        CMDTARGET_RELEASE(m_pSchema);

        XTPColorManager()->RefreshColors();

        OnSkinChanged(bEnabled, m_bEnabled);

        return FALSE;
    }

    m_bEnabled = TRUE;

    pApiHook->InitializeHookManagement();

    m_pSchema->RefreshMetrcis();
    XTPColorManager()->RefreshColors();

    OnSkinChanged(bEnabled, m_bEnabled);

    return TRUE;
}
static VOID CALLBACK OnSkinChangedAPC(ULONG_PTR param)
{
	HTMLControl *thisControl = (HTMLControl *)TlsGetValue(threadStorage);
	if (thisControl)
	{
		OnSkinChanged(thisControl);
		if (thisControl->m_pweb)
		{
			// if you want to update page uncomment this
			//	thisControl->m_pweb->Stop();
			//	thisControl->m_pweb->Refresh();
		}
		thisControl->Release();
	}
}
void CXTPSkinManager::SetApplyOptions(DWORD dwOptions)
{
    m_dwApplyOptions = dwOptions;

    if (!m_bEnabled)
        return;

    CXTPSkinManagerApiHook* pApiHook = CXTPSkinManagerApiHook::GetInstance();

    pApiHook->FinalizeHookManagement();
    pApiHook->InitializeHookManagement();

    m_pSchema->RefreshMetrcis();
    XTPColorManager()->RefreshColors();

    OnSkinChanged(m_bEnabled, m_bEnabled);
}
void CXTPSkinManager::RedrawAllControls()
{
    if (!m_bEnabled)
        return;

    if (!m_pSchema)
        return;

    POSITION pos = m_pSchema->m_mapClasses.GetStartPosition();
    CString strClassName;
    CXTPSkinManagerClass* pClass;
    while (pos != NULL)
    {
        m_pSchema->m_mapClasses.GetNextAssoc( pos, strClassName, (void*&)pClass);
        pClass->GetImages()->RemoveAll();
    }

    m_pSchema->GetMetrics()->RefreshMetrics();
    XTPColorManager()->RefreshColors();

    OnSkinChanged(TRUE, TRUE);
}
Exemplo n.º 6
0
LRESULT CSkinnedMsgBox::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY_CATCH

	//+create fonts
	HFONT font = GetFont();
	ATLASSERT(::GetObjectType(font) == OBJ_FONT);
	LOGFONT logFont;
	GetObject(font, sizeof(LOGFONT),&logFont);
	_tcscpy_s(logFont.lfFaceName, LF_FACESIZE, _T("Verdana")); 
	logFont.lfHeight = -11;
	Font = logFont;
	LOGFONT boldFont = Font;
	boldFont.lfWeight = FW_BOLD;
	LOGFONT underlinedFont = Font;
	underlinedFont.lfUnderline = TRUE;
	LOGFONT underlinedBoldFont = boldFont;
	underlinedBoldFont.lfUnderline = TRUE;
	LOGFONT smallFont = Font;
	smallFont.lfHeight = -11;
	//-create fonts

	/// Attaching controls
	m_okBtn.Attach(GetDlgItem(IDOK));
	m_okBtn.Font = boldFont;
	m_okBtn.FontColor1 = SCVUI_LBLFONTCOLOR1;
	m_okBtn.OnSkinChanged();

	m_cancelBtn.Attach(GetDlgItem(IDCANCEL));
	m_cancelBtn.Font = boldFont;
	m_cancelBtn.FontColor1 = SCVUI_LBLFONTCOLOR1;
	m_cancelBtn.OnSkinChanged();

	m_textLabel.Attach(GetDlgItem(IDC_TEXT_LBL));
	m_textLabel.Font = boldFont;
	m_textLabel.FontColor1 = SCVUI_LBLFONTCOLOR1;
	m_textLabel.FontColor2 = SCVUI_LBLFONTCOLOR1;
	m_textLabel.SetText(m_text);
	m_textLabel.OnSkinChanged();

	m_showAgainCheckBox.Attach(GetDlgItem(IDC_SHOWAGAIN_CHBOX));
	m_showAgainCheckBox.Font = smallFont;
	m_showAgainCheckBox.Font2 = smallFont;
	m_showAgainCheckBox.FontColor1 = SCVUI_BTNFONTCOLOR2;
	m_showAgainCheckBox.FontColor2 = SCVUI_LBLFONTCOLOR1;
	m_showAgainCheckBox.BkColor1 = SCVUI_LBLFONTCOLOR1;
	m_showAgainCheckBox.SetText(_T("Don't show me this dialog again"));
	m_showAgainCheckBox.OnSkinChanged();

	if (!m_showCheckBox)
		m_showAgainCheckBox.ShowWindow(SW_HIDE);

	if (!m_showCancel)
		m_cancelBtn.ShowWindow(SW_HIDE);
	
	//Proper window show happened here
	OnSkinChanged();

	return TRUE;

CATCH_THROW()
}
static DWORD CALLBACK IEThread(LPVOID param)
{
	HWND parent, hwndHost;

	parent = (HWND)param;
	OleInitialize(0);
	bShowOnNavigate = true;

	HTMLControl *thisControl = new HTMLControl();
	htmlControl= thisControl;
	TlsSetValue(threadStorage, thisControl);
	thisControl->CreateHWND(parent);
	SetEvent(threadEvent);

	OnSkinChanged(thisControl);

	hwndHost = thisControl->GetHostHWND();
	if (hwndHost)
	{
		SetWindowPos(hwndHost, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
		SubclassHost(hwndHost);
	}


	while (1)
	{
		DWORD dwStatus = MsgWaitForMultipleObjectsEx(0, NULL,
		                 INFINITE, QS_ALLINPUT,
		                 MWMO_ALERTABLE | MWMO_INPUTAVAILABLE);
		if (dwStatus == WAIT_OBJECT_0)
		{
			MSG msg;
			while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
			{
				if (msg.message == WM_QUIT)
				{
					OleUninitialize();
					return 0;
				}
				else if (msg.message == WM_USER+1111)
				{
					if (thisControl->m_pweb)
						thisControl->m_pweb->Stop();
					thisControl->remove();
					thisControl->close();
					thisControl->Release();
					thisControl=0;
					continue;
				}

				if (WM_KEYFIRST > msg.message || WM_KEYLAST < msg.message || !thisControl || !thisControl->translateKey(&msg))
				{
					if (!IsDialogMessage(parent, &msg))
					{
						TranslateMessage(&msg);
						DispatchMessage(&msg);
					}
				}
			}
		}
	}
}