|
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??
|
|
|
|
|
I'm trying to load an excel document into my application using Excel COM but I cannot get the Open () command to work... This is my code:
Excel.Application app = new Excel.Application ();
app.Visible = true;
app.Workbooks.Open (...)
the first parameter is of course the file name (as a string?) but what type of objects should the other parameters be???
Andreas Philipson
|
|
|
|
|
Use Missing.Value from System.Reflection for parameters that you want to have the default value
|
|
|
|
|
DVryce wrote:
What kind of statement do I have to use to get C# to reference the DLL?
You don't need any statements. If you have VS.NET, just add a reference to your MC++ dll from Solution explorer. If you work from the command line, you will need to reference the library when compiling your project.
I vote pro drink
|
|
|
|
|
I'm trying to play a bit with C# and multifile assemblies. Documentation mentions al.exe and csc.exe (linker and compiler) as tools needed for that but I can't find them in VS.NET RC. Anybody knows where to find them?
Thanks
CK
|
|
|
|
|
C:\WINNT\Microsoft.NET\Framework\v1.0.2914
Nish
p.s. For you C might be D or E
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Thanks a lot. I quiried only VS.NET directory so I missed them.
Regards
CK
|
|
|
|
|
Hi,
I am having some problems in calling a managed code( server) from an unmanaged client. I created a WebService Application in C# and a Win32 based console client. The client is working fine when both the server and the client are located on my computer( Windows 2000). However, invoking the client application from another computer on the same network results in an error, whose value is -2147221164. From the Error Lookup option, the message obtained correspoding to -2147221164 is "Class not registered".
So,i copy the entire client project on this other computer(Windows NT).It does not have a .NET compiler.On building the project in Visual Studio 6, gives an error which is: Unable to include atlsoap.h : No such File.
Can anyone suggest me how to deal with this queer problem and what these error messages signifies ??
Vivek.
|
|
|
|
|
In VS.NET right click on the references node in solution explorer.
Click "Add Reference", on the COM components tab choose the component you wish to use (OCX).
You might want to then add it to the toolbox as well, right click on the Toolbox tab you want to add it to, and choose "Customize Toolbox"; then select your COM component again.
HTH,
James
Sonork ID: 100.11138 - Hasaki
and a digital cookie (not chocolate chip, its computer chip) goes to whoever can be the first to tell me what Hasaki means. I know someone registered on here can tell me
|
|
|
|
|
Is there an easy way to maximize a winform at runtime?
For instance, by setting a property instead of getting the
screen dimensions and then specifying the size manually?
|
|
|
|