C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
call from c++ to gui create in c# Posted by michaeldune on 10 Jul 2008 at 12:23 AM
hi all
i created gui in c# i was exe.
now i want to create api/lib/dll to call from c++ aplication that runs in windows ce what steps i need to take and how to call the functions from windows ce here is the code in c#
---------------------------------------
the aplication just have two buttons when pressed create rectangle
instead i want to remove this two buttons in the futere and create the ructungle using function call
[button_red_Click.....]
when i recive some event from manager function when keyboard pressed for example
--------
i suppose i need to remove the main etc ...
what i need to write in c++ code ?
=========================================
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;


namespace AlphaBlender
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;


private Button button_red;
private Button button_blue;

private static Color backColor = Color.White;
private Color barColor = Color.Red;
private int x = 20;


public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer,
true);
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

// Note - in a fit of bad coding practice, I converted
// the radioButton event handlers to all point to a single
// event handler. So I'm lazy...
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button_red = new System.Windows.Forms.Button();
this.button_blue = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button_red
//
this.button_red.BackColor = System.Drawing.Color.Red;
this.button_red.Location = new System.Drawing.Point(104, 453);
this.button_red.Name = "button_red";
this.button_red.Size = new System.Drawing.Size(75, 23);
this.button_red.TabIndex = 0;
this.button_red.Text = "button_red";
this.button_red.UseVisualStyleBackColor = false;
this.button_red.Click += new System.EventHandler(this.button_red_Click);
//
// button_blue
//
this.button_blue.BackColor = System.Drawing.Color.CornflowerBlue;
this.button_blue.Location = new System.Drawing.Point(222, 453);
this.button_blue.Name = "button_blue";
this.button_blue.Size = new System.Drawing.Size(75, 23);
this.button_blue.TabIndex = 1;
this.button_blue.Text = "button_blue";
this.button_blue.UseVisualStyleBackColor = false;
this.button_blue.Click += new System.EventHandler(this.button_blue_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(412, 510);
this.Controls.Add(this.button_blue);
this.Controls.Add(this.button_red);
this.ForeColor = System.Drawing.Color.Black;
this.Name = "Form1";
this.Text = "Dune GUI";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}



private void button_red_Click(object sender, EventArgs e)
{
barColor = Color.Red;
x = x + 20;
Refresh();
}
private void button_blue_Click(object sender, EventArgs e)
{
barColor = Color.Blue;
x = x + 20;
Refresh();
}
private Rectangle backRectangle = new Rectangle(20, 20, 20, 22);


protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
SolidBrush backBrush = new SolidBrush(barColor);
e.Graphics.FillRectangle(backBrush, backRectangle);
backRectangle.X = x;

}
}
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.