Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to Print the ASCII Character Set in Visual Basic

Featured Replies

Posted

How to Print the ASCII Character Set in Visual Basic
/>http://support.microsoft.com/kb/75857

Using A Standard Terminal Font - documentation

StockFont.zip - source example VB

StockFont.zip

Using A Standard Teriminal Font.unlocked.pdf

Edited by CodeCracker

Here's a different approach I've put together in the

past to get the 'Terminal' font into a .NET control:

public class TerminalBox : TextBox
{
[StructLayout(LayoutKind.Sequential)]
public class LOGFONT
{
public const int LF_FACESIZE = 32;
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FACESIZE)]
public string lfFaceName;
}
[DllImport("gdi32", CharSet = CharSet.Auto)]
public static extern uint CreateFontIndirectA([In, MarshalAs(UnmanagedType.LPStruct)]LOGFONT lplf);
[DllImport("user32")]
static extern void SendMessage(IntPtr hWnd, uint Msg, uint wParam, uint lParam);
protected override void OnCreateControl()
{
base.OnCreateControl(); LOGFONT lfFont = new LOGFONT();
lfFont.lfHeight = 9;
lfFont.lfCharSet = 1; // DEFAULT_CHARSET
lfFont.lfFaceName = "Terminal";
uint nfoFont = CreateFontIndirectA(lfFont); SendMessage(this.Handle, 0x00000030, nfoFont, 0x00000001); // hWnd, WM_SETFONT, hFont, [redraw=]true
}
}
  • Author

Here is my old code, it require linedraw.ttf.

[DllImport ( "Shell32.DLL" )]

static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner,

int nFolder, out IntPtr ppidl);

[DllImport ( "Shell32.DLL" )]

public static extern Int32 SHGetPathFromIDList(

IntPtr pidl, // Address of an item identifier list that

StringBuilder pszPath);

// Get the font path:

public string GetFontPath()

{

FileInfo[] cdirfonts=null;

FileInfo[] fontfiles=null;

try

{

DirectoryInfo curdi = new DirectoryInfo(Environment.CurrentDirectory);

cdirfonts = curdi.GetFiles("*.ttf");

foreach(FileInfo fi in cdirfonts)

{

if (fi.Name.ToLower()=="linedraw.ttf") return fi.FullName;

}

}

catch

{

}

try

{

IntPtr pidl = IntPtr.Zero;

string FontDirectory="";

if( 0 == SHGetSpecialFolderLocation(IntPtr.Zero,

20, out pidl ) ) // 20 = Font Directory

{

// Then retrieve the path from the IDList.

StringBuilder sb = new StringBuilder ( 1000 );

SHGetPathFromIDList(pidl, sb );

FontDirectory=sb.ToString();

}

DirectoryInfo curdi = new DirectoryInfo(FontDirectory);

fontfiles = curdi.GetFiles("*.ttf");

foreach(FileInfo fi in fontfiles)

{

if (fi.Name.ToLower()=="linedraw.ttf") return fi.FullName;

}

}

catch

{

}

return "";

}

// Now seeting the font:

string fontpath = GetFontPath();

if (fontpath!=null&&fontpath!=""&&File.Exists(fontpath))

{

try

{

PrivateFontCollection pfc = new PrivateFontCollection();

pfc.AddFontFile(fontpath);

FontFamily terminal = pfc.Families[0];

Font fontTerminal = new Font(terminal, 12f, FontStyle.Regular, GraphicsUnit.Pixel);

txt_scroller.Font = fontTerminal;

}

catch

{

}

}

  • Author

@Ufo-Pu55y:

Your code doesn't seems to work for a label

Any idea why ?

Yep, set "FlatStyle" to "System".

Same for buttons and alike,

since they are all "STATIC" controls..

  • Author

Works fine now ;) thanks.

Now I have another problem with the Terminal font: Autosize doesn't work properly;

so I should compute the size on my own,

I looked on " INFO: Calculating The Logical Height and Point Size of a Font"
/>http://support.microsoft.com/kb/74299

and I'm quite confuse :wacko:

I don't know w/o investigating, and to be honest I would simply

never use such a font, if it's not for a textbox to show NFO chars!

But if you're just doing it out of curiosity, then I guess you

should take a look at following API calls instead:

SIZE size;

IntPtr hDC = GetDC(someForm.Handle);

GetTextExtentPoint(hDC, someString, Len(someString), ref size);

ReleaseDC(someForm.Handle, hDC);

..'size' should contain height and width of the string in pixels

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.