|
You can't use C# code in a C program.
You can either wrap your C code into a dll and call it via DllImport from the C# project, or you might want to use C++/CLI.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
The C program is the main executable file, the codes in c# is the function i would like to call. Can i compile the C# into a dll and use it in the C program?
As i have not use the VC++.net before, do you have any idea whats the difference between the MFC, Win 32 or window Form. I wish to build a GUI, and some of my frds mention that i can use the MFC as it has the auto drag and drop toolbox, but i found out recently that VC++ window form also has this properties.
Sorry for the trouble
thanks alot
jas
|
|
|
|
|
Cassiopeiaxy wrote:
The C program is the main executable file, the codes in c# is the function i would like to call. Can i compile the C# into a dll and use it in the C program?
You can compile the C# classes into a DLL, but you won't be able to call the DLL from your C program.
It's a bit difficult, you might need to create a wrapper DLL written in C++/CLI that will convert your C# calls into C++/CLI ones. It'S a bit more involved, though, check out this article
Cassiopeiaxy wrote: As i have not use the VC++.net before, do you have any idea whats the difference between the MFC, Win 32 or window Form.
Win32 - the oldest C++ sindowing API for Windows, pretty complicated to create complex windows
MFC - Makes it easier to work with the Win32 API, you can drag-drop your windows with a designer in VC++
Windows.Forms - the new .NET approach, requires the .NET framework. Makes it very easy to create windows with the designer of VS .NET
You have two choices:
a) you still program in C++ and don't want the .NET framework: use MFC
b) you program in .NET: use Windows.Forms
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
if you want to set cursor position on C++ you can use SetCursorPos
|
|
|
|
|
Hi,
I find out that we can use the user32.dll to control the cursor. Do you
happen to know the difference between using the user32.dll and ::Cursor::Position?
Do you think it is easier if i convert my c coding to c++ using the ::Cursor::Position or should i try to use the user32.dll with the c coding?
I try to create a new C++ file with the following codes:
SAMPLE CODING:
#pragma once
namespace yg {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///
~Form1()
{
if (components)
{
delete components;
}
}
private:
///
/// Required designer variable.
///
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
this->components = gcnew System::ComponentModel::Container();
this->Size = System::Drawing::Size(300,300);
this->Text = L"Form1";
this->Padding = System::Windows::Forms::Padding(0);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
};
void MoveCursor()
{
::Cursor::Position = Point(::Cursor::Position.X - 50,::Cursor::Position.Y - 50);
}
}
Errors Encountered:
error C3083: 'Cursor': the symbol to the left of a '::' must be a type c:\projects\yp\yg\yg\Form1.h 70
error C2039: 'Position' : is not a member of '`global namespace'' c:\projects\yp\yg\yg\Form1.h 70
error C2065: 'Position' : undeclared identifier c:\projects\yp\yg\yg\Form1.h 70
error C3083: 'Cursor': the symbol to the left of a '::' must be a type c:\projects\yp\yg\yg\Form1.h 70
error C2228: left of '.X' must have class/struct/union c:\projects\yp\yg\yg\Form1.h 70
error C3083: 'Cursor': the symbol to the left of a '::' must be a type c:\projects\yp\yg\yg\Form1.h 70
error C2228: left of '.Y' must have class/struct/union c:\projects\yp\yg\yg\Form1.h 70
Sorry for the trouble
Thanks alot
Jas
|
|
|
|
|
What happens if you run this code
<br />
Cursor::Position = Point(Cursor::Position.X - 50,Cursor::Position.Y - 50);<br />
|
|
|
|
|
Good afternoon.
How to unload data in the called fields? (i.e. cells we set to it a symbolical name (Insert-> Name->Create in Excel) to not become attached to concrete numbers of lines and columns)
or
In what it is better to create reports? So that the user could change names in caps of tables and other static information.. In patterns it (is desirable)
Thanks.
|
|
|
|
|
Hi everyone. Iam currently building a application for a smart pc handheld unit and uses the following techniques.
x SQL Server 2005 Mobile Edtion
X Microsoft .Net Compaqt Framework
X Visual Studio 2005 Ent, C#
I have now reached a critical stage in my project were I want to read the data from the database to a excel document, this document should thereafter be easialy transported to another computer using ActiveSync. It should also be possible to edit the excel document and then get it to update the sql mobile database on the handheld device.
Or does anyone have another way to solve this problem, or have done anything like this before.
Thanks in advacne and have a wonderful day.
|
|
|
|
|
this is a tricky one: How do i read registry key values and how do i modify them or create a new one?
rzvme
|
|
|
|
|
Take a look at the Registry and related classes.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
|
Hi all,
I am creating xml and i have a stylesheet and i create a html document when these two are combined. Is it possible to print this HTML document through C#?
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi,
In my C# Windows form, I have a datagridview where datagridview is bounded to a databinding source.
Now, when I have no rows in the gridview, there a single * marked row always there to allow user to ADD a new row. Now If I just click the DELETE button of the binding navigator, I get this error
Error : "current item cannot be removed from the list because there is no current item."
I have no way to handle this exception as the Delete button of binding navigator has no predelete event rather it has click event and this event occurs after the row is deleted.
Is there nay idea how can I handle this error ?
Thanks.
|
|
|
|
|
I believe you MIGHT be able to do it by taking three steps:
1) mark your form for KeyPreview=true;
2) Implement the KeyPress event handler on the form
3) If your grid has focus, and rows.Count.Equals(0), the set Handled=true;
|
|
|
|
|
How to play a sound from my program?
I need help.
Vasildb
|
|
|
|
|
|
Read the documentation for the System.Media namespace and search the CodeProject articles for "play audio". You will find everything you need.
____________________________________
There is no proof for this sentence.
|
|
|
|
|
But i have Visual Studio 2003.
Vasildb
|
|
|
|
|
Well, if you're using an out of date version, you need to make this clear.
I believe there's a PLaySound API you can p/invoke for waves, you can use the Windows Media Player as a control for anythin that WMP can play.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
See here[^] maybe its some helpful for you
|
|
|
|
|
hi
i want to use CrystalReports XI in VS2005 and print my form . how to do ??
thanks
|
|
|
|
|
Hi, I am doing this website where I am suppose to LOCALIZE the web contents according to the user's language preference. Labels and buttons can be LOCALIZED easily using ASP.NET's LOCALIZED:LOCALIZEDLITERAL & LOCALIZED:LOCALIZEDBUTTON to grab the content from the respective language resource files.
But for tooltips, I need to create a function to grab the content in the resource file. The following are the code I found on the web and tried to implement on my website:
XmlTextReader resourceReader = new XmlTextReader(@"language\\ja-JP\\Resource.xml");
XmlNode resourceNode1;
public string readXML()
{
XmlDocument resourceXML = new XmlDocument();
resourceNode1 = resourceXML.SelectSingleNode("//Resource/item[@name = 'login_emailAddOfModerator']");
return resourceNode1.InnerText.ToString();
}
private void LoadToolTips()
{
this.txtUserName.ToolTip = readXML();
}
The following are the XML code:
<?xml version="1.0" encoding="utf-8" ?>
<Resource>
<item name="login_emailAddOfModerator">調整器のEメールアドレス。</item>
</Resource>
The tooltip didnt appear. Please advise me on how to make the code work, thankz
|
|
|
|
|
Well, have you stepped through the code ? Does the XML file you want exist ? What does the method return ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
yltoh wrote: But for tooltips, I need to create a function to grab the content in the resource file.
What makes you think that? Given a resource string with name "txtUserNameToolTip" exists in the resource file of the current page the following will create a textbox with respective tooltip
<asp:TextBox id="txtUserName" runat="server" ToolTip="<%$ Resources: txtUserNameToolTip %>" />
Furthermore the Page class provides the GetLocalResourceObject and GetGlobalResourceObject methods that allow you to access resources without the need to deal with XML.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|