|
Row and Column are nothing but the pixel values only!
logically, i undestand that what event i have to go for but i dont have much experience on graphics programming part so thats my main problem.
|
|
|
|
|
When you will handle the MouseClick event, the MouseEventArgs object will have the location. The coordinates will be based on the top left of the picturebox. This means that it the location comes out to be (10,10), it means it is at a location of 10,10 with respect to the top left corner of the picture box.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Using the click event, get the mouse coordinates. Then display them in your textbox.
Add the x coordinate value in one collection, the y coordinate value in another collection.
meetmak wrote: and fed into a .dll file
Not sure what you mean by that.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Actually, once the point values are stored as two arrays they are transferred into a .dll(Dynamic Link Library) file which requires that collection of array as the input.
and after taking this input it generates some output.
i hope , you get me now.
|
|
|
|
|
logically, i undestand that what event i have to go for but i dont have much experience on graphics programming part so thats my main problem.
|
|
|
|
|
Don't use an an array, use List<Point> , where Point can be found in the System.Drawing namespace. Depending upon your implementation you might also consisder BindingList<Point> and ObservableCollection<Point> instead of the list, as these both support bindin gto the UI.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Thank you for the reply!
actaully i cant go for "list" as my .dll file takes the collection as array only!
logically, i undestand that what event i have to go for but i dont have much experience on graphics programming part so thats my main problem.
|
|
|
|
|
Error : "The type or namespace HRESULT could not be found(are you missing a using directive or an assembly reference)"
Code Snippet
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid(IIDGuid.EnumIdList),
]
internal interface IEnumIDList
{
[PreserveSig()]
HRESULT Next(uint celt, out IntPtr rgelt, out int pceltFetched);
[PreserveSig()]
HRESULT Skip(uint celt);
void Reset();
void Clone([Out, MarshalAs(UnmanagedType.Interface)] out IEnumIDList ppenum);
}
Please help...
|
|
|
|
|
For C#'s COM Interop HRESULT will be returned as uint when using the PreserveSig(true) attribute. Change the method signatures in your interface of the two methods that return HRESULT to return uint instead and you should be good to go. You can also go a step further and create a uint enum that defines the possible result values:
public enum Next_HRESULTs : uint
{
S_OK 0x...,
...
}
public enum Skip_HRESULTs : uint
{
S_OK 0x...,
...
}
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
Hi Friends,
I want to do some registry settings changes through my .net app. Registry settings change will happen only in the "Settings" part of the app like "Starts at Windows" i.e. put an entry in the "Run" key. But to do this things in Win7 or Vista I am experiencing problems like Unauthorized access due to UAC. I am not being able to change the settings. I don't want to run the app in admin mode each time it runs, I just only want to elevate the permission at the time of changing the registry settings. Can anyone please help me out in this situation on how to accomplish this task like by modifying manifest file or putting permission attribute, anything at all.
Thanks in advance.
|
|
|
|
|
Are you writing to HKLM? Try writing to HKCU and you will not have security issues.
|
|
|
|
|
I tried with
<br />
RegistryKey runKey = Registry.CurrentUser.OpenSubKey(@"\Software\Microsoft\Windows\CurrentVersion\Run", true);<br /> but runKey is getting always null in Win7 and XP also. What to do? Please help me out.
|
|
|
|
|
I am trying to call the following method from a library to an exe file using a delegate, can anyone help with the following code, am I missing something, if so what and where do I add it. Below where it says “//********Error************”
I called the delegate and I get the error message “Object reference not set to an instance of an object.” with Troubleshooting tips “Use the “new” keyword to create an object instance”.
Thanks in advance,
Michael
namespace z
{
static class Program
{
[STAThread]
public static void Main()
{
A a = new A();
DelegateMethodA delegateMethodA = new DelegateMethodA(a.MethodA);
}
}
//Execution class
class A
{
void MethodA(Int32 x)
{
y = x + 1;
}
}
//Library in separate project
public delegate void DelegateMethodA(Int32 x);
class B
{
public static DelegateMethodA delegateMethodA = null;
void MethodB()
{
delegateMethodA (Int32 x); //********Error************
}
}
}
|
|
|
|
|
Hi,
inside class B you have a delegateMethodA which is null, and never changes, hence MethodB() will never succeed. the delegateMethodA inside class Program is unrelated.
You really should use an event to "link" both classes.
I suggest:
- you read up on delegates and events;
- you study an introductory book to C#;
- you look at how Visual Studio and Visual Designer generate code when connecting a Button to its click handler.
PS: please use PRE tags (e.g. through the "code block" widget when showing code), as it results in better readability.
|
|
|
|
|
Hello,
i'll try to be concret on my problem.
I want to convert a string: "alex" to bits (by bits I mean 0 and 1) and then write them into a binary file.
There are many ways to do this, but i've selected this:
private void MyWriteMethod()
{
byte[] bytes = UTF8Encoding.Default.GetBytes("alex");
Stream str = File.Create("test.bin");
BinaryWriter bw = new BinaryWriter(str);
BitArray bits = new BitArray(bytes);
for (int i = 0; i < bits.Length; i++)
{
bw.Write(bits.Get(i));
}
}
My problem is:
All goes well, but when I look for my file it occurs 32 bytes on my HDD.
Now to do a comparison, I create a new file and write by hand the text "alex". When I look for this new created file, I see that it occurs 4 bytes!!!!
My questions are:
1. Why is that ?? Can anyone explain to me this phenomenon ??
2. Can I occure the same amount of bytes using the bits ?
3. Afther that may I recive a code sample on how this can be done? I mean: how can I write bits to a binary file?
Thanks you for you're patience!
Alex Manolescu.
modified on Tuesday, December 29, 2009 3:58 AM
|
|
|
|
|
oldsellerros wrote: 1. Why is that ?? Can anyone explain to me this phenomenon ??
It's lazy and writing a whole byte. It could save up bools in batches of 8 and flush them when there are 8 or when something else is written, but they just didn't make it like that.
oldsellerros wrote: 2. Can I occure the same amount of bytes using the bits ?
Could you try to translate that again, maybe using a different translator?
oldsellerros wrote: 3. Afther that may I recive a code sample on how this can be done? I mean: how can I write bits to a binary file?
It has been done countless times before, just search codeproject/google for "bitstream C#" or something like that. Or you could make one yourself, just collect bits until you have 8 of them and then write them all at once in a byte. The exact details will depend on whether you want bytes/ints/etc to be byte-aligned or not
|
|
|
|
|
Thanks you verry much for answer! It really helps me.
Sorry for my mistake at question 2, it's about 3:15 AM in my country now and today is my birthday! i'm 22
At question 2 I mean:
Supose I have a file, 1.dat, with "alex" text in it. Can I write the bit array "alex" to a binary file that occurs the same amount of size like the fist file? something like that was in my mind.. hope you'll understand me!
Have a wonderfull day and Happy New Year!
I've got the answer now!
|
|
|
|
|
Happy birthday/new year
oldsellerros wrote: Supose I have a file, 1.dat, with "alex" text in it. Can I write the bit array "alex" to a binary file that occurs the same amount of size like the fist file?
It's still a bit unclear to me, but the answer to what I think you mean would be yes
On the other hand, the file 1.dat is probably 4 bytes, right? In that case writing the string "alex" as 4 ASCII chars (or even as UTF8 since it's all below 127 anyway) should make the same file (at least in size, the bit-order could be different, depending on how you're writing the bits)
|
|
|
|
|
You're a genius ! Thanks for understanding. Now it's clear to me.
I'm verry grateful to you.
May I add you to my friends list? or something like that?
Could I have you're e-mail adress, I fell that I need to make you a gift for you're help!
Good luck!
Alex Manolescu.
|
|
|
|
|
You're welcome
Help here is free of course, but you can vote 5 for my posts if you really feel they helped you
|
|
|
|
|
I've voted 5 for you.
Thanks you for help!
|
|
|
|
|
Hi,
in a file system such as FAT or NTFS, files get allocated in multiples of sectors (512B) or clusters (several sectors). So you can't create a non-empty file of less than 512B of disk space.
the logical file length is expressed in bytes, so you can't create a non-empty file of less than 8 bits.
BitArray.Get() returns a bool; BinaryWriter.Write(bool) writes a byte, the doc says "Writes a one-byte Boolean value to the current stream, with 0 representing false and 1 representing true." That could be lazyness, or a defense against unaligned data. If it were to write a single bit, a consequent Write(int) would be misaligned, and the total logical length would not necessarily be a multiple of 8.
|
|
|
|
|
Thanks you verry much for you're quick answer!
I am verry grateful!
Happy New Year!
|
|
|
|
|
Hey,
I was wondering what this is called:
Class MyClass<MyType>
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
Hi,
class MyClass<MyType> is "generics", introduced with .NET 2.0
|
|
|
|