|
er I did invoke the Focus method, take another look at the code. Also, I know it's focused because i can see the cursor blinking in it, and the border etc..
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Bog wrote:
er I did invoke the Focus method, take another look at the code.
tbx.Focus(); only calls the function.
You will need to do something like this I suspect.
if (tbx.InvokeRequired) tbx.Invoke(tbx.Focus);
else tbx.Focus();
Also I see that there is no KEYEVENTF_KEYUP for the SendInput. This I presume you will need to do after the first SendInput you are sending.
"There are no stupid question's, just stupid people."
|
|
|
|
|
I tried a Console.WriteLine(tbx.InvokeRequired) and it was false. Also, I know the textbox is getting focus because I can see it. The curosor is blinking in the textbox, and when I type text goes into it.
I don't think sending a KEYUP is required, because it's not required in normal keyboard activity either. For example, when you press a key here in a web form, the letter appears on keydown, not on keyup. Also, I've seen examples of this in C++ (non dotnet) and non of the examples have a subsequent KEYUP.
Thanks for your responses anyway tho.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Hello,
i am very new to c#.
i made a program to download a web page.
Now I want to parse out the meta keyword tags:
Done any hacking lately?
|
|
|
|
|
Add the Microsoft.mshtml namespace (add a reference to this primary assembly that you'll find in the program files \ .NET folder).
Then the IHTMLMetaElement interface is the right stuff for you.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Thanks - that pointed me in the right direction.
I have managed to get the keywords out, but I think that regular expressions could do it much quicker for me. I am looking into those right now If you have any experience with regular expressions, please look at my new post
Cheers,
Jeremy
Jeremy Pullicino
Professional C++ Developer
Amature C# Software Architect
Done any hacking lately?
|
|
|
|
|
My C# app calls a COM server but does not release it. What's Wrong? Urgent!
Please help!
Here is how I call it:
<code>
...
void SomeFunc1()
{
for (int i; i<10; i++)
{
SomeFunc2();
}
}
void SomeFunc2()
{
MyCOMLib.MyIFace mf = null;
try
{
mf = new MyCOMLib.MyIFace();
string myParam = "Here is some param";
MyCOMLib.MyIFace2 mf2 = mf.MyMethod(myParam);
mf2.MyProperty = 1;
}
catch()
...
}
</code>
|
|
|
|
|
Not really surprising.
Anyway, help the GC by doing stuff like mf2.Release() and mf = null;
(may be the issue is on your part btw : if you have a wrong apartment model, then the COM server is not released that easy).
How low can you go ? (MS retrofuck)
|
|
|
|
|
The problem is that for some reason, even when COM interface
IUnknown derived C# compiler throuws at me:
MyCOMLib.MyIFace2 does not contain a definition for 'Release'
and assigning to null does not release it right away for sure.
How do I work this appartment thing?
|
|
|
|
|
O! So GC does not release objects right away, does it?!
It looks like if I call GC.Collect(); objects do get released (not right there but in a couple of milsecs).
I'm assuming that means that my COM objects are fine and can be released just fine, right? Or is this GC.Collect(); a kind of cheating?
If not, why GC doesn't clear local vars right there on the spot like VB does (I think ) ? When does it do it?
|
|
|
|
|
GC.Collect() is kinda hardcore. This method is not normally called by a client app, except in critical scenarios (huge memory needs, and so on). It's true that, from what I know from the Java GC, the GC has no good reason to release objects as soon as they are out of scope.
The fact that GC.Collect() has actually released your COM object is that it was a weak-reference in scope.
COM are normaly finely released.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Interesting! Thanks a lot.
Curious : what's "weak-reference"?
And what do you mean by "COM are normaly finely released"?
May be my english is not that good yet
Do you think I still have to hunt for problem or it looks like it's fine. What do I do?
|
|
|
|
|
Here is an article [^]explaining how the GC works, and what is a weak reference.
You'll notice it's about Sun's GC. But when you know where the .NET virtual machine comes from...
How low can you go ? (MS retrofuck)
|
|
|
|
|
Hi,
I'm trying to call functions exposed by a .Net application (exe, not dll) from a COM client. The problem is that the tlb generated by regasm (or tlbexp) doesn't have enough info. I assume I need to use some funky attributes, but I just can't find them.
Does anyone have an idea?
Thanks,
Bruno
|
|
|
|
|
ComVisible and ComSource
How low can you go ? (MS retrofuck)
|
|
|
|
|
ComVisible determines if a class/method is visible to COM, but has no effect in exes. ComSource is linked to events; I don't need those. Am I missing something?
Also, can you please explain the last part? The one with "how low..".
|
|
|
|
|
Those are entry points. If you check out .NET samples, or google, you'll find implementations that might help you.
How low can you go ? (MS retrofuck)
|
|
|
|
|
I'm totally new to programming so don't expect me to know anything =)
I've been trying to write a simple program too list all the installed fonts in a simple list,
This I've accomplished with this code:
FontFamily[] fontFamilies;
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
// Get the array of FontFamily objects.
fontFamilies = installedFontCollection.Families;
int count = fontFamilies.Length;
for(int j = 0; j < count; ++j)
{
listView1.Items.Add(fontFamilies[j].Name);
}
It adds lines to the listView1.
How would I now continue with my project and try to get the fonts to display in their own typeface, since they now are printed using the default system font.
Cheers
|
|
|
|
|
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)
|
|
|
|