|
How can I obtain the sender object from a control handle in VB.net?
I have a function GetProperties(sender)
sender is an Object Type like the one in Form1_Click sited below:
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Form2.GetProperties(sender)
Form2.Show()
End Sub
Private Declare Function apiGetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Int32
I currently can get a handle of a window or of a control that I clicked on as follows:
hwnd = apiGetForegroundWindow ()
How can I obtain the sender object from hwnd so that I can passed into GetProperties as follows: GetProperties(sender)?
Thanks,
|
|
|
|
|
handler huh? how about this[^]
|
|
|
|
|
Thank you so much replying and help. However, this is not exactly what I am looking for. I was trying to find a way to obtain the system of the item that I got the handle for.
For example, public sub button1_click (sender as Object, e As Args)
end sub
For example, public sub button2_click (sender as Object, e As Args)
end sub
For example, if the user click on button or any control, after I obtain the handle of the control being clicked I want to be able to trace back or obtain the sender of the handle.
hwnd = getHandle(button1)
I am trying to find a way to obtain the sender of hwnd so that I can pass the sender into a function whose parameter requires sender object, for example,
SenderObject = getSender(hwnd) 'How do I get the Senderobject from a control or a window hwnd so
that I can pass it into a function or sub that means to accept sender object as follows?
Call Button2_Click(SenderObject, e)
Thanks,
|
|
|
|
|
Only controls have handles. Cast your sender-object to a control, and you can access the property.
What is it that you're trying to achieve?
Bastard Programmer from Hell
|
|
|
|
|
Thank you very much for your info and help.
I have am trying to obtain all the properties of any window, control, or object that the user will click on.
I am currently, have function that accepts a sender and displays all the sender's properties.
For example, if the user clicked on button1,
in
Sub Button1_click(sender As Object, e As args)
GetProperties(sender) ' Right now I can do
' this fine.
End Sub
I can also do GetProperties(Me.ActiveControl) fine too.
However, when the user clicks on a window or a button of another application, I can obtain the handle of this window or this button as buttonhandle or windowhandle; however, I cannot pass windowhandle or buttonhandle directly into GetProperties as
GetProperties(windowhandle or buttonhandle) this does not work because GetProperties requires sender argument to be passed into it as follow GetProperties(getSender(windowhandle) or getSender(buttonhandle))
How do I get SenderObject = getSender (windowhandle) from windowhandle or
SenderObject = getSender (windowhandle) from windowhandle
so that I can pass it into GetProperties(SenderObject)?
Thanks,
|
|
|
|
|
Member 3746076 wrote: How do I get SenderObject = getSender (windowhandle) from windowhandle so that I can pass it into GetProperties(SenderObject)?
You can't. The other app might be using a custom treeview that your app doesn't know anything about.
No, won't work if you're looking at another process. What you're trying to achieve can be found here[^], with sourcecode.
Bastard Programmer from Hell
|
|
|
|
|
Thank you so much replying and help. However, this is not exactly what I am looking for. I was trying to find a way to obtain the sender object of the item that I got the handle for.
I am trying to obtain all the properties of any obeject that the user clicks on.
Currently, I can alread obtain the handle of the oject or of the control being clicked on, but I do not how to trace the handle back to its sender type or object.
For example, public sub button1_click (sender as Object, e As Args)
end sub
For example, public sub button2_click (sender as Object, e As Args)
end sub
For example, if the user click on button or any control, after I obtain the handle of the control being clicked I want to be able to trace back or obtain the sender of the handle.
hwnd = getHandle(button1)
I am trying to find a way to obtain the sender of hwnd so that I can pass the sender into a function whose parameter requires sender object, for example,
SenderObject = getSender(hwnd) 'How do I get the Senderobject from a control or a window hwnd so
that I can pass it into a function or sub that means to accept sender object as follows?
Call Button2_Click(SenderObject, e)
Thanks,
|
|
|
|
|
how can i code a datagridview with 3 columns:
textbox-textbox-combobox
textbox1 has an autocomplete collection;
when i select or type a string of it a matching number appear in textbox2;
and editing textbox2 affects the combobox's selected index ??
also how to make pressing enter moves to the first cell in the new row ??
|
|
|
|
|
The best solution for this would be to research using Google. However two URL's you may wish to review are....
http://www.dotnetperls.com/datagridview-vbnet
http://vb.net-informations.com/datagridview/vb.net_datagridview_tutorial.htm
|
|
|
|
|
Thanks,
I found a really helpful tutorial here :
http://www.codeproject.com/Articles/26289/Editable-and-Multi-Functional-Datagridview
|
|
|
|
|
I have a combobox attached to a database with names in it. How do I get the combolist to show only the name of the text typed as it is type. IE: If I type "A" I want the list to display only the names that start with the letter "A". I was able to do this in the VB6 but lost the function when I upgraded to Visual
Studio 2010.
Please help!!!!
cjscs
|
|
|
|
|
Not to hard to add the functionality.
Have a start here[^].
|
|
|
|
|
The AutoComplete functionality Jorgen links you to is nice. But you might be asking for a simple way to filter your list items (which could be used in conjunction with AutoComplete). Have a look at the BindingSource class and its Filter property. Something like this:
Dim bs As New BindingSource
bs.DataSource = dtTable
Me.ComboBox1.DataSource = bs
Me.ComboBox1.DisplayMember = "DISPLAY_COLUMN"
Private Sub ComboBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
bs.Filter = "DISPLAY_COLUMN LIKE '" & e.KeyChar & "%'"
End Sub
|
|
|
|
|
description:
Custom screensaver in vb.net 2008 of a slideshow using local resource images embedded. I got the exe working fine.
general steps done so far:
1) form properties to no border and full screen
2) import images to local resources so they are embedded in the application
3) create a timer to change the form.background to the next image
4) generate a random number reflecting the number of images and confirm no repeats
5) close application trigger (spacebar)
6) test on my systems and work fine as exe
Problem:
#1
Within install shield reg settings pushed
-1 HKCU/controlpanel/dekstop/ScreenSaveActive = 1
-2 ScreenSaveTimeOut = 900 (15 minutes)
-3 SCRNSAVE.EXE = C:\Windows\MICHAE~1.SCR
1 and 3 work
2 doesn't set the screensaver timer to 15 minutes, it stays at the same timer previously entered
#2
right clicking on the desktop of Win 7 and selecting Personalize. The screensaver is there, but clicking on Screen Saver to open up the screensaver properties, the screensaver initiates. Stopping the screensaver brings the screensaver properties up fine. Using another way like Control Panel > Appearance and Personalization > Change screen saver works as expected. Using the start>run "screensaver" to open screensaver properties starts the screensaver and after closing the screensaver, the screensaver properties is available.
#3
in the screensaver properties, selecting either settings or preview start the screensaver twice. In other words, the screensaver will start, then after you close it, it starts again a second time.
#4
although the screensaver shows it is in the screensaver properties window. even after waiting the designated time to pass, the screensaver doesn't initiate.
Can someone lend a hand on how to resolve these issues?
www.MichaelHulak.com
modified 7-May-12 1:36am.
|
|
|
|
|
Have you followed the steps outlined here[^]?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
i tried, but not successful. Maybe if i show the code i currently have to assist
Imports System.Timers
Imports System.Drawing
Public Class Form1
Dim A As Int16 = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PrevInstance()
' If PrevInstance() = True Then
' MessageBox.Show("sdfsdf")
' Close()
' End
' Else
' MessageBox.Show("222222")
' End If
running()
Dim startPoint1 As New Point(Me.Width / 2 - 165, 19)
lbl_top.Location = startPoint1
Dim startPoint2 As New Point(Me.Width / 2 - 62, 93)
lbl_bottom.Location = startPoint2
A = RandomNumber(0)
Images()
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Function PrevInstance() As Boolean
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
MessageBox.Show("222222")
Me.Close()
Return True
Else
Return False
End If
End Function
Private Sub Form_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
Static count As Integer
If count > 2 Then
Me.Close()
End
Else
count = count + 1
End If
End Sub
Public Sub running()
'The end result of this code is similar to Visual Basic 6.0's App.Previnstance feature.
Dim appName As String = Process.GetCurrentProcess.ProcessName
Dim sameProcessTotal As Integer = Process.GetProcessesByName(appName).Length
If sameProcessTotal > 1 Then
MessageBox.Show("A previous instance of this application is already open!", " App.PreInstance Detected!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
End If
appName = Nothing
sameProcessTotal = Nothing
End Sub
Private Sub CreatePointsAndSizes(ByVal e As PaintEventArgs)
' Create the starting point.
Dim startPoint As New Point(Me.Width / 2 - 331)
' Use the addition operator to get the end point.
Dim endPoint As Point = Point.op_Addition(startPoint, _
New Size(140, 150))
' Draw a line between the points.
e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint)
' Convert the starting point to a size and compare it to the
' subtractButton size.
Dim buttonSize As Size = Point.op_Explicit(startPoint)
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, _
ByVal keyData As Keys) As Boolean
' spacebar to escape screensaver
Const WM_KEYDOWN As Integer = &H100
Const WM_SYSKEYDOWN As Integer = &H104
If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
Select Case (keyData)
Case Keys.Space
Close()
End Select
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Images()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer2.Tick
lbl_bottom.Visible = False
lbl_top.Visible = False
Timer2.Enabled = False
End Sub
Public Sub Images()
If A = 1 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_06_07_IMG_2969_WM
A = RandomNumber(1)
Exit Sub
End If
If A = 2 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_06_28_IMG_4278_WM
A = RandomNumber(2)
Exit Sub
End If
If A = 3 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_08_03_IMG_9462_WM
A = RandomNumber(3)
Exit Sub
End If
If A = 4 Then
Me.BackgroundImage = Screensaver_01.My.Resources.Resources._2011_08_21_Confidence_WM
A = RandomNumber(4)
Exit Sub
End If
End Sub
Public Function RandomNumber(ByVal previous_number As Integer, _
Optional ByVal MinNumber As Integer = 1) As Integer
Dim randomObject As Random = New Random()
Dim rndNum As Integer = previous_number
Dim output As String = ""
While previous_number = rndNum
rndNum = randomObject.Next(1, 4)
End While
Return rndNum
End Function
End Class
|
|
|
|
|
how to play videos from my database on my vb.net form.? plz if any one know rly me nw....
|
|
|
|
|
By loading the data, prolly a bitarray, and playing it back.
If you want more specific help, you'll have to give us some more specifics on your app, what you're doing, and where you're stuck. No, there's little chance that someone is going to walk you through the entire process.
- What type of database? Sql Server I presume?
- What exactly do you need help with? Loading the bits, playing the bits, or just programming in general?
- What have you tried? Did you try the articles here on CodeProject?
Bastard Programmer from Hell
|
|
|
|
|
|
I don't think the admins and moderators would like that too much, that is spam.
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
Hello !
in vb.net 2010 , i have a tabcontrol with 3 tabs , on each of them i have some bound textboxes. The textboxes are bound when the form is open.
The problem is that if i try to use a value of these textbox , but i haven't click on tabs , the value is empty.if i click on the tabs on time , everything is ok.
what can i do?
thank you.
|
|
|
|
|
Move the code that fills the textboxes to the constructor of the form. There's probably an OnShow, OnActivate or an OnClick that does the databinding. Can you paste the code here?
Bastard Programmer from Hell
|
|
|
|
|
Hello people,
I'm making a software which will only allow a set of pre-defined programs I list, when it detects a "no no" process it terminates it. I made a text file that the program loads and tells it which processes which not to terminate and/or suspend, currently the list I have for that is (see below)
System
Interrupts
smss
Whenever a user wants to save his or her new settings, a form pops-up with UAC (user-account control) -like behavior, it suspends all processes except critical ones (the list above), it does this just in case the computer has been hacked or been unauthorized remote control (yeah I'm pretty serious about it) but whenever I tend to do this, it crashes the system. What would I like to know is which processes that should not be terminated or suspended or NOT BE TOUCHED all together, in order for the computer to not crash, so that the user doesn't have to force restart the computer, by unplugging the cord or holding the power-button for a few seconds.
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
Cute. You're going to have to investigate that yourself. The problem you have is that not every Windows installation is the same. Certain installation options will vary your list depending on whats installed.
Frankly, I think this is a waste of time as suspending process, even non-system ones, can cause problems. There's just no way you're going to be able to tell which process can and cannot be suspended.
|
|
|
|
|
(1.) Would you suggest just disconnecting the internet using the shell command:
Shell ("ipconfig /release", vbHide)
(2.) or disabling all network and I.p. devices.
(3.) Check the process really deep to make sure it's not connected to anything important, then if it's not do whatever I please to it. But if it is, freeze the non-important parts of the program.
Then re-enable anything that has been mess with (see above).
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|