|
Of cource that's perfect that it is built-in ability, but it is required to have own realisation w/o standart features ... =(
|
|
|
|
|
Now that is a silly requirement. A bit like "print text to the console without using any build-in .NET code"
Are you allowed to use CryptAPI?
|
|
|
|
|
I know, that it's silly, but requirements are so.
No. I'm not allowed to use any external libraries etc.
So, do you know, where can I look for my headache?
|
|
|
|
|
You wont find any since the most used implementation in C# is going to be the .NET Framework's built-in library. Any custom implementation that goes outside the stanard is going to be proprietary and very secret to the organization using it. On top of that, noone is going to just hand over their own hard work to someone they don't know. Also, if you didn't write the implementation, how on earth are you going to debug and support it??
|
|
|
|
|
Yes, You are right. But it's sorrowful for us. We spent a lot of time searching for necessary info, but found nothing. Only source in C++. Probably, the best way is to rework it into c#?
|
|
|
|
|
Why do that when you can just compile the C++ source into a .DLL and use that from C#...
|
|
|
|
|
Hmm.. It's interesting idea, we hadn't think about it yet, thnx!
|
|
|
|
|
Hey all,
I was wondering if there is a way to change a single property on a couple of controls at the same time. Like in my app, I have to change the ReadOnly and BackColor of 10 TextBoxes at the same time.
Do I have to go like:
txtTextBox1.ReadOnly(True);
txtTextBox2.ReadOnly(True);
etc...
Or would there be something like:
txtTextbox1, txtTextbox2.ReadOnly(True) ?
That would save me a heap of coding....
Thanks!
Yup, I'm a NooB
|
|
|
|
|
Hi,
there is no special syntax available to indicate multiple controls.
This is what you can do:
1. either create a collection (say a List< Control> ) and put the references to the Controls of interest in there, then do a foreach(Control ctrl in myControlList) ctrl.DoSomething();
2. or enumerate all Controls on the Form and test some characteristic, e.g.
foreach(Control ctrl in this.Controls) {
TextBox tb = ctrl as TextBox;
if (tb!=null) {
if (tb.Name.StartsWith("aha")) || tb.Tag!=null) {
tb.ReadOnly=true;
}
}
}
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
this must be in recursive method...else the textboxes in container controls will not be effected
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
this is what you want is;
foreach (Control txt in this.Controls)
if (txt is TextBox)
((TextBox)txt).ReadOnly = true;
|
|
|
|
|
Wouldn't that be txtTextBox1.ReadOnly = txtTextBox2.ReadOnly = True ; ?
|
|
|
|
|
Thanks everyone!
Yup, I'm a NEWB
|
|
|
|
|
Hi
i have a form and i inserted a gif image to it's resx file (local resource). now, i want to retrieve it and display to picturebox, for this, i wrote this code :
this.pictureBox1.Image = Image.FromStream(this.GetType().Assembly.GetManifestResourceStream("MyAppNamespace.Form1.wait1.gif"));
but the following error message shown me :
Value of 'null' is not valid for 'stream'.
where does my problem and how to solve it ?
Thanks
|
|
|
|
|
Why don't you just do this?
this.pictureBox1.Image = Properties.Resources.wait1.gif;
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
Hi Kristian
Your suggesstion is for global resource wheras in my situation is local resource (for example: Form1.resx file)
|
|
|
|
|
Hi,
hdv212 wrote: where does my problem and how to solve it ?
If you put all the action in one big line of code you can be sure of two things:
1. if there are any problems, they will be in that one line;
2. it will be difficult to debug.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:28 AM
|
|
|
|
|
Hi Luc
You mean which i wrote this code :
System.IO.Stream stream= this.GetType().Assembly.GetManifestResourceStream("DevExpressLoadingTest.Form1.resources.wait1.gif");
this.pictureBox1.Image = Image.FromStream(stream);
|
|
|
|
|
How about:
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("wait1.gif")));
I think that would work. And the chances are that in the code you have now "MyAppNamespace.Form1.wait1.gif" is incorrect, although I 'm not sure what it should be if that is the case.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks SK Genius
i was tried your suggesstion like this :
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("wait1.gif")));
it's no coused error, but does not show show image. when i trace my code, i saw that this.pictureBox1.Image is null.
|
|
|
|
|
I want to place a MDI form at a certain position in relation to the MDI background application window.
Ie. When I display a certain form I would like to display the form on the right of the applications MDI window and locatthis child form in the top right corner.
How could I achieve this in c#.
|
|
|
|
|
In the Activate or Shown Event of the child form you could probably include code like the following:
this.Location = new Point(this.ParentForm.Width - (this.Width + 10), 0);
Of course, if you put the code in the Activate event you will want to ensure the code only executes the first time the form activates. That should get your MDI child in the ballpark of the right corner of the parent form. You might have to play around with the value you add to this.Width a little bit.
Good luck.
|
|
|
|
|
How can I know where a url gets redirected programatically?
e.g. This url:
http://scobleizer.com/feed/
redirects to the following url:
http://feeds2.feedburner.com/fastcompany/scobleizer
I am trying to read the xml document of feed. But the following lines of code:
var doc = new XmlDocument();
doc.Load(url);
will throw an exeption for the first url:
System.Net.WebException: The remote server returned an error: (404) Not Found.
|
|
|
|
|
Hey,
i want to generate a WM_DROPFILES Message and send it to a Control on my Form.
i found one sample in c++
http://groups.google.de/group/microsoft.public.platformsdk.shell/browse_frm/thread/5bbd1d67913ac2c7?hl=de&lr=&rnum=2&prev=/groups%3Fq%3Dsendmessage%2Bwm_dropfiles%26hl%3Dde%26lr%3D%26selm%3D03c301c3973d%25240433f8e0%2524a101280a%2540phx.gbl%26rnum%3D2
does anybody know how it sounds right in C# .Net 2.0?
here my trying, which doesnt work:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace DropFile
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(341, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(142, 40);
this.button1.TabIndex = 0;
this.button1.Text = "Load Image";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(860, 546);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
this.DragOver += new System.Windows.Forms.DragEventHandler(this.Form1_DragOver);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (FileList.Length == 1)
{
FileInfo fi = new FileInfo(FileList[0]);
if (fi.Extension == ".gif" | fi.Extension == ".bmp" | fi.Extension == ".jpg" | fi.Extension == ".jpeg")
{
e.Effect = DragDropEffects.Move;
}
}
}
else
e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (FileList.Length == 1)
{
FileInfo fi = new FileInfo(FileList[0]);
if (fi.Extension == ".gif" | fi.Extension == ".bmp" | fi.Extension == ".jpg" | fi.Extension == ".jpeg")
{
this.BackgroundImage = Image.FromFile(FileList[0]);
}
}
}
else
e.Effect = DragDropEffects.None;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public const uint GMEM_FIXED = 0x0000;
public const uint GMEM_SHARE = 0x2000;
public const uint WM_DROPFILES = 0x0233;
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern int GlobalLock(IntPtr Handle);
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern int GlobalUnlock(IntPtr Handle);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam,
IntPtr lParam);
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public Int32 X;
public Int32 Y;
public POINT(Int32 x, Int32 y)
{
this.X = x;
this.Y = y;
}
}
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
class DROPFILES
{
public int size;
public POINT pt;
public bool fND;
public bool WIDE;
}
public static byte[] RawSerialize(object anything)
{
int rawsize = Marshal.SizeOf(anything);
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.StructureToPtr(anything, buffer, false);
byte[] rawdatas = new byte[rawsize];
Marshal.Copy(buffer, rawdatas, 0, rawsize);
Marshal.FreeHGlobal(buffer);
return rawdatas;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_DROPFILES)
{
bool bTest = true;
}
base.WndProc(ref m);
}
private void button1_Click(object sender, EventArgs e)
{
IntPtr hwnd = this.Handle;
DROPFILES s = new DROPFILES();
s.size = 20;
s.pt = new POINT(10, 10);
s.fND = false;
s.WIDE = false;
string file = "D:\\test.bmp\0";
Int32 filelen = Convert.ToInt32(file.Length);
byte[] bytes = RawSerialize(s);
int structlen = (int)bytes.Length;
int size = structlen + filelen + 1;
IntPtr p = Marshal.AllocHGlobal(size);
GlobalLock(p);
int i = 0;
for (i = 0; i < structlen; i++)
{
Marshal.WriteByte(p, i, bytes[i]);
Console.WriteLine("Wrote header byte " + i.ToString() + " of " + size.ToString());
}
byte[] b = ASCIIEncoding.ASCII.GetBytes(file);
for (int k = 0; k < filelen; k++)
{
Marshal.WriteByte(p, i, b[k]);
Console.WriteLine("Wrote filename byte " + i.ToString() + " of " + size.ToString());
i++;
}
Marshal.WriteByte(p, i, 0);
GlobalUnlock(p);
PostMessage(hwnd, WM_DROPFILES, p, IntPtr.Zero);
Marshal.FreeHGlobal(p);
}
}
}
thanks a lot
Steffen
|
|
|
|
|
May be you should add:
this.AllowDrop = true;
in
private void InitializeComponent()
|
|
|
|