private void buildList() { // Need an HDC to pass to EnumFontFamilies IntPtr hwnd = GetDesktopWindow(); IntPtr hdc = GetDC(hwnd); LOGFONT logFont = new LOGFONT(); enumFontDelegate = new EnumFontDelegate(EnumFontFamiliesExProc); fpEnumProc = Marshal.GetFunctionPointerForDelegate(enumFontDelegate); EnumFontFamilies(hdc, null, fpEnumProc, IntPtr.Zero); // We got a list of the major families. Copy the list, // then clear it so we can go back and grab all the individual fonts. List <string> fontFamilies = new List <string>(); fontFamilies.AddRange(fontNames); fontNames.Clear(); foreach (string fontFamily in fontFamilies) { EnumFontFamilies(hdc, fontFamily, fpEnumProc, IntPtr.Zero); } ReleaseDC(hdc); foreach (string s in fontNames) { //listBox1.Items.Add(s); } }
private void buildList(){ // Need an HDC to pass to EnumFontFamilies IntPtr hwnd = GetDesktopWindow(); IntPtr hdc = GetDC(hwnd); LOGFONT logFont = new LOGFONT(); enumFontDelegate = new EnumFontDelegate(EnumFontFamiliesExProc); fpEnumProc = Marshal.GetFunctionPointerForDelegate(enumFontDelegate); EnumFontFamilies(hdc, null, fpEnumProc, IntPtr.Zero); // We got a list of the major families. Copy the list, // then clear it so we can go back and grab all the individual fonts. List<string> fontFamilies = new List<string>(); fontFamilies.AddRange(fontNames); fontNames.Clear(); foreach(string fontFamily in fontFamilies) { EnumFontFamilies(hdc, fontFamily, fpEnumProc, IntPtr.Zero); } ReleaseDC(hdc); foreach(string s in fontNames) { //listBox1.Items.Add(s); } }