|
Hi there.
I'm created a borderless window, on which I put 8 panels containing my custom window border. I want the window to be resized when the user clicks+ drags from the right border. I created 3 event handlers for the right border panel...mousedown, mouseUp and mouseMove. On mouseDown, a flag is set and I get the location of the click. On MouseUp I unset the flag. On mouse move I do the following:
<br />
if (this.resizeRDown) <br />
{<br />
int Xdiff;<br />
Xdiff = e.X - this.ResizeRXY.X;<br />
this.Width = this.Width + Xdiff;<br />
} <br />
But the resizing is acting very weird...making the window a single pixel wide.
Can anyone give me a hint on this(or an article for that matter) that can help out.
Thanks
------------------------------------------------------------------------------
Programming......THE DEVINE GIFT!
|
|
|
|
|
What does the debugger say when you examine e.X and ResizeRXY.X? What values do they have at runtime?
Maybe you just calulate them wrong.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Well, that's what I actually prompted me to write here. I discovered that hovering was affecting this so I handled mousehover, so that it would unset the flag. It improved, but still acting kind of funny.
Well...for XDiff..the value is small.
What I want to know is whether e.X, e.Y (mouse location) is the coordinate with respect to the top,left (first location of window) or with respect to 0,0 of screen?
--------------------------------------------------
Programming...the golden price!
|
|
|
|
|
Depends on what e is. If it's a point from Cursor.Position , then MSDN says: A Point that represents the cursor's position in screen coordinates.
But you can use the PointToClient method to convert them into client coordinates.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
the code seems good at first glance but some parts are missing to clear this out. I assume you are setting ResizeRXY not correctly. Be beware of the affect that the X and Y coordinate of the MouseEventArgs are relative to the control which generated the event in relation to its parent (to the whole screen when working with a Form).
I quickly put together the following (where panel1 is a Panel docked to the right of a Form - but it shouldn't matter what kind of control it is):
private Point _resizePoint;
private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
_resizePoint = new Point(e.X, e.Y);
}
private void panel1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
_resizePoint = Point.Empty;
}
private void panel1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (_resizePoint != Point.Empty)
{
this.Width += (e.X - _resizePoint.X);
}
}
|
|
|
|
|
Hi, Thanks. Helped a lot.
--------------------------------------------
Programming is a devine gift
|
|
|
|
|
Hi
I am beginner at C#.
I need to create two classes which will represent two picture models(like JPG and bitmap).It should look something like this
class JPGImage
{
..............
}
class BMPImage
{
..............
}
I don't know how to describe this classes.
In winForm I need 2 panels where I'll put this 2 models.
Can you help me with this?
Thanks
|
|
|
|
|
It depends what you want to do.
In .NET, you use the Bitmap class to handle not only BMP images but also GIF, PNG and JPG - so from most points of view there would be no difference as to what members you would use to describe them.
|
|
|
|
|
OK thanks,
Does it mean that I can inherit from Bitmap class my
class like this :
class JpgImage : Bitmap
{
....
}
and create object JpgImage?
Which methods I can use for working with my class (class JpgImage)?
|
|
|
|
|
videhr wrote: Does it mean that I can inherit from Bitmap class my class like this :
No. the Bitmap class is sealed , which means you can't inherit from it.
You'd either need to use the Bitmap class, entirely write your own JpgImage class or use a mixture (a JpgImage class which uses a Bitmap instance and its methods)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks, i am starting to understand this.
Using this mixture should look like this:
Image JpgImage= new Bitmap("image1.jpg");
am I right?
|
|
|
|
|
I acutually thought about something like this:
class JpgImage
{
private Bitmap jpg;
public JpgImage(string file)
{
jpg = new Bitmap(file);
}
}
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'm not sure I understand this,but it is ok.
Now with jpg I can create drawing(like rectangular or elipse,line etc),am I right?
Thank you again,you have helped me a lot.
Sorry for bothering you.
|
|
|
|
|
videhr wrote: Now with jpg I can create drawing(like rectangular or elipse,line etc),am I right?
No you can't.
Sorry no offense, but I think you need to read a book about C# and take a lot of practice to understand how this stuff works
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
whats the point though? they all load in exactly the same way from Bitmap, no advantages / disadvantages from what you can do with them - just use the Bitmap class, or if you have to
public enum ImageType
{
JPG = 0;
PNG = 1;
etc
}
class Image
{
public bitmap itsBitmap;
public ImageType itsFormat;
}
|
|
|
|
|
hi guys,
how can i set the file that i create using c# (FileStream) to be automatically hidden or read-only? i dont want the client users to have access to that file that is why i want to hide it..
if there's a better way of doing this, im open to suggestions.. tnx in advance!
|
|
|
|
|
I think you have to use the File object in the System.IO namespace.
It would go something like:
<br />
File.SetAttributes(path, FileAttributes.Hidden);
See the following URL for reference:
File.SetAttributes Method
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Thanks for the immediate reply..
here's a follow up question. is it possible for the folder which contains the file to set its attribute also to hidden?
|
|
|
|
|
Have you looked at the DirectoryInfo object in the System.IO namespace?
It also has Attributes member.
Your code would be something like:
DirectoryInfo di = new DirectoryInfo(@"c:\Test");
di.Attributes = FileAttributes.Hidden;
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
thanks wayne! it workd..
|
|
|
|
|
Hello,
is it possible to create a .NET DLL (using C#.NET or C++.NET) that exports functions in C-style?
In VC++ we can use extern "C" __declspec(dllexport) for that. And in C#.NET or C++.NET?
Thanks in advance and best regards
Dominik
<small>and</small;gt;
<code>__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
-- modified at 4:46 Saturday 25th February, 2006
|
|
|
|
|
All public marked types are avalible outside your DLL in .NET
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thanks for your reply. How do I mark a type to be public? Note that I want the functions to be exported in C style, i.e. the other DLL won't have anything to do with .NET.
Best regards
Dominik
<small>and</small;gt;
<code>__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Works perfectly with C++/CLI. Here's some sample code:
extern "C" int __declspec(dllexport) Load(int *link)
{
Debug::Print("Load(int*) called");
...
}
Grüße nach Deutschland ;
modified 12-Sep-18 21:01pm.
|
|
|
|
|