Click here to Skip to main content
15,885,032 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to solve system.NullReferenceException Pin
Member 83455994-Apr-18 4:46
Member 83455994-Apr-18 4:46 
QuestionUse Tabcontrol to switch beween control in Excel VBA form Pin
hmanhha30-Mar-18 17:28
hmanhha30-Mar-18 17:28 
AnswerRe: Use Tabcontrol to switch beween control in Excel VBA form Pin
Maciej Los3-Apr-18 3:29
mveMaciej Los3-Apr-18 3:29 
QuestionChange the Project folder's name Pin
desanti30-Mar-18 12:22
desanti30-Mar-18 12:22 
AnswerRe: Change the Project folder's name Pin
A_Griffin30-Mar-18 21:44
A_Griffin30-Mar-18 21:44 
GeneralRe: Change the Project folder's name Pin
desanti31-Mar-18 5:44
desanti31-Mar-18 5:44 
AnswerRe: Change the Project folder's name Pin
Gerry Schmitz31-Mar-18 7:01
mveGerry Schmitz31-Mar-18 7:01 
QuestionProblem with custom control stealing focus: Resolved 'sort of' Pin
mo149230-Mar-18 8:02
mo149230-Mar-18 8:02 
Well after several hours I seem to have resolve this problem although I am still
not confident in my understanding of the issue. Without getting into all of the hairy
details the basic problem is related to initializing the control with Visible = False
and the fact that the control does not have or get a Parent during initialization. I
do not know why this is an issue because I cannot see the underlying vb code. By waiting
and setting Visible = False during Load() seems to have fixed the problem.


I am working on a custom tooltip control and have a particular problem with my control stealing
focus from the form.

Below are my creation parameters that are what I've used in VS C++ to do the same thing.
These are meant to create a WS_EX_TOOLWINDOW which displays above controls and the Form.
Below that is the stack trace that shows the issue where WmSetFocus() is being called
through my call to CreateGraphics(). I don't know what I can do to prevent this call
unless there is a style I can return in CreateParams() to prevent the call.

Can someone help?
Note I have removed some of the stack trace detail to try to reduce size of this message.
I have left what I think is relevant. If you think you need the rest let me know and I will
post it all.

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Const WS_EX_TOPMOST As Integer = &H8
Const WS_EX_NOACTIVATE As Integer = &H8000000
Const WS_EX_TOOLWINDOW As Integer = &H80
Const WS_EX_CONTROLPARENT As Integer = &H10000

Const WS_POPUP As Integer = &H80000000
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const WS_DISABLED As Integer = &H8000000L

Dim cp As CreateParams = MyBase.CreateParams
Debug.WriteLine(String.Format("CreateParams1():EX({0:X}),WS({1:X})", cp.ExStyle, cp.Style))

' Set topmost and prevents activation.
cp.ExStyle = cp.ExStyle Or (WS_EX_NOACTIVATE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST)
cp.ExStyle = cp.ExStyle And Not WS_EX_CONTROLPARENT

' WS_POPUP makes control display above other controls including form.
' MSDN says you cannot combine WS_CHILD and WS_POPUP
cp.Style = cp.Style Or (WS_POPUP Or WS_DISABLED)
cp.Style = cp.Style And Not (WS_CHILD Or WS_VISIBLE)
Debug.WriteLine(String.Format("CreateParams2():EX({0:X}),WS({1:X})", cp.ExStyle, cp.Style))

Return cp
End Get
End Property

Stack
MyControls.dll!MyControls.TooltipControl.got(Object sender = {MyControls.TooltipControl}, System.EventArgs action = {System.EventArgs}) Line 968 Basic
System.Windows.Forms.dll!System.Windows.Forms.Control.OnGotFocus(System.EventArgs e) + 0xb8 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmSetFocus(ref System.Windows.Forms.Message m) + 0x143 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x5cd bytes
System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WmSetFocus(ref System.Windows.Forms.Message m) + 0x19c bytes

????????? Problem SetFocus()
System.Windows.Forms.dll!System.Windows.Forms.UserControl.WmSetFocus(ref System.Windows.Forms.Message m) + 0xdf bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.UpdateChildZOrder(System.Windows.Forms.Control ctl) + 0x2cf bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmCreate(ref System.Windows.Forms.Message m) + 0x7d bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x4a6 bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 0x00000001, System.IntPtr wparam, System.IntPtr lparam) + 0xad bytes
[Native to Managed Transition]
[Managed to Native Transition]

???????????? CreateParams
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp) + 0x3e7 bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle() + 0x24a bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.Handle.get() + 0x65 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.CreateGraphicsInternal() + 0xa bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.CreateGraphics() + 0x99 bytes
MyControls.dll!MyControls.TooltipControl.MeasureControlInfoText(Boolean bAll = False) Line 1252 + 0xd bytes Basic

-- modified 30-Mar-18 20:15pm.
AnswerRe: Problem with custom control stealing focus: Resolved 'sort of' Pin
Gerry Schmitz31-Mar-18 7:10
mveGerry Schmitz31-Mar-18 7:10 
QuestionAddition and Subtraction Operation in SQL update query Pin
Member 1375497530-Mar-18 4:50
Member 1375497530-Mar-18 4:50 
QuestionRe: Addition and Subtraction Operation in SQL update query Pin
Eddy Vluggen30-Mar-18 5:23
professionalEddy Vluggen30-Mar-18 5:23 
AnswerRe: Addition and Subtraction Operation in SQL update query Pin
Richard Deeming3-Apr-18 8:30
mveRichard Deeming3-Apr-18 8:30 
Questionproblem with opening a text file in my app with double click Pin
Sh3R3iF29-Mar-18 9:22
Sh3R3iF29-Mar-18 9:22 
QuestionRe: problem with opening a text file in my app with double click Pin
Richard MacCutchan29-Mar-18 22:19
mveRichard MacCutchan29-Mar-18 22:19 
QuestionProblem running a command when the path has spaces in its name. Pin
David Mujica27-Mar-18 9:37
David Mujica27-Mar-18 9:37 
AnswerRe: Problem running a command when the path has spaces in its name. Pin
Dave Kreskowiak27-Mar-18 10:30
mveDave Kreskowiak27-Mar-18 10:30 
GeneralRe: Problem running a command when the path has spaces in its name. Pin
David Mujica28-Mar-18 9:35
David Mujica28-Mar-18 9:35 
QuestionConversion Blues Pin
Member 1274920627-Mar-18 5:00
Member 1274920627-Mar-18 5:00 
AnswerRe: Conversion Blues Pin
Richard Deeming27-Mar-18 5:20
mveRichard Deeming27-Mar-18 5:20 
AnswerRe: Conversion Blues Pin
Richard MacCutchan27-Mar-18 5:21
mveRichard MacCutchan27-Mar-18 5:21 
QuestionHow to add custom control to designer like tooltip Pin
mo149227-Mar-18 2:30
mo149227-Mar-18 2:30 
AnswerRe: How to add custom control to designer like tooltip Pin
Dave Kreskowiak27-Mar-18 5:08
mveDave Kreskowiak27-Mar-18 5:08 
GeneralRe: How to add custom control to designer like tooltip Pin
mo149227-Mar-18 5:15
mo149227-Mar-18 5:15 
QuestionHow do I link two forms together in VB 2010? Pin
Lost25-Mar-18 3:36
Lost25-Mar-18 3:36 
AnswerRe: How do I link two forms together in VB 2010? Pin
Eddy Vluggen25-Mar-18 19:18
professionalEddy Vluggen25-Mar-18 19:18 

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.