|
How could I fill a Ellipse with one color, making the center most intensive, and the intensity fades as the distance from the center increase.
I tried to use LinearGradientBrush, but could not find a mode for ellipse.
|
|
|
|
|
Hello fellow programming, what you are seeking comes with good fortune and happy tidings..LOL!!!
You want whats caleld a PathGradientBrush which is derived from GraphicsPen...Lemme type up some code for you, I will not have tested this but you will get the idea...
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics
GraphicPath gp = new GraphicPath();
gp.AddLine(10,10,110,15);
gp.AddLine(110,15,100,96);
gp.AddLine(100,96,15,110);
gp.CloseFigure(); //its a box duh!!
g.FillRectangle(Brushes.White, this.ClientRectangle); //paint the form white...
g.SmoothingMode = SmoothingMode.AntiAlias; //otherwise it looks like crapola
PathGradientBrush pgb = new PathGradientBrush(gp);
pgb.CenterColor = Color.White; //the middle "cone"
pgb.SurroundColors = new Color[]{Color.Blue,Color.Red}; //Surround Colors, pass in an array of colors...
g.FillPath(pgb, gp);
g.DrawPath(Pens.Black, gp); //draw the stupid square...its not perfectly square prolly
pgb.Dispose();
gp.Dispose();
}
|
|
|
|
|
|
The error is: 'Class1.frmAccount.txtOwnerName' is inaccessible due to its protection level.
<br />
public void ShowAddAccount(string Name)<br />
{<br />
frmAccount frmA = new Class1.frmAccount();<br />
frmA.txtOwnerName.text = Name;
frmA.ShowDialog();<br />
}<br />
When I change "private System.Windows.Forms.TextBox txtOwnerName;" to public in frmAccount then it says "'System.Windows.Forms.Control.text' is inaccessible due to its protection level"
I know this is a logical mistake but I still need help. Thanks in advance.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
text with lower case is an internal property. Try Text. Then make it a property.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Ooops.. Trouble for VB programmers huh?
Thanks Christian
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
hi there,
I have a Solution with two projects. Both projects have a main method to open its own.
- projectA - formA(with a main() method) - buttonA
Solution
- projectB - formB(with a main() method) - buttonB
I want to open formB in projectB by clicking buttonA.
private void buttonA_click(){
projectB.formB fb = new projectB.formB();
fb.Show(); // open projectB
this.Visible = false; // close projectA
this.Dispose();
}
But," this.Visible = false; and this.Dispose();" statements cause both projects closed.
1) how can Open a Project, then close another one by not using " this.Visible = false; and this.Dispose();" ??
Thansks
|
|
|
|
|
luckyShek wrote:
this.Visible = false; // close projectA
This hides child windows as well, such as the one you created.
luckyShek wrote:
this.Dispose();
Oh, someone shoot me. projectB exists as an instance inside projectA. What did you expect this would do ?
You probably want to use ShellExecute to just run the other program, then close this one.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi there,
I had created a UserControl.exe. I want to add it to a project by using "Add References". But it only take .dll file.
1) Can I just rename UserControl.exe to UserControl.dll ? 2) Will it cause any error ??
3) What's the best to create a userControl file with .dll in vs.net ?
Thank you very much.
|
|
|
|
|
luckyShek wrote:
What's the best to create a userControl file with .dll in vs.net ?
Set the compiler to build a dll.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
|
An EXE and a DLL contain different headers. An EXE contains an entry point while a DLL does not, though it typically contains a load address of where in memory relative to the EXE base it should be loaded. In the case of .NET assemblies, the EXE entry point references mscoree.dll!_CorExeMain , which creates the unmanaged AppDomain, loads a managed AppDomain then your assembly, and runs the entry point. A DLL will simply load into the process space but contains no entry point. While the IL module(s) contained in the assembly are basically file format-agnostic, the PE/COFF headers of the executable that contain the manifest and IL module(s) (and any other embedded files or resources) are different.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
In C#, during compile time, if you try to assign a int to a short, you will get a compile error.
In runtime, I need to check if a certain type can be assignable to another without loss of data.
(ie. it is fine to assign a short to an int, but not the another way around.)
System.Type has a function isAssignableFrom.
Unfortunately it only returns "true" if the types are the same. Are there any ways I can do assignability checking?
Thanks!
|
|
|
|
|
You could use reflection and the MaxValue/MinValue properties on types to write a method that does this for you.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
For casting between numeric types, there is a compiler option called "checked". If that is turned on, the CLR checks for loss of precision in runtime. Alternatively, you can wrap the statements you want in checked blocks (like "using" blocks) to selectively enable runtime checking.
As for general assignability, IsAssignableFrom does take into account casting up the inheritance chain IIRC.
Regards
Senthil
|
|
|
|
|
I was experimenting with the "floating window" code located in this article: http://www.vbaccelerator.com/home/NET/Code/Controls/Popup_Windows/Floating_Controls/article.asp
And i want that affect plus one additional characteristic...i want to display my form without preventing the mouse from hitting anything behind the form...as if my form wasn't their in the first place.
Would it be possible to determine what is the handle of the program that is directly beneath my form?...then i could probably send it a mousedown message with that sendmessage api.
|
|
|
|
|
YEs, the Windows API has a function to return a visible window handle from a point. Convincing it that your window does not count is obviously the problem, but the API is there.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
Convincing it that your window does not count is obviously the problem, but the API is there.
Maybe if you hide the window, call WindowFromPoint and show the window again, without letting any message pump get a message (so the other program don't get a chance to repaint itself -- I know it's preemptive multitasking, but it may just work), you could get away with it without flicker.
He would have to try that.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I looked into that API, but found it wasn't necessary to do what you were suggesting...but as expecting the flicker is crazy...even with double buffering turned on...heres code so far.
Another possibility to kill the flicker is if i can send a mouse click to a certain window handle...then i could try enumerating all windows and somehow hitting the one at that point that is also topmost of the z-order...ill then probably get rid of my mouse overrides, and handle everything in the wndproc...might be only way to avoid getting focus...this is weird heh
#region Using Directives<br />
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
using System.Runtime.InteropServices;<br />
<br />
#endregion<br />
<br />
namespace no_Mouse_input<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
#region Autostuff<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
SetStyle(ControlStyles.UserPaint, true);<br />
SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
SetStyle(ControlStyles.DoubleBuffer, true);<br />
<br />
InitializeComponent();<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.SuspendLayout();<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(292, 266);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
#endregion<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
this.TopMost = true;<br />
<br />
ShowFloating();<br />
}<br />
<br />
#region Floating<br />
<br />
private const int WS_EX_NOACTIVATE = 0x08000000;<br />
private const int WS_EX_TOPMOST = 0x00000008; <br />
<br />
protected override CreateParams CreateParams<br />
{<br />
get<br />
{<br />
CreateParams cp = base.CreateParams;<br />
cp.ExStyle |= (WS_EX_NOACTIVATE | WS_EX_TOPMOST);<br />
cp.Parent = IntPtr.Zero;<br />
return cp;<br />
}<br />
}<br />
<br />
<br />
private const int WM_NCHITTEST = 0x0084;<br />
private const int HTTRANSPARENT = (-1);<br />
<br />
protected override void WndProc(ref Message m)<br />
{<br />
{<br />
base.WndProc(ref m);<br />
}<br />
}<br />
<br />
[DllImport("user32")]<br />
private static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);<br />
[DllImport("user32")]<br />
private static extern int ShowWindow(IntPtr hWnd, int nCmdShow);<br />
<br />
public void ShowFloating()<br />
{<br />
if(this.Handle == IntPtr.Zero)<br />
base.CreateControl();<br />
<br />
SetParent(base.Handle, IntPtr.Zero);<br />
ShowWindow(base.Handle, 1);<br />
}<br />
<br />
#endregion<br />
<br />
#region Faked Mouse Clicks<br />
<br />
<br />
private const int MouseEventLeftDown = 0x0002;<br />
private const int MouseEventLeftUp = 0x0004;<br />
<br />
[DllImport("user32.dll")]<br />
private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);<br />
<br />
public void MouseLeftClick()<br />
{<br />
mouse_event(MouseEventLeftDown, MousePosition.X, MousePosition.Y, 0, 0);<br />
mouse_event(MouseEventLeftUp, MousePosition.X, MousePosition.Y, 0, 0);<br />
}<br />
<br />
public void MouseLeftDown(ref Point impact)<br />
{<br />
mouse_event(MouseEventLeftDown, impact.X, impact.Y, 0, 0);<br />
}<br />
<br />
public void MouseLeftUp(ref Point impact)<br />
{<br />
mouse_event(MouseEventLeftUp, impact.X, impact.Y, 0, 0);<br />
}<br />
<br />
#endregion<br />
<br />
#region Overrided Mouse events<br />
<br />
protected override void OnMouseDown(MouseEventArgs e)<br />
{<br />
Point screen_impact = PointToScreen(new Point(e.X, e.Y));<br />
<br />
this.Visible = false;<br />
<br />
if(e.Button == MouseButtons.Left)<br />
MouseLeftDown(ref screen_impact);<br />
<br />
this.Visible = true;<br />
}<br />
<br />
protected override void OnMouseUp(MouseEventArgs e)<br />
{<br />
Point screen_impact = PointToScreen(new Point(e.X, e.Y));<br />
<br />
this.Visible = false;<br />
<br />
if(e.Button == MouseButtons.Left)<br />
MouseLeftUp(ref screen_impact);<br />
<br />
this.Visible = true;<br />
}<br />
<br />
protected override void OnClick(EventArgs e)<br />
{ <br />
<br />
this.Visible = false;<br />
<br />
MouseLeftClick();<br />
<br />
this.Visible = true;<br />
}<br />
<br />
protected override void OnMouseWheel(MouseEventArgs e)<br />
{<br />
} <br />
<br />
#endregion<br />
}<br />
}
|
|
|
|
|
I have a page that I am generating using some System.Web.UI.Webcontrols.
On that page is a list box, a text box and a button. I want the user to place some data in the text box, click submit, and then have the list box populated depending on that data. How do I do that? (If someone just told me what I should be reading that would be great!)
Thanks a lot,
Jim
|
|
|
|
|
handle a click event for the button, and then read the data using the .Text property. How you decide to fill the list box from that is up to you.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I have two forms, Form1 and FormNew. Form1 contains a serial control. FormNew needs to write to that control. How can I do that? I am able to create an instance of FormNew and then make it pop up and work and do stuff, but now I am to the place where I wish to send commands to an embedded board via the serial port and then post the result to the text boxes.
Ideas??
Kenny O'Dell
Sr. R&D Software Engineer
Mettler-Toledo Inc.
Inman, SC
|
|
|
|
|
You need to pass an instance of Form1 to FormNew , either in the construct or as a property or even a method. It really doesn't matter:
class Form1 : Form
{
private void ShowFormNew()
{
using (FormNew form = new FormNew(this))
form.ShowDialog(this);
}
}
class FormNew : Form
{
Form1 parentForm;
private FormNew(Form1 form)
{
parentForm = form;
}
} Depending on how you open FormNew in your scenario and assign an owner to it, the Form.Owner property may be valid. Read the documentation for the Form class and its members in the .NET Framework SDK for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for the help. I'm off to the races. Hey, I have another general question. This app is using the serial port, but it would be nifty to add USB to it later. We make scales for all sorts of things, trucks, grocery store, post office, etc... Some of my designs talk HID POS. Long ago we had a contractor help us with the first deployment and he wrote the PC stuff. Now I want to do this myself in .NET C#. So the question is does someone sell a component for USB? Sort of like the Sax.Net component I use for serial?
You might be not believe it, but lots of folks still use serial, especially in the industrial world, but they are adding USB a little here and there.
Kenny O'Dell
Sr. R&D Software Engineer
Mettler-Toledo Inc.
Inman, SC
|
|
|
|
|