|
hi all, in vs.net, how do you make a scroll bar automatically drop to the bottom of a multiline textbox?
its for my chat program, and scrolling down every message is getting annoying >=(
|
|
|
|
|
Refer the below code
const int SB_VERT = 1;
const int EM_SETSCROLLPOS = 0x0400 + 222;
[DllImport("user32", CharSet=CharSet.Auto)]
public static extern bool GetScrollRange(IntPtr hWnd, int nBar, out int lpMinPos, out int lpMaxPos);
[DllImport("user32", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, POINT lParam);
[StructLayout(LayoutKind.Sequential)]
public class POINT
{
public int x;
public int y;
public POINT()
{
}
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
}
int min, max;
GetScrollRange(richTextBox1.Handle, SB_VERT, out min, out max);
SendMessage(richTextBox1.Handle, EM_SETSCROLLPOS, 0, new POINT(0, max - richTextBox1.Height));
|
|
|
|
|
I have a class inherit from usercontrol, If a user at ime mode, the KeyDown Event can only receive the first key code, others are gone? How to get full strings? thanks!
|
|
|
|
|
1.I did not get what really the problem is? can you post the keypress event code.
2.Just to remind you,when ever Key is Pressed, the event gets fired and it gives one keycode at a time. that is what it is doing in your case?????
|
|
|
|
|
How to convert this into c#?
If File.Exists(filepath)Then
Dim filename As String = Path.GetFileName(filepath)
Thank You
|
|
|
|
|
string filename;
if(File.Exists(filepath)
{
filename = Path.GetFileName(filepath);
}
|
|
|
|
|
hi,
try
{
string fName="";
if(File.Exists(@"C:\sree.rtf"))
{
fName=Path.GetFileName(@"C:\sree.rtf");
MessageBox.Show(fName);
}
else
{
MessageBox.Show("File Does Not Exists");
}
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thanx for ur contribution!;)
|
|
|
|
|
Hello,
What I want to do I allow the user to move/resize some of the controls on the form.
For example, if there is a textbox, the user would be allow to move it and resize it. Do I just monitor the mouse move event and check if it is within a certain distance of the textbox, and if it is, change the cursor to a gripper, and then, if the mouse is clicked, just change the width/height of the textbox accordingly?
Any ideas/suggestions are welcome
Thanx,
-Flack
|
|
|
|
|
I had the practice code for moving the controls. I am pasting the same for your reference. I do not know whether it would help you or not?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
public class Form2 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public Form2()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows フォーム デザイナで生成されたコード
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.BackColor = System.Drawing.SystemColors.Window;
this.button1.Cursor = System.Windows.Forms.Cursors.IBeam;
this.button1.ForeColor = System.Drawing.SystemColors.WindowText;
this.button1.Location = new System.Drawing.Point(136, 96);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 88);
this.button1.TabIndex = 7;
this.button1.Text = "button1";
this.button1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.button1_MouseUp);
this.button1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.button1_MouseMove);
this.button1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.button1_MouseDown);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 382);
this.Controls.Add(this.button1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main() { Application.Run(new Form2()); }
private System.Windows.Forms.Button button1;
int MoveFlag = 0;
private void button1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
MoveFlag = 1;
}
private void button1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
MoveFlag = 0;
}
private void button1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (MoveFlag == 1)
{
button1.Location = (new Point(button1.Location.X+e.X,
button1.Location.Y+e.Y));
button1.Refresh();
}
}
}
}
|
|
|
|
|
Hi guys,
I need to build a small application that will browse a website automatically. It needs to authenticate itself by using a form post, then a session id is given by the server, and I need to keep that session open for everything I'll do thereafter (or I'll be brought back to the login page).
I'm not quite sure where to start to achieve such a thing. Can anyone help?
Thanks!
Carl
|
|
|
|
|
You'll need to add a CookieContainer to your web request.
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(yoursite);
wr.CookieContainer = new CookieContainer();
Your client will then make subsequent request on the same session.
I suggest having a single static CookieContainer somewhere in your application and re-use that.
|
|
|
|
|
Armand,
I will try that, thank you!
Carl
|
|
|
|
|
Hi all. I know this is not C# specific but it is the language I am using for this project.
In my application I am setting permissions to several folders. Problem is, my app needs to run in 12 different languages. These permissions needs to be given to standard windows groups like 'Administrators' and 'Users' which change in every given language. Only solution I have found so far is to use a utility like this to give the permission based on the SID, which is constant for the standard groups given any OS language.
So is here any way in the framework or as an alternative an API I can call to get the localized name of the standard user groups?
Thanks!
Juan Miguel Venturello
|
|
|
|
|
Hi,
I am trying to convert the long integer (ex: 8837225770433) into character array.
But I am getting the following error.
"Value was either too large or too small for a character."
I am trying to convert the C++ logic to C#.
<br />
unsigned long* pTemp= reinterpret_cast<unsigned long*>(szBuf+(n-1)*4);<br />
*(pTemp) = hashRand.GenRandom() ^ lBuf[n];<br />
TIA
Dy
|
|
|
|
|
In C# you can do:
long value = ...;
char[] chars = value.ToString().ToCharArray();
that is if you want char array for 123 to hold '1', '2', '3'
|
|
|
|
|
well, he means byte (8), not char (16)
|
|
|
|
|
He said character array, not byte array.
|
|
|
|
|
Does C# have the C++ equivalent of a friend class?
I have a class where I want to prevent all by one class (in the assembly) from calling certain methods. In C++ I'd declare them protected and then make that one class a friend. Am I out of luck with C# as I suspect?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Sadly no, and I was only lamenting the fact last night. Remember, C# is also supposed to attract VB programmers, so a lot of things that can be useful for a good programmer are missing because they are a danger to idiots.
In my case, I wrap an event in a class, and I wanted to only allow the class that sends events to be able to construct them, so that they were then unable to be modifed by clients. I can make it so a client must create a new event, they cannot modify the one they have, but I cannot hide the constructor.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I came across of this few times too.
Best thing I could come up with was to inherit:
class A
{
protected int x;
}
class ToolsForA : A
{
public int DoSomethingWithX(A a)
{
... can access a's protected members here...
}
}
|
|
|
|
|
The only way of doing something similar to C++ friend classes is by isolating your classes in an assembly (e.g., a DLL), and use them as 'internal', which makes a member public only to an assembly.
Yes, even I am blogging now!
|
|
|
|
|
I think it's internal .
/\ |_ E X E GG
|
|
|
|
|
Does anyone know how to display printer properties dialog?
It's the one that show when you click "Properties" from PrintDialog next to
dropdown with printer names.
I have printer name and need to display it's properties dialog without
showing PrintDialog or PageSetupDialog
|
|
|
|
|
i have a lines of code just like the following and i whould like to jump after checking a specified condition and incressing the i ... somthing like that ...
<br />
for(int i=0;i<=10;i++)<br />
{<br />
if(ok)<br />
<br />
<br />
}<br />
how can i do something like that...
ADEL K Khalil
|
|
|
|