|
It will add it to the project, just try it! You will see what I mean then. [edit] Or reference it I mean, Ooops! [/edit]
"There are no stupid question's, just stupid people."
|
|
|
|
|
On the toolbox I can only add controls.
Let me explain what I want to do:
I have a .Net windows app. In that app I have a class, let's say:
public class MyClass
{
int callMe()
{
return 3;
}
}
I want to make this class (and the callMe function) accessible from a MFC application. How do I do it?
|
|
|
|
|
kozureokami wrote:
I have a .Net windows app. In that app I have a class,
kozureokami wrote:
I want to make this class (and the callMe function) accessible from a MFC application. How do I do it?
Look up CCW on MSDN
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
This one[^] is for you.
How low can you go ? (MS retrofuck)
|
|
|
|
|
I need to import functions frol UxTheme.dll, Windows XP's visual styles dll. Several of the functions have const parameters, and C# does not allow the use of the const keyword in function parameter definitions. I'm wondering if anyone knows how to import a function with constant parameters into a C# class.
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int DrawThemeBackgroundEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, const IntPtr pRect, const IntPtr pOptions);
|
|
|
|
|
Jon Rista wrote:
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
Dont you mean [DllImport("UxTheme.dll", CharSet=CharSet.Auto)] ? Sorry I dont have docs on UxTheme.dll
"There are no stupid question's, just stupid people."
|
|
|
|
|
Doh!
Yeah, meant uxtheme.dll. I just finished working on a file importing a bunch of shell32.dll stuff. Wasn't out of "shell32" mode yet.
|
|
|
|
|
BTW, having shell32.dll in there wasn't the problem. I had it correct in my code. I'm still having the original problem.
|
|
|
|
|
Does the function definition really need that const keyword? Have you tried it, without it? What are the results?
"There are no stupid question's, just stupid people."
|
|
|
|
|
This program should show all the installed fonts in their typeface but it doesn't show anything instead whats wrong?
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();
}
}
}
Cheers
|
|
|
|
|
I *think* your problem is that you are doing the drawing on the load event which actually occurs before the form is displayed.
Try taking the stuff in the draw event and putting it in the paint event instead and see if that works.
|
|
|
|
|
I understand how to access functions from a DLL that is not a COM DLL. However, I would like to know how I can access the classes from a NON-COM DLL.
A tutorial, or sample code would be great, or at worse a tool that created a .NET wrapper for you.
Thanks
Coding is a way of life. It's in the air we breath. It pumps through our veines. Without it we soon crumble to dust. - Rodney S. Foley
|
|
|
|
|
You need to use DllImport. Here is an example straight from MSDN :-
using System;
using System.Runtime.InteropServices;
class PlatformInvokeTest
{
[DllImport("msvcrt.dll")]
public static extern int puts(string c);
[DllImport("msvcrt.dll")]
internal static extern int _flushall();
public static void Main()
{
puts("Test");
_flushall();
}
}
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
First I like to say I appreciate your attempt to help, however, please read a post and understand it before you reply.
Okay I will try to state this again. As I said, I understand how to access functions from a DLL. Which is what you just provided an example for.
What I asked for in the post, and what is also stated in the subject is how to access CLASSES from a NON-COM DLL. That would be a DLL that is not a COM library. That would be C++ classes, not C classes which are really just a struct.
If you know how to do this or have a link to a tutorial or sample code great that would be appreciated. How to access just global functions from a DLL is not needed.
Coding is a way of life. It's in the air we breath. It pumps through our veines. Without it we soon crumble to dust. - Rodney S. Foley
|
|
|
|
|
|
Nishant S wrote:
I seriously doubt if you can access native C++ classes from a C# program.
Nope, you can't. The problem is that each vendor compiles its C++ code differently, which is the main reason why COM was created (so that a binary standard existed for sharing OOP code without having to produce a version for every compiler version in existance)
As you said the best option is to use an MC++ wrapper for the native class.
James
Sig code stolen from David Wulff
|
|
|
|
|
Hello guys,
I have been only a few hours on C# and I am loving it.
I have created a program that downloads a web page, and i am trying to extract the keywords meta tag. I tried using the MSHTML stuff, but it was sooo slow! I figured that I will parse the meta keyword thing myself, thats when i discovered "regular expressions".
I have managed to the keywords from this kind of string:
However, the same pattern will not work on
(content and name are switched).
How cuold i make my query not care where CONTENT and NAME are located, as long as they ARE present in the string?
As usual,
Thanks in advance
Jeremy.
Jeremy Pullicino
Professional C++ Developer
Done any hacking lately?
|
|
|
|
|
Use some combination along the lines of
((?<key>\w+)\s*=\s*(?<value>\w+)\s+)*
to pick up all the tags in a metatag into a GroupCollection, then find the one with CONTENT in the key field.
Disclaimer: I'm just playing with Regular Expressions myself and I could have this completely wrong, but I think it's good.
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
Jeremy Pullicino wrote:
I have been only a few hours on C# and I am loving it.
Glad to hear that
Jeremy Pullicino wrote:
How cuold i make my query not care where CONTENT and NAME are located, as long as they ARE present in the string?
I'm by no means a regex guru, but this one does the trick for me though it could probably be optimized.
<meta (name=\"(?<name>.*?)\" content=\"(?<content>.*?)\")|(content=\"(?<content>.*?)\" name=\"(?<name>.*?)\")>
Using the IgnoreCase and ExplicitCapture options that works on your example above.
Regular Expression Workbench (V1.03)[^] written by Eric Gunnerson is a good tool for testing regex's because of the tooltip help breaking down what the regex does
HTH,
James
Sig code stolen from David Wulff
|
|
|
|
|
I forgot to point out that mine is very picky; so a cross between my solution and Paul's would probably be best
James
Sig code stolen from David Wulff
|
|
|
|
|
James T. Johnson wrote:
a cross between my solution and Paul's would probably be best
I was about to say that
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
I did a mix between paul's and mine and it worked like a charm Thanks guys.
My next step is to get this into an array or something (I need to store it in a database)
"word1,word2,word3 and four,word5"
Will regular expressions work well for this, or is it better if I use conventional string parsing?
Jeremy.
Jeremy Pullicino
Professional C++ Developer
Done any hacking lately?
|
|
|
|
|
I think string parsing would be better for that. Use the Split method of the string class to get the initial array, then do parsing on each item to see if it contains more keywords (like 3 and 4 above).
James
Sig code stolen from David Wulff
|
|
|
|
|
If it's always going to look like that ("word1,word2,word3 and four,word5") then use String.Split on "," because it's a LOT more efficient.
If there's randomly spaces (like "word1, word2 , word3 and four,word5") then use Regex.Split on "\s*,\s*".
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
The easiest thing is probably to write two separate regular expressions, and see if either of them match.
For using regex, you might want to download my utility:
http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=regular%20expression%20workbench
|
|
|
|