Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
QuestionSubclassing in .NET Pin
Luis Alonso Ramos25-Aug-05 9:43
Luis Alonso Ramos25-Aug-05 9:43 
AnswerRe: Subclassing in .NET Pin
Daniel Turini25-Aug-05 10:31
Daniel Turini25-Aug-05 10:31 
GeneralRe: Subclassing in .NET Pin
Luis Alonso Ramos25-Aug-05 16:59
Luis Alonso Ramos25-Aug-05 16:59 
Answer[Message Deleted] Pin
miah alom25-Aug-05 11:59
miah alom25-Aug-05 11:59 
QuestionSetting the exact position of a tooltip Pin
Luis Alonso Ramos25-Aug-05 9:37
Luis Alonso Ramos25-Aug-05 9:37 
AnswerRe: Setting the exact position of a tooltip Pin
miah alom25-Aug-05 12:00
miah alom25-Aug-05 12:00 
GeneralRe: Setting the exact position of a tooltip Pin
Luis Alonso Ramos25-Aug-05 16:47
Luis Alonso Ramos25-Aug-05 16:47 
GeneralRe: Setting the exact position of a tooltip Pin
miah alom26-Aug-05 11:03
miah alom26-Aug-05 11:03 
I hope the following works for you. As faar as ListBox is concerned you can do the following

[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hWnd);

[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int cx;
public int cy;
}

[DllImport("gdi32.dll")]
public static extern int GetTextExtentPoint32(IntPtr hdc, String str, int len, ref POINT pt);

[DllImport("user32.dll")]
public static extern int ReleaseDC(IntPtr hWnd,IntPtr hdc);

private void listBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
int index = this.listBox1.IndexFromPoint(e.X,e.Y);

if ( index > 0 )
{
IntPtr dc = GetDC(this.listBox1.Handle);

POINT pt;
pt.cx = 0;
pt.cy = 0;
GetTextExtentPoint32(dc, this.listBox1.Items[index].ToString() ,this.listBox1.Items[index].ToString().Length,ref pt);

ReleaseDC(this.listBox1.Handle, dc);
if(this.listBox1.Width < pt.cx)
{
this.SetToolTipText(this.listBox1.Items[index].ToString());
}
}
}

and as far as ToolTip is concerned

///
/// Set the position of the control with respect to the anchor control
///

/// <param name="anchorControl" />
private void SetPosition(Control anchorControl)
{
//
//Resolve the Balloon Coordinates
//to the client area
//
UnsafeNativeMethods.GetClientRect(anchorControl.Handle, ref this.toolInfo.rect);
UnsafeNativeMethods.ClientToScreen(anchorControl.Handle, ref this.toolInfo.rect);

//
//set the position of the toolTip to be
//displayed
//
int pt = MAKELONG(toolInfo.rect.left, toolInfo.rect.top + toolInfo.rect.bottom);
IntPtr ptr = new IntPtr(pt);

UnsafeNativeMethods.SendMessage(
this.Handle, TTM_TRACKPOSITION,
0, ptr);
}

[DllImport("User32", SetLastError = true)]
public static extern int GetClientRect(IntPtr hWnd, ref Rect lpRect);
[DllImport("User32", SetLastError = true)]
public static extern int ClientToScreen(IntPtr hWnd, ref Rect lpRect);
private const int WM_USER = 0x0400;
private const int TTM_TRACKACTIVATE = WM_USER + 17;

private int MAKELONG(int loWord, int hiWord)
{
return (hiWord << 16) | (loWord & 0xffff);
}
GeneralRe: Setting the exact position of a tooltip Pin
Luis Alonso Ramos26-Aug-05 16:31
Luis Alonso Ramos26-Aug-05 16:31 
GeneralRe: Setting the exact position of a tooltip Pin
Alomgir Miah26-Aug-05 17:31
Alomgir Miah26-Aug-05 17:31 
GeneralRe: Setting the exact position of a tooltip Pin
Luis Alonso Ramos26-Aug-05 22:08
Luis Alonso Ramos26-Aug-05 22:08 
QuestionPlease could you... Pin
KORCARI25-Aug-05 9:26
KORCARI25-Aug-05 9:26 
AnswerRe: Please could you... Pin
miah alom25-Aug-05 12:03
miah alom25-Aug-05 12:03 
GeneralRe: Please could you... Pin
radic.feng26-Aug-05 1:44
radic.feng26-Aug-05 1:44 
QuestionRegex vs. String - *Speed* Pin
User 665825-Aug-05 8:30
User 665825-Aug-05 8:30 
AnswerRe: Regex vs. String - *Speed* Pin
Daniel Turini25-Aug-05 9:04
Daniel Turini25-Aug-05 9:04 
GeneralRe: Regex vs. String - *Speed* Pin
User 665825-Aug-05 9:50
User 665825-Aug-05 9:50 
GeneralRe: Regex vs. String - *Speed* Pin
Daniel Turini25-Aug-05 10:37
Daniel Turini25-Aug-05 10:37 
GeneralRe: Regex vs. String - *Speed* Pin
User 665825-Aug-05 12:03
User 665825-Aug-05 12:03 
AnswerRe: Regex vs. String - *Speed* Pin
eggie526-Aug-05 7:19
eggie526-Aug-05 7:19 
GeneralRe: Regex vs. String - *Speed* Pin
User 665827-Aug-05 0:33
User 665827-Aug-05 0:33 
QuestionWindows Service Pin
Taurian11025-Aug-05 8:26
Taurian11025-Aug-05 8:26 
QuestionHow to Secure the Configuration Settings Pin
oneworld200225-Aug-05 7:25
oneworld200225-Aug-05 7:25 
Questionforms Pin
xilefxilef25-Aug-05 6:30
xilefxilef25-Aug-05 6:30 
AnswerRe: forms Pin
Judah Gabriel Himango25-Aug-05 7:00
sponsorJudah Gabriel Himango25-Aug-05 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.