|
Essentially iterating through your array, make sure you have a graphics object when doing this (e.g. - grfx ):
<code>
Color c = Color.Black;
Brush brush = new SolidBrush(c);
float y = 0;
FontFamily[] aff = FontFamily.Families;
foreach (FontFamily ff in aff)
{
Font font = new Font(ff, 12);
grfx.DrawString(ff.Name, font, brush, 0, y);
y += font.GetHeight(grfx);
}
</code>
HTH
Nick Parker
The greatest lesson in life is to know that even fools are right sometimes. - Winston Churchill
|
|
|
|
|
using System;
using System.Drawing;
using System.Drawing.Text;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace FontViewer
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabPage1});
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(624, 353);
this.tabControl1.TabIndex = 2;
//
// tabPage1
//
this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listView1});
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(616, 327);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Installed Fonts";
//
// listView1
//
this.listView1.CausesValidation = false;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader2});
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Scrollable = ((bool)(configurationAppSettings.GetValue("listView1.Scrollable", typeof(bool))));
this.listView1.Size = new System.Drawing.Size(616, 327);
this.listView1.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listView1.TabIndex = 1;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader2
//
this.columnHeader2.Text = "Names";
this.columnHeader2.Width = 595;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem3});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "File";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Shortcut = System.Windows.Forms.Shortcut.CtrlQ;
this.menuItem2.Text = "Exit";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.Text = "About";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// columnHeader1
//
this.columnHeader1.Width = 612;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(624, 353);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabControl1});
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Leons Font Program";
this.Load += new System.EventHandler(this.Form1_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
Graphics grfx = CreateGraphics();
Color c = Color.Black;
Brush brush = new SolidBrush(c);
float y = 0;
FontFamily[] aff = FontFamily.Families;
foreach (FontFamily ff in aff)
{
if(ff.IsStyleAvailable(FontStyle.Regular))
{
Font font = new Font(ff, 12);
grfx.DrawString(ff.Name, font, brush, 0, y);
y += font.GetHeight(grfx);
}
}
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Made By Leon Radley, 2002");
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
Here's my program, the problem is that nothing shows when I compile it... what have I done wrong?
|
|
|
|
|
From my C# application, I want to create a MS access database create tables and update it with the data that I receive from the network! Kinda the same way cd player (that comes with win2k) stores its records on an Access DB and retreives them back.
What technology should I use to accomplish this ?
Thanks
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
Download the Jet .NET driver here[^].
How low can you go ? (MS retrofuck)
|
|
|
|
|
Why not just use ADO.NET's System.Data.OleDB namespace? If it's already built-in to the .NET framework...why download the Jet.NET driver?
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
The If is the important thing in what you say.
Excerpt from MSDN[^] : "To access an ODBC data source using ADO.NET, use the ODBC .NET Data Provider, which is available for download at http://msdn.microsoft.com/downloads."
This driver is native in .NET 1.1 however.
How low can you go ? (MS retrofuck)
|
|
|
|
|
I agree that ODBC is not required to access a MSACCESS database, even though most MSACCESS implementations in the real world use ODBC.
It's true you have a OLEDB Jet data provider under OLEDB .NET. Even if I don't recommend it, this may well allow to do the job.;P
How low can you go ? (MS retrofuck)
|
|
|
|
|
Hi all.
I builded my application at home with C# and I tried it on others computers but it doesn't work. Do you know if I need to install on each computer the pack of 20Mo (I would need autorisations)? Or is there any other way as just copying a few files ?
I have another question, is it possible to compile C# appz in binary as C++ does ? This would speed up and solve the problem of my first question...
Thanks by advance.
NitroD.
|
|
|
|
|
C# cannot compile down to native, that would defeat the object of the .NET Framework. Thus, yes, if you want to run a C# program on a PC other than the one you compiled on, you have to install the .NET Framework.
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
If you try to run a .NET app on a computer with no .NET run-time installed, then you get a dirty message box saying "missing mscoree.dll". This DLL is launched from the PE and hosts the CLR.
If the computer has a .NET run-time, but in a wrong version (it will happen as soon as .NET 1.1 is RC), then you'll get an explicit message box "cannot find C:\WINNT\Microsoft .NET\Framework\v1.1.0.3800".
( in this scenario, the user may try to launch the app with his .NET run-time thanks to either the creation or modification of an associated .config file in the same directory. Of course, if the app was compiled against .NET 1.1, there is no strict guarantee is works against a .NET 1.0 run-time just because you would change a config file).
And about native generation, the JIT produces native code. Use ngen.exe. With .NET 1.0, you must explicitely use ngen.exe in a separate cmdline, because there is no direct support of this in the IDE. ngen myapp.exe will generate a native image of the managed code in myapp.exe, and put it in the GAC (c:\winnt\assembly) ready for use.
How low can you go ? (MS retrofuck)
|
|
|
|
|
I was afraid about that...Thanks Paul and Stephane. Java can be compiled in class or native code..I hope C# will be able of the same thing later...
|
|
|
|
|
I'm trying to get a form to pop-up when the user presses a hotkey. So far the form pops up OK, (I'm registering the hotkey, and issueing a form.Show(); from within a WndProc method that ). But the form that I show doesn't get keyboard focus...
Dave
|
|
|
|
|
Have you tried Form.ShowDialog(this); ?
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
Yes, it still doesn't get the keyboard focus.
|
|
|
|
|
Well that's odd. What does get focus? If the new Dialog is owned by the old one then the old one surely can't retain focus... can it?
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
I've spent some time experimenting with this, and unfortunately don't have a solution, but maybe a better characterization of the problem...
What I do is register a hotkey then minimize and hide my main application window after a few seconds. This causes whatever application had focus prior to starting my main application to regain focus.
When I press the registered hotkey, I'm able to pop up a form, but it doesn't get focus.
In general what I'm trying to do is create a hotkey that will pop-up a form that is activated no matter what application had focus previously.
This might not be relevant, but there is a strange situation when there is no active application on the desktop. In that case, my applcation seems to have focus, but I need to press Tab to have the first control get keyboard focus.
|
|
|
|
|
Aha! Now I understand the problem. You're giving focus to another App by minimizing but expecting to get it back automatically when you open a new dialog. Of course if you have nothing to give focus to, it will go to the desktop and when you start up a new window the desktop will give it back.
I think the answer to your problem is this.Focus() , probably in your pop-up app's Form_Load() event.
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
Thanks, unfortunately I've tried that... and this.Activate() as well... It seems to be a problem related to some other application having the keyboard focus.
|
|
|
|
|
FWIW I've gotten this working. I did a "zero based" example to try to demonstrate the problem in the simplest way possible. I discovered that the loss of focus was caused by a custom control that was on the pop-up form. It was a very simple control that extends TextBox so that it will capture and process enter and escape keys. Still don't know why THAT is failing...
Thanks much for your help!
Dave
|
|
|
|
|
Dave,
I've only just noticed your last reply, I don't know how I missed that. However, I'm glad you figured it out and thanks for letting me know how, for future reference.
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
Hi,
I seem to have a problem with a debug version of a DLL that i am calling. It enteres the function OK and goes to the end but when the function returns it tries to store the return value of the functoin in the register ESI from EDX. Visual C# then throws an access violation error. It works fine in release mode and uses the same registers.
Has anybody seen this before and know how to resolve the issue.
Thanks
Ceri
|
|
|
|
|
Ceri wrote:
Has anybody seen this before and know how to resolve the issue.
Not exactly but I have had similar problems before, there are often vast differences between debug and release versions that you don't see.
For example, I've written DLLs for Windows Installer using VC++ which work fine in debug mode and not in release mode. When I switched the release mode optimisation off, it worked fine.
If possible, it's worth looking at the differences in the commandline options for the DLL in release and debug mode and adjusting them until they both act the same way. Then at least you'll know what is causing the problem.
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
Don't see the relation with C#, appart the fact C# is hosting your client.
Try compiling the DLL by changing the signature of methods (__cdecl, __fastcall, ...) : Project settings / C/C++ tab / code generation / calling convention.
From what I remember, the return value is always stored in EAX.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Hello,
I'm currently playing a lot with the WebBrowser control and C#. I made several programs interacting with the DOM of pages I use for testing.
One of my programs traverse the DOM tree of a page, find all the images tags and click on them. Nothing really fancy .
My point is sometimes when I click on an image a JavaScript is called in the page and this JavaScript opens a messagebox using window.alert.
The problem is that I want to execute the scripts but disable those modal messageboxes who freeze my program.
My question is: how to disable the window.alert function ? Or how to intercept a window.alert call ?
I explored the window object and I think you can't not change the window.alert default behaviour.
Thanks,
R. L.
|
|
|
|
|
A very crude method would be to read in the script before clicking the image and then remove, or comment out any calls to window.alert
What do u think?...too much work maybe
May the Source be with you
Sonork ID 100.9997 sijinjoseph
|
|
|
|