|
Hi,
How do I create a COM component in C~ when i know the CLSID of the component, this CLSID is discovered in real-time so i can not add a reference to the DLL at compile time.
Cheers
|
|
|
|
|
The answer is....
Type comType = Type.GetTypeFromCLSID( new Guid( "12345678-0000-....") );
object comObj = Activator.CreateInstance( comType );
// if you have type infos (tlbimp/reference), try to cast:
YourCOMClass yourObj = (YourCOMClass) comObj;
// or for some special imported types, wrap:
// YourCOMClass yourObj = (YourCOMClass) Marshal.CreateWrapperOfType( comObj, typeof(YourCOMClass) );
To access remote by DCOM:
Type dcomType = Type.GetTypeFromCLSID( guid, "REMOTE_PC", false );
|
|
|
|
|
Can I set ReadOnly for a user control? I have some controls such as textbox , radiogroup, datagrid in my user control. I want to set all of them readonly in UserControl level. When I need read-write, I want to turn read-only off easily.
How to impliment this? Thanks.
Chris#
|
|
|
|
|
In your properties set function, set all the child controls according to what they have set the property to.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Chris# wrote:
Can I set ReadOnly for a user control?
The framework won't do this, this is something that needs to be done on a case-by-case basis because ReadOnly doesn't make sense to everything (progress control for example).
Also you need to keep in mind that ReadOnly is only a UI state, code can still read/write to the controls, the controls just don't accept user input.
With those ideas in mind...
private bool isReadOnly = false;
public bool ReadOnly
{
get
{
return isReadOnly;
}
set
{
isReadOnly = value;
textBox1.ReadOnly = isReadOnly;
}
} Good Luck,
James
Simplicity Rules!
|
|
|
|
|
In the .net framework is there a function that would process any pending messages in the message queue for the current thread, so while reading folders from a hard drive I could still move the window around.
Thanks
|
|
|
|
|
|
Hi,
Sorry, I know it maybe a bit dumb to ask this question.
But if I wrote class library that inherit some MFC classes,
can I use them in my C# project?
Thank you in advance
|
|
|
|
|
If you used managed C++, then I believe so. Ask in the MC++ forum to be sure.
|
|
|
|
|
They can't live in the *same* project, but you can use them together if you write an MC++ class library which wraps the MFC classes, then you can use that from a C# app, rather easily I might add The hard/tedious part is going to be wrapping the MFC class.
James
Simplicity Rules!
|
|
|
|
|
|
They can leave in the same solution so you can P/Invoke the C# or the unmanged code from C#
Al
|
|
|
|
|
In my MFC application, I draw lines over graphics and text
controls.
void CAboutDlg::OnButton1( )
{
CClientDC dc( this );
dc.MoveTo( 0, 0 );
dc.LineTo( 200, 200 );
}
The black line will draw over anything on the form.
--------------------------------------------------------
Now, in C# I cannot figure out how to draw on 'top' of the
controls.
private void Button1_Click(object sender, System.EventArgs
e)
{
Graphics g = CreateGraphics( );
g.DrawLine( Pens.Black, 0, 0, 200, 200 );
}
When I want to draw this line, it draws on the background
and does not draw over the bitmaps or text.
So, how do I draw on top of all the objects in a form?!
Transparent controls are not an option in this case.
Thanks in advance!!
|
|
|
|
|
because you tell him to create a graphics for the Window Form you are using
ex : suppose the text you want to put on the form is a label called "lab"
- make this :
Graphics g = lab.CreateGraphics();
instead of CreateGraphics because if you only write CreateGraphics, it's the sams as this.CreateGraphics.
Do you understand ??
I hope I help you
Jonathan Pouliot
|
|
|
|
|
Yes, I definitely understand. Unfortunately, it's not that easy.
I am needing to draw from one control to another across the entire form. The code you showed me basically only lets me draw within one control.
The final application has two fingerprint images and lines connecting identifying features between the two.
|
|
|
|
|
hi
i have stored form names in an arraylist. i need to create an object of each form in the arraylist and display it....
but when i create an object say f1 of arraylist frmnum[0]....it gives an error...
i have no idea how to go about this.....do i need to use typecasting....if yes ....please tell me how
bye
|
|
|
|
|
Yes is the answer to your question, you will need to typecast whatever you are getting back out of the ArrayList to the value type you need. This code cycles through the ArrayList arrlstApts which holds an array of points. To assign the value into apt we must cast it as such (Point[])
for(int i = 0; i < arrlstApts.Count; i++)
{
Point[] apt = (Point[])arrlstApts[i]
}
Nick Parker
|
|
|
|
|
i tried to typecast to Form type like this:
for(int i = 0; i < frmnum.Count; i++)
{
Form[] apt = (Form[])frmnum[i];
}
but it is giving an exception error saying "System Invalid Cast Exception" occurred
Additional Information :Specified Cast is not valid.
please tell me how to do it!
|
|
|
|
|
Maybe it is silly question.Is it possible to bind the Text property of ListBox to the column of database? If I set the DataSource and DisplayMember it shows all of the column in listbox,but I want to show each field seprately and use BindingContext.Position++ to show records in listbox.Is that possible?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Anyone have the code worked out to scan every file in every directory on a hard drive to locate a single file possibly using DirectoryInfo and FileInfo?
Kyle
|
|
|
|
|
You could do something like this, inside the loop I am adding the file to a listbox:
string m_CurrentDirectory = "C:\";
string[] AllFiles = Directory.GetFiles(m_CurrentDirectory, "*.*");
foreach (string aFile in AllFiles)
{
string aFileName = GetFileNameFromPath(aFile);
this.listBox1.Items.Add(aFileName);
}
Nick Parker
|
|
|
|
|
Thanks Nick. This works well for a single directory but I need to develop a routine that will search not only the root of drive C but also every sub-directory until the entire harddrive has been searched.
Kyle
|
|
|
|
|
public void SearchHardDrive(string harddrive)
{
DirectoryInfo di = new DirectoryInfo(harddrive);
SearchDirectory(di);
}
private void SearchDirectory(DirectoryInfo di)
{
DirectoryInfo [] dirs = di.GetDirectories();
foreach(DirectoryInfo dir in dirs)
{
SearchDirectory(dir);
}
FileInfo [] files = di.GetFiles();
foreach(FileInfo file in files)
{
DoSomethingWithFileInfo(file);
}
}
private void DoSomethingWithFileInfo(FileInfo file)
{
} Enjoy
[Edit: Okay, I'm an idiot I click on the wrong post to reply too ]
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
[Edit: Okay, I'm an idiot I click on the wrong post to reply too ]
No way James, I didn't have time to reply to Kyles response yet. Thanks
Nick Parker
|
|
|
|
|
Thanks guys,
Here is an approach that works well.
Kyle
using System.Management;
string drive = "\"c:\"";
string filename = "\"test\"" ;
string extension = "\"exe\"";
string qry = String.Format( "select * from cim_logicalfile where drive={0} and filename={1} and extension={2}", drive, filename, extension);
ManagementObjectSearcher query = new ManagementObjectSearcher(qry); ManagementObjectCollection queryCollection = query.Get();
foreach(ManagementObject mo in queryCollection)
{
Console.WriteLine( "Name '{0}' :Path: '{1}' ",mo["Name"], mo["Path"]);
}
[Edit: The : P shows up as a smily face. Although I am happy with this result the smily face was unintentional. ]
|
|
|
|