|
Hello,
I need some information on where to find and obtain a drives attributes, e.g, ROM_DRIVE or FLOPPY_DRIVE etc and other attributes pertaining to the drive. I've searched the MSDN library and other places to no avail. I've tried using Environment but can't get anything. Any insight would greatly be appreciated.
Thanks
|
|
|
|
|
Any sample on using CreateWindow API from c# ? I’m aware of “MessageBox” sample on MSDN but I’ve no idea on how to retrieve HWND of Form and Instance handle. I’m trying to put together code to use virtual listview. virtual listview is available in SDK not with .Net. Any idea would be truly appreciated.
Thanks
|
|
|
|
|
kasturirawat wrote:
...I’ve no idea on how to retrieve HWND of Form and Instance handle.
For the HWND use the Forms Handle property. The HINSTANCE is a bit harder to get, but still possible.
untested code, but from the docs this should work; though the GetHINSTANCE method confuses me a bit as i'll explain later.
<br />
IntPtr hInstance = System.Runtime.InteropServices.Marshal.GetHINSTANCE(<br />
typeof(ClassThatHasYourHInstance).Module <br />
);<br />
Here's the confusing part about this method
Parameters
m
The module whose HInstance is desired.
Return Value
The HInstance for m;-1 if the module does not have an HInstance.
Remarks
Whether dynamic or in-memory, modules do not have an HInstance.
It looks like this method will work until you read the remarks. We pass in the module whose hinstance we wish to retreive, but then the remarks tells us that modules don't have one. Thus we will always get -1.
I seem to vaguely remember there being some win32 function that would give you the hinstance if you had the hwnd. Since you have the hwnd you could call this function and get the hinstance (call via p/invoke).
HTH,
James
Sonork ID: 100.11138 - Hasaki
|
|
|
|
|
I’ve created sample for virtual listview using SDK. Since dotnet does not support virtual list view, is there any way I can use my sdK sample with dotnet app. Using PINVOKE is very time consuming
|
|
|
|
|
I believe you could wrap your code with MC++ providing an interface for your dotnet app to work with it. Thats about the extent of my knowledge on MC++ though. :p
Perhaps someone with a better grasp could fill you in more?
James
Sonork ID: 100.11138 - Hasaki
|
|
|
|
|
Do Anyone know how to use TAPI in C# or any component in .Net that enable Voice over IP application???????
|
|
|
|
|
Hi,
Can any one tell me how I can Automate MS Office 97/2000/XP using the same C# Code. Using VB I could use Late Binding to do this, but I can not figure out how to do it using C#. I wish to have one C# Program which will work on all versions of MS Office.
Thanks for your time
Peter Tewkesbury
Peter Tewkesbury
|
|
|
|
|
Just off the top of my head, so i have no idea how much work this would be...
Abstract the functionality you need from office into an interface or abstract class. Then write a class for each version of office. At runtime detect which version of office is installed and use the proper class.
You might have to break each class into a separate assembly so it won't try loading office 97 typelib info when you want xp info. My knowledge of how the references get loaded is minimal though, so this may be an extraneous step.
Hope this at least gives you some ideas,
James
Sonork ID: 100.11138 - Hasaki
|
|
|
|
|
Thanks for the info. I now have a working solution thanks to .NET
1. Write the base class in C# in a seperate DLL & namespace
2. Derive a new class in VB from the base class in another DLL - I can use Late Binding features of VB to automate MS Office (All Versions) without writing pages of code.
3. Use this new class in the top level program (C#)
All Thanks for .NET
Man I love .NET
Peter Tewkesbury
Developer
ibsl technologies
|
|
|
|
|
I am writing a custom Grid and can't figure how to get the scrolling to work.
I am trying to call ScrollWindow from CSharp and it doesn't seem to be doing anything. I am not getting any exceptions. Can anyone explain what the expected results should be or tell me what i am doing wrong.
Any help would be great!!!!
Code: [DllImport("User32.dll")] public extern static bool ScrollWindow(IntPtr hWnd, int nXAmount, int nYAmount, ref RECT rectScrollRegion, ref RECT rectClip);
public struct RECT {
public int bottom;
public int top;
public int left;
public int right;
public RECT(int left, int top, int right, int bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
}
/***************/
RECT rect = new Rect(102, 2, 770, 381); bool b = NativeMethods.ScrollWindow(this.Handle, change, 0, ref rect, ref rect);
|
|
|
|
|
I think you're doing too much work on your own here. Windows Forms provides a ScrollableControl class (as well as Panel and ContainerControl).
If you have your control inherit from one of those the scrolling will be taken care of for you, you can set the current position with the AutoScrollPosition property (assuming you have autoscrolling enabled).
Now sure off hand what sets the bounds for scroll, my first guess would be something with the AutoScrollMinSize property.
HTH,
James
Sonork ID: 100.11138 - Hasaki
|
|
|
|
|
Here's a reply I got offline from the original poster, posted here for archival purposes
Thanks for the suggestion, but i determined what my
error was. I defined my RECT structure incorrectly so
that when it was being passed from managed to
unmanaged code, it was being marshalled incorrectly.
The correct definition of RECT:
[StructLayout(LayoutKind.Explicit)]
public struct RECT
{
[FieldOffset(0)] public int left;
[FieldOffset(4)] public int top;
[FieldOffset(8)] public int right;
[FieldOffset(12)] public int bottom;
public RECT(int left, int top, int right, int
bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
}
Sonork ID: 100.11138 - Hasaki
|
|
|
|
|
Is it possible to write a function that return 2 different data types?
e.g. if it's TRUE, it returns a string, and if it's FALSE, returns an array of string.
Thanks alot!
|
|
|
|
|
If C# supports a VARIANT you could do it that way, so long as both types were able to be stuffed into a VARIANT.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
You could also use the out keyword.
public bool OurFunction (out object value2)
{
bool value;
if (value)
value2 = "This object returned true!!!";
else
value2 = new string [] {"This object", "returned", "true", "!!!"};
return value;
}
Or you could simply just return an object and then check the type wheter it's true of false...
public object OurFunction2 ()
{
bool value;
object value2;
if (value)
value2 = "This object returned true!!!";
else
value2 = new string [] {"This object", "returned", "true", "!!!"};
return value2;
}
public void MainFunction ()
{
object obj = this.OurFunction2 ();
if (obj.GetType () == typeof (string))
Console.WriteLine ("TRUE!!!")
else
Console.WriteLine ("FALSE!!!");
}
Andreas Philipson
|
|
|
|
|
It could return object, which could either be a string or an array of string.
In general, however, I think that's a bad idea. Why not return an array with a single item for the first case?
|
|
|
|
|
Hello all,
I need to use a fixed-width font such as FixedSys or System fonts, but the Font object does not recognize them. I believe the problem is with the FontFamily object for not recognizing them. Everytime I try to give the Font object "FixedSys" as a font name, it resets it to "Microsoft San Serif". anyone knows of a way around this?
thanks
fadi
|
|
|
|
|
Hi everyone,
I have a string like:
"[FormField width=30 type=upload]"
Using RegEx, I want to take the value of "type", and of width, and output them to their own seperate strings. How do I do this?
I thought I might be able to do this using Regex.Match, but that just modifies the original string, not write them out to new strings.
Any help with this is greatly appreciated.
Thank you!
|
|
|
|
|
Use a regex like:
@"width=(\d+) type=(.+)]";
if this matches, look in the match.Groups[0] for the first value, and [1] for the second value.
You can also use named captures:
@"width=(?<width>\d+) type=(?<type>.+)]";
and then use match.Groups["width"] and ["type"]. That really helps the readability of code.
|
|
|
|
|
Which programming language is better, when developing Windows Application?
C# or Visual C++ MFC
On the other hand C# seems easy to handle then MFC?
What do you think? Which on is stable ??
|
|
|
|
|
Right now you'd be better off with MFC.
Maybe 6 months later you might think C#
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Can i use remoting in a Win 9x/Me machine ?
|
|
|
|
|
Hi guys, I have a control that has some picturebox controls on it. I'd like that the form on which my control is placed recieves an event notification when a picture box control recieves a MouseDown event. Simple enough but I'd like to use events. Right now I'm not sure what the code should look like. How and where do I add the parent form as a listener for an event happening within a control embedded within another control?
Pseudo code will do.
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Add this code to the constructor...
this.pictureBox.MouseDown+= new System.Windows.Forms.MouseEventHandler(this.onMouseDown);
and the function which handles the mouse down...
private void onMouseDown (object sender, System.Windows.Forms.MouseEventArgs e)
{
}
This can be automated if you're using VS.NET...
Andreas Philipson
|
|
|
|
|
how do you automate this is VS.NET??
|
|
|
|