|
I`m made a simple Windows Control Library. I added some properties to be used at design time. Its ok - designing user may use them by entering eg. a string.
But suppose I would like to create a property responsible for selecting polygon. I want a special form to be opened then, which contains list of all possible polygons, allowing the user to select the desired one. How to make that?
thanks for any help
|
|
|
|
|
|
Hi
I have a user control which has a number of custom properties. Unfortunately these properties are not suitable for the designer to execute. As a result form’s which use this user control won’t open at design time in the designer.
Is there some way to prevent the designer from executing my user control properties?
Cheers
Rich
|
|
|
|
|
You can check the control's DesignMode property to conditionally vary its behavior in order for it to be created by the designer. Alternatively, you could create the control at run time.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Apply the [Browsable(false)] attribute to the properties which should not appear in the Properties window at design time.
:josh:
My WPF Blog[^]
|
|
|
|
|
Thanks Ravi + Josh, both solutions appear to work well
|
|
|
|
|
Hi guys,
I have a file that I am parsing and getting the data using Regex and storing the data in string dictionary.
Here is the statement where I assign data to stringcollection scoldata.
String [] arrTemp =null;
scoldata.Add(arrTemp[arrTemp.GetLowerBound(0)]);
My question is, when I assign data to scoldata, it's adding 5 characters, eg FBBBB, how do I get rid of the first character 'F' from this stringcollection?
Please help.
sasa
|
|
|
|
|
|
Thank you Ravi, I decided to go with String.Substring and it works now. Appreciate your help.
sasa
|
|
|
|
|
Hi!
Does anyone have an idea how it's possible to compact and repair an MS Access database using C#?
The option is avaiable in MS Access main menu but I don't want to do it manually.
Thanks in advance.
|
|
|
|
|
Try the COM object Access.Application.
You should be able to do it this way.
Eran Aharonovich (eran.aharonovich@gmail.com )
Noviway
|
|
|
|
|
How do I terminate all the threads my program has started when it closes? I've tryed this code:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)<br />
{<br />
if (serverThread != null)<br />
serverThread.Abort();<br />
if (clientThread != null)<br />
clientThread.Abort();<br />
if (receiveRoutineThread != null)<br />
receiveRoutineThread.Abort();<br />
}
However, the form closes and a process with my application's name remains running. Can anyone suggest me other way of doing this?
|
|
|
|
|
Just set the IsBackground[^] property on each thread you create to true and you should be done. When the GUI thread shuts down, .NET forces those threads to abort.
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Thread.Abort() actually aborts the thread when that operation can be performed.
For example, if the thread calls a time-consuming method, the thread won't be aborted until that method returns.
_____________________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA] - Developing ScrewTurn Wiki 1.0 Beta3
|
|
|
|
|
Hi All ,
I have some struct and hashtable.
In the hashTable i add objects of this struct.
How can i update the objects of the struct in the hashTable?
Example :
Public struct Struct_1
{
public int a;
public int b;
}
.
.
.
HashTable T;
Struct_1 R
T.add(R.a, R);
Question.... How can i update now the field a or b whan the object is in T ???
Thanks for any help.
|
|
|
|
|
You can do
int originalA = R.a;
Struct_1 newR = T[R.a];
newR.a = 42;
newR.b = 42;
T[originalA] = newR;
However, note that the above code changes the value for the previous key and because the key itself is part of the value, it can be confusing if you depend on key == ((R)T[key]).a .
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Hi,
I am trying to convert a little delphi source to CSharp. The code reads the names of exported methods out of a native library. In Delphi, it works very fine, but now I need to convert it to CSharp. The most work is already done, but there are two thinks to do left.
1. The variable "Name" should be of type string
2. The variable "virtualAddressOfMappedFile" should be an Int[]
You can find the bookmarks 1. and 2. in the attached source code.
For testing the source, simply create a new Console Application, and replace the code with the following.
Thanks,
Thomas van Veen (specialwork)
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
pInvoke.LOADED_IMAGE loadedImage = new pInvoke.LOADED_IMAGE();
try
{
if (pInvoke.MapAndLoad("advapi32.dll", null, ref loadedImage, true, true))
{
int dirSize = 0;
IntPtr pImageExportDirectory = pInvoke.ImageDirectoryEntryToData(loadedImage.MappedAddress, false, pInvoke.IMAGE_DIRECTORY_ENTRY_EXPORT, ref dirSize);
pInvoke.IMAGE_EXPORT_DIRECTORY imageExportDirectory = (pInvoke.IMAGE_EXPORT_DIRECTORY)Marshal.PtrToStructure(pImageExportDirectory, typeof(pInvoke.IMAGE_EXPORT_DIRECTORY));
pInvoke.IMAGE_SECTION_HEADER imageSectionHeader = new pInvoke.IMAGE_SECTION_HEADER();
IntPtr virtualAddressOfMappedFile = pInvoke.ImageRvaToVa(ref loadedImage.FileHeader, loadedImage.MappedAddress, imageExportDirectory.AddressOfNames, ref imageSectionHeader);
for (int i = 0; i < imageExportDirectory.NumberOfNames; i++)
{
IntPtr Name = pInvoke.ImageRvaToVa(ref loadedImage.FileHeader, loadedImage.MappedAddress, virtualAddressOfMappedFile.ToInt32(), ref imageSectionHeader);
Console.WriteLine(Name);
}
pInvoke.UnMapAndLoad(ref loadedImage);
}
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
pInvoke.UnMapAndLoad(ref loadedImage);
}
finally
{
Console.ReadLine();
}
}
}
public class pInvoke
{
public const int IMAGE_SIZEOF_SHORT_NAME = 8;
public const int IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16;
public const ushort IMAGE_DIRECTORY_ENTRY_EXPORT = 0;
[DllImport("Imagehlp.dll")]
public static extern bool MapAndLoad(string ImageName, string DllPath, ref LOADED_IMAGE LoadedImage, bool DotDll, bool ReadOnly);
[DllImport("ImageHlp.dll")]
public static extern bool UnMapAndLoad(ref LOADED_IMAGE LoadedImage);
[DllImport("Dbghelp.dll")]
public static extern IntPtr ImageDirectoryEntryToData(IntPtr Base, bool MappedAsImage, ushort DirectoryEntry, ref int Size);
[DllImport("Dbghelp.dll")]
public static extern IntPtr ImageRvaToVa(ref IMAGE_NT_HEADERS NtHeaders, IntPtr Base, int Rva, ref IMAGE_SECTION_HEADER LastRvaSection);
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct LOADED_IMAGE
{
public string ModuleName;
public IntPtr hFile;
public IntPtr MappedAddress;
public IMAGE_NT_HEADERS FileHeader;
public IMAGE_SECTION_HEADER LastRvaSection;
public int NumberOfSections;
public IMAGE_SECTION_HEADER Sections;
public int Characteristics;
public bool fSystemImage;
public bool fDOSImage;
public LIST_ENTRY Links;
public int SizeOfImage;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct IMAGE_EXPORT_DIRECTORY
{
public int Characteristics;
public int TimeDateStamp;
public short MajorVersion;
public short MinorVersion;
public int Name;
public int Base;
public int NumberOfFunctions;
public int NumberOfNames;
public int AddressOfFunctions;
public int AddressOfNames;
public int AddressOfOrdinals;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct IMAGE_NT_HEADERS
{
public int Signature;
public IMAGE_FILE_HEADER FileHeader;
public IMAGE_OPTIONAL_HEADER OptionalHeader;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct LIST_ENTRY
{
public IntPtr Flink;
public IntPtr Blink;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct IMAGE_SECTION_HEADER
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IMAGE_SIZEOF_SHORT_NAME)]
public byte[] Name;
public uint PhysicalAddress;
public uint VirtualAddress;
public uint SizeOfRawData;
public uint PointerToRawData;
public uint PointerToRelocations;
public uint PointerToLinenumbers;
public short NumberOfRelocations;
public short NumberOfLinenumbers;
public uint Characteristics;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct IMAGE_FILE_HEADER
{
public ushort Machine;
public ushort NumberOfSections;
public uint TimeDateStamp;
public uint PointerToSymbolTable;
public uint NumberOfSymbols;
public ushort SizeOfOptionalHeader;
public ushort Characteristics;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct IMAGE_OPTIONAL_HEADER
{
public ushort Magic;
public byte MajorLinkerVersion;
public byte MinorLinkerVersion;
public uint SizeOfCode;
public uint SizeOfInitializedData;
public uint SizeOfUninitializedData;
public uint AddressOfEntryPoint;
public uint BaseOfCode;
public uint BaseOfData;
public uint ImageBase;
public uint SectionAlignment;
public uint FileAlignment;
public ushort MajorOperatingSystemVersion;
public ushort MinorOperatingSystemVersion;
public ushort MajorImageVersion;
public ushort MinorImageVersion;
public ushort MajorSubsystemVersion;
public ushort MinorSubsystemVersion;
public uint Win32VersionValue;
public uint SizeOfImage;
public uint SizeOfHeaders;
public uint CheckSum;
public ushort Subsystem;
public ushort DllCharacteristics;
public uint SizeOfStackReserve;
public uint SizeOfStackCommit;
public uint SizeOfHeapReserve;
public uint SizeOfHeapCommit;
public uint LoaderFlags;
public uint NumberOfRvaAndSizes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = IMAGE_NUMBEROF_DIRECTORY_ENTRIES)]
public IMAGE_DATA_DIRECTORY[] DataDirectory;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct IMAGE_DATA_DIRECTORY
{
public uint VirtualAddress;
public uint Size;
}
}
}
|
|
|
|
|
hi all
i have made an activex by visual c++6 and want to use it in c#
i added the refrence to activex in my app and try to call one of it's methid. ut i got an catastrophic failure . what should i do?
is it enough to compile the activex ? or should i register it ? if so how to register it ?
thank you in advance .
|
|
|
|
|
Without the error message, there isn't anything anyone can do to help you.
Yes, the ActiveX control has to be registered before you can use it. Open a command prompt, change directory to the folder where the control (.OCX) file is residing and type:
REGSVR32 filename.ocx
Then you can add a reference to the COM registered control. Do NOT set a reference to the OCX file directly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thank you for your reply .
the error is system.runtime.interopservices.comexception(0x8000ffff)
i set a refrence to the .tlb file , but there is still error.
the activex work in vb6 .
should i do something more than adding the refrence?
|
|
|
|
|
thank you for your reply .
the error is system .runtime.interopservices.comexception(0x8000ffff)
i added the tlb file as a refrence but there still the error.
should i do something more than just adding the refrence??????????
|
|
|
|
|
Don't set the reference to the .TLB file! Set it to the registered copy of the .OCX. Just open the References dialog, click on the COM tab and find your control. Do NOT browse for the file!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hello,
I'm a visual c++ programmer,
i wanted some information about .net technology and how should i start with it and where to finish it,and how much time does it take,I study almost 8hours a day,
Best regards,
khodadad pakdaman.
|
|
|
|
|
|
It's all up to you my friend in how many hours you grasp a particular topic. If you nee books regarding .Net i can help you on it.By the way i am working on C# if u have any query you may ask i'll give you the answers if they are in my knowledge.Best Of Luck
fahad.ashraf.ali@gmail.com
Fahad
|
|
|
|