|
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.
|
|
|
|
|
If the "custom control" is "stealing" focus at certain times, why don't you simply "reset" the focus instead of fighting a control you claim to have no "control" over?
I typically set focus (if I need to) after the ui is "ready for interaction"; which is generally at the end of the "loaded event" (or "activated" in special cases).
If a call to "something" causes focus to be "stolen", then "save" a reference to the control currently having focus, make the call, then re-focus.
Those are the only scenarios.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello Everyone!
I am developing a simple stock management software for my final year college project.
I am trying to fire following queries:
"UPDATE item_stock SET qnt = (qnt + '" & qty & "'), amount = (amount + '" & mrp * qty & "') WHERE batch = '" & batch & "'"
<pre>"UPDATE item_stock SET qnt = (qnt - '" & qty & "'), amount = (amount - '" & mrp * qty & "') WHERE batch = '" & batch & "'"
The Subtraction is working fine but I cannot see affect of the addition. Any help?
|
|
|
|
|
"Final" year? How many years did you have this teacher?
Your numbers aren't; they are text. If you want to calculate, use numbers. Also, don't concatenate strings like that, I would wipe your database on my first test-run of your application.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
hey
i'm working on a notepad project
and i want to open .txt files with my app
it worked
BUT
when i open a file ,modify it and save... save only NOT save as
it opens save as file
i want to modify the opened file
here is the code i'm using
Shared Sub DoubleClickFile(Textbox As TextBox)
If System.Environment.GetCommandLineArgs().Length > 1 Then
Dim i As Integer
For i = 1 To System.Environment.GetCommandLineArgs().Length - 1
Dim zReader As StreamReader
zReader = New StreamReader(System.Environment.GetCommandLineArgs(i), True)
Textbox.Text = zReader.ReadToEnd
Next
Else
End If
End Sub
|
|
|
|
|
Where is the code that saves the modified file?
|
|
|
|
|
Backgroud: I'm trying to automate the printing of PDF files.
I found that by invoking
acrord32.exe /N /T pdfFile printerName on the command line you can print PDFs silently. Great.
I'm trying to automate this in VB via
Dim p As Process = New Process()
Dim pi As ProcessStartInfo = New ProcessStartInfo()
Dim command As String = Chr(34) & "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\acrord32.exe" & Chr(34) & " /N /T "
Try
pi.Arguments = String.Format("{0} {1} {2} {3}{4}{5}", " /C ", command, sFilename, Chr(34), sPrinter, Chr(34))
pi.UseShellExecute = False
pi.RedirectStandardError = True
pi.RedirectStandardOutput = True
pi.CreateNoWindow = True
pi.WindowStyle = ProcessWindowStyle.Normal
pi.FileName = "cmd.exe"
p.StartInfo = pi
p.Start()
Do Until p.HasExited : Loop
outp = p.StandardOutput.ReadToEnd
Debug.Print(outp)
outp = p.StandardError.ReadToEnd
Debug.Print(outp)
Catch ex As Exception
Debug.Print(ex.Message)
End Try
The error message I get from StdErr is Quote: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
I've tried putting quotes around the command string, but it just doesn't work.
Turning to the community for guidance.
|
|
|
|
|
You have to separate the command line options from the command you're trying to execute.
For your "filename", you've got:
"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\acrord32.exe" /N /T
That doesn't work.
Your filename and arguments must be specified separately:
Dim command As String = """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\acrord32.exe"""
Dim arguments As String = String.Format("/n /t ""{0}"" ""{1}"" ""{2}"" ""{3}""", pdfFilePath, printerName, driverName, portName)
Dim process As New Process
Dim pi As New ProcessStartInfo
pi.Filename = command
pi.Arguments = arguments
process.StartInfo = pi
process.Start
Yes, the double quotes are there for a reason. It's shorter to type "" than it is to type Chr$(34) & .
|
|
|
|
|
Your suggestion worked perfectly. I was over-thinking the problem. I was trying to run cmd.exe and pass the acrord32.exe as a parameter.
Your solution of running acrord32.exe directly worked.
Thank you.
|
|
|
|
|
Hello,
I am stumped by this.
csng("1422.843197465627") returns
1422.84314
and NOT 1422.8432 or even 1422.84319
even CType( "1422.843197465627", Single) also return the same value.
Can somebody explain this to me?
|
|
|
|
|
Are you sure? On my computer, it returns 1422.843 , not .84314 .
You're converting to a single-precision floating point number[^]. The documentation is quite clear: Quote: A Single value has up to 7 decimal digits of precision, although a maximum of 9 digits is maintained internally.
If you want more precision, use a double precision floating point number[^] instead, which supports up to 17 digits.
But be aware that neither type can guarantee to precisely represent every decimal number you throw at it. For example, 0.1 doesn't have a precise binary representation.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I've created a custom tooltip control using a UserControl as the base. When dragging the
control from the toolbox to the form it displays the control (of course) but I want it to
be added like a ToolTip when it is dragged to the form; as an object displayed below the form
in the designer. I've been searching for an answer but I'm not even sure what question to
search for. Can someone help?
Thanks
|
|
|
|
|
Inheriting from UserControl was the wrong route to take. In order for it to show up below the form in the designer, you inherit from Component, not UserControl.
ToolTip is not a normal control. It's an extender that modifies other controls. It adds functionality to anything that inherits from System.Windows.Forms.Control.
The standard ToolTip class inherits from Component and implements the IExtenderProvider interface. You can see the source for ToolTip here[^].
|
|
|
|
|
Thanks a lot for the information and link. I will try that road instead.
|
|
|
|
|
My teacher gave us an assignment to link two forms together where one form is an admin form where u can put things and delete things together and another form is an user form where they can only view it. My question is I want to do a video input format and I can only embed my videos on form 1 but it wont show on form 2 can anyone please help.
|
|
|
|
|
Tell your teacher that forms aren't linked, but created and opened.
Lost wrote: My question is I want to do a video input format and I can only embed my videos on form 1 but it wont show on form 2 can anyone please help. Show us your code
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello !
I'm using entity framework 6 and vb.net 2017.
I have a situation where I read some data from database :
Dim lst as ienumerable(of Mytable1)
lst=context.mytable1.where(Function(t2) t2.nr1=1).Tolist After that , I've made some modifications on some items on the collection , and after that i want to remove from the collection the items that have vl1=0. (But of course I want to do that only on local data that is read before from database and nothing will be saved on database )
How can I do that ?
|
|
|
|
|
|
I'm sorry to bug people about this but I'm still having a slight problem with a Database programming question with Visual Basic 6/Net. I took the advice of someone else on this message board (thanks) about instead of using a combo box as a control but use a simple textbox/command button to control a database pointer in a database program that controls what table to use within the database. Here is the following code I'm using now...
Private Sub cmdSelectedLeagueGameBack_Click()
Dim DataPointerIndicator As Integer
Dim DataIndexNumber As Integer
DataPointerIndicator = DataPointerIndicator - 1
If DataPointerIndicator <= 0 Then DataPointerIndicator = 1
Select Case DataPointerIndicator
Case Is = 0: DataIndexNumber = 0
Case Is = 1: DataIndexNumber = 1
Case Is = 2: DataIndexNumber = 2
End Select
Data1.RecordSource = DataIndexNumber
Text1.Text = Data1.RecordSource
End Sub
The problem I'm having is that I can't figure out how to use the "DataIndexNumber" varible to connect to the "Text1.Text = Data1.RecordSource" so that I can display each table within the Connected Database. The table display properly within the Text1 Object, but I have no idea how to make a "Pointer" within the Database and how to control the "Pointer".
Any help would be most appreciated.
|
|
|
|
|
You use the index value to select the appropriate table. But a much easier method would be a ListBox with the table names, so the user could select the name, and you then have the exact value necessary.
|
|
|
|
|
Yes, I was trying to use an varible to "control" a pointer (which I haven't figured out how to create yet) much like the Index value you described but I can't seem to come up with anything with the previous code. I'm kinda stumped.
A listbox sounds like a good idea, but how do I display the individual tables within the Listbox? Do you have an example I could use for this?
|
|
|
|
|
I am not sure exactly what you are trying to do. Are you trying to display the content of the tables, or just their names? If the former then there are plenty of articles that explain how to bind between different view types and a database. If the latter then you just need to get the names from the database and add them one by one to the listview, or use simple databinding.
|
|
|
|
|
What I'm trying to do is build a simple utility that inputs data from a sporting event into individual tables within a database. Each table represents a sporting event with recorded stats. I have linked the database to the utility porperly with the code I listed before, but I can't seem to figure out how to build a pointer to input the data from each game into a particular table. Switching from table to table in the database is inportant in this utility, but I just can't figure out how to control the pointer in the database with a simple command button and a textbox to display the selected table.
any info would be most appreciated.
|
|
|
|