I want to display the body font of emails from a certain sender in Courier New, or another fixed size font, because they contain ASCII tables. All other messages should use the Outlook 2010 default font.
Note that I don't care about the font used in the view pane (conditional formatting rules in View settings), or setting the default body font for all messages. I'm asking about an automatic, conditionally set font based on the sender email.
If it is not possible to automatically change the message font, what's the quickest way to switch between fonts, when reading and composing messages?
You cannot do that out of the box, especially for a received message that is considered read-only.
For the messages that you compose, you can change the font style using something like the following:
'set Msg = Application.ActiveExplorer.Selection(1)
set Msg = Application.ActiveInspector.CurrentItem
set insp = Msg.GetInspector
set doc = insp.WordEditor
for each p in doc.Paragraphs
set r = p.Range
r.Font.Name = "Arial"
r.Font.Size = 14
r.Select
next
Related
I'm maintaining a VB6 application that makes extensive use of the old VBAccelerator SGrid 2.0 (vbalGrid, using another Grid control isn't really an option). I need to change the grids font at run-time, and nothing I seem to do works to change the header font, only changing the grid controls Font property at design time seems to actually change the font.
Here is the code I've tried, which I would have thought would work:
Dim Fnt As New StdFont
Set Fnt = vbalGrid.Font
Fnt.Name = "MS Sans Serif"
Set vbalGrid.Font = Fnt
This sets the font for the body of the grid just fine, but you do have to clear and repopulate the grid if it already has data. However the header doesn't change, even if you clear all the columns and recreate them.
It looks like there is a bug in the Property Set Font routine -- it does not call BuildMemDC to invalidate its buffered output DC.
Try RowHeight(1) = RowHeight(1) + 1 or similar nudge to force BuildMemDC getting called. You'll have to increase the height of some row above its internal m_lMaxRowHeight variable for the rebuild to kick in.
In the sample of CKEditor, the Font Name and Font Size dropdown have a item which is (default), which gives user to change the Font Name and Size back to the default setting.
Which when choose the default item in these two dropdown, the span created for specifying Font Name and Size was removed when we inspect the source of the content.
source: https://ckeditor.com/latest/samples/index.html
However, when i google through how to set this configuration, the normal answer is to set the default label, which can't achieve the effect shown in the sample.
May i ask how to set the configuration in order to achieve the same effect shown in the example?
Thanks a lot.
I'm not sure if this is exactly what you meant but if you are asking how to set default font through JavaScript then the answer is you can't do that. The default font can only be set in ckeditor/contents.css (look for the body element definition) for classic editor or main page CSS file for inline editor.
If you have set default font (inside your CSS) to Times New Roman, you can also set default font label to the same value so that default font is being shown whenever there is no matching font in current selection. Please see:
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-font_defaultLabel
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-font_names
Same can be done for Font Size:
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-fontSize_defaultLabel
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-fontSize_sizes
Please note that font dropdowns are not fully context sensitive meaning they only show given font name or size if there is an exact match. If CKEditor sets e.g. <span style="font-family:Courier New,Courier,monospace">test</span> the Font Dropdown will only display name Courier New if you have exactly span element with Courier New,Courier,monospace as font-family value inside set in your HTML. In all other cases "Default" label or default font name (if you have set font_defaultLabel) will be shown. This of course can lead to problems when you paste fonts (e.g. from MS Word) which are not defined in dropdown definition. In such a case editor will show invalid values because it will use Default label or default font name.
Problem can be worked around with the help of Advanced Content Filter (ACF) and addTransformations method. I have explained it briefly here.
Hope this helps.
I'm setting up the preferences window for my cool app, which displays some text. In preferences I've set up a button that opens an NSFontPanel. My app stores the user's preferred text color and font, and always opens with those settings so that the user never has to see text displayed in a color or font they don't prefer.
The problem is, while my app is able to remember these preferences, the NSFontPanel has trouble. When I first open the font panel, the default values for all the fields are reset. After fiddling with them, closing the panel, and then reopening it, the correct values are retained. The problem only occurs when I first open the panel.
I don't understand why this is happening!
I've been careful to set the font and color for the panel when my app starts, as you can see from this snippet:
def show_entry_font_menu(sender)
font_manager = NSFontManager.sharedFontManager
color_panel = NSColorPanel.sharedColorPanel
font_manager.setDelegate self
color_panel.setDelegate self
font_manager.setSelectedFont(preferences.entry_font, isMultiple:false)
font_panel = font_manager.fontPanel(true)
font_panel.makeKeyAndOrderFront(sender)
attributes = preferences.entry_font_attributes
color = preferences.entry_font_color
font_manager.setSelectedAttributes(attributes, isMultiple:false)
color_panel.setColor(color) if preferences.entry_font_color
self.did_open_font_panel = true
end
There is an oddness in initializing the sharedFontPanel. If you set the font before creating it the first time, that works fine, but setting attributes does not.
What you have to do is makeKeyAndOrderFront first, and then set the attributes. Once the panel has been thus created the first time it will properly reflect setSelectedAttributes.
font_panel.makeKeyAndOrderFront(sender)
font_manager.setSelectedAttributes(attributes, isMultiple:false)
When creating a control (e.g. an edit control) on the fly using CreateWindow, it usually starts out with an ugly (boldish sans serif) font.
Usually I wok around that by grabbing the parent dialog's font, and setting it to the control - I can't even say if this is a good idea.
How do I "legally" fetch the right font?
The "correct" way to get the font used in dialog boxes like message boxes, etc. would be via the SystemParametersInfo() function:
// C++ example
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(NONCLIENTMETRICS);
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&metrics, 0);
HFONT font = ::CreateFontIndirect(&metrics.lfMessageFont);
::SendMessage(ctrlHWND, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));
Don't forget to destroy the font when the controls are destroyed:
::DeleteObject(font);
You can look up the MSDN documentation for NONCLIENTMETRICS and SystemParametersInfo() to see what other system-wide parameters you can retrieve.
In VB6, I have a DTPicker control on a form. (The DTPicker is the calendar date/time selector, included in Microsoft Windows Common Controls-2 6.0, available from the Components dialog.)
While there are many properties to affect the colors of the calendar when it's dropped down, there is no property that allows changing the color of the date that's displayed in the textbox. I'm looking for something like the standard TextBox's ForeColor property.
Does anyone have a little API magic to allow me to simulate that property?
I hate to post something that is not really helpful, but this appears to be something beyond the scope of what Microsoft intended developers to do with the control. While there must certainly be an API call to set the color (Windows certainly knows to paint it black when enabled and gray when disabled), the method to do so escapes me.
My recommendation, should no one else respond with how to do what you need, is to either obtain a new DateTime Picker control with the needed properties (it would seem that there are a few 3rd party options), or "roll your own" control.
FWIW, this same issue exists in VB.NET with the exception being that Microsoft specifically overrides (and then hides) the ForeColor (and BackColor) properties inherited from the generic Control object to do nothing.
I'm going to address two issues with the DatePicker object and a workaround for them.
You cannot put a blank value into DatePicker, which lead me to the 2nd problem.
You cannot change the font color to at least make it appear blank.
To keep the functionality of the DatePicker AND gain the ability to have a blank value and your regular font formatting options (colors, etc), I used two objects. First make a DTP object and set the width so that you can only really see the drop down arrow. For me this was 15. Then make a regular TextBox that is wide enough to hold your date. Put the DTP arrow directly to the right (or left) of the text box. Then you simply add code to the Change event of the DTP to copy its .Value into the .Text of the TextBox like so:
Private Sub MyDTP_Change()
MyUserForm.MyDateTextBox.Text = MyUserForm.MyDTP.Value
End Sub
Then have any data references you need access the MyDateTextBox.Text instead of the MyDTP.Value and presto! You get the functionality of the DTP with the formatting control of a regular TextBox.
EDIT:
Sorry JeffK, I wasn't working with VB in a production environment 9 years ago. :) I would like to add the other side of the functionality to this as well. This allows 2-way syncing between the TextBox and the DTP. IE: Manually enter a date into the TextBox and the DTP Calendar follows. If the TextBox is blank or has an invalid date, the DTP defaults to today's date.
Private Sub MyDateTextBox_Change()
If MyUserForm.MyDateTextBox.Text <> "" And
IsDate(MyUserForm.MyDateTextBox.Text) = True Then
If CDate(MyUserForm.MyDateTextBox.Text) <= MyUserForm.MyDPT.MaxDate And _
CDate(MyUserForm.MyDateTextBox.Text) >= MyUserForm.MyDPT.MinDate Then
MyUserForm.MyDTP.Value = MyUserForm.MyDateTextBox.Text
Else
MyUserForm.MyDTP.Value = Date
End If
Else
MyUserForm.MyDTP.Value = Date
End If
End Sub