|
I am assuming this is relatively simple, but I have not been able to figure this out as of yet.
I have an external WPF application that I cannot modify, but I would like to retrieve the data from a control in the application.
I have the code to retrieve the application top window from the windows API and the code needed to traverse the visual tree to find child items.
The problem lies in getting the window (which is contained in the HwndWrapper) into an object in my program that I can use to send to my code to find the controls I need.
I have tried searching and have come up with the following:
Using HwndSource.FromHwnd() - Returns Nothing
Casting a custom window class to Window - Will not convert
Inheriting from Window in custom window class - none of the attributes I need get populated this way.
I know that this can be done, as the opensource project, snoop, is able to get the data. Unfortunately it is written in C# with a C++ ManagedInjector and I am not as proficient in these languages as I am in VB, so while I can read and understand some of it, the rest is lost on me.
I truly hope that someone will be able to help me with this project, as I am ready to tear my hair out.
Thanks in advance.
|
|
|
|
|
Hi Mr, I know few things about WPF, I can be wrong, but I vaguely remember that a WPF window do not 'use' child windows, I mean child windows do not 'exist' as in C++, Windws Forms ,etc., but really they are all together painted only on one main window. Hope this helps, Carlos.
|
|
|
|
|
Thank you. I did read that the controls in a WPF application do not have handles and therefore must be traversed through with a TreeHelper/Walker, but I cannot figure out how to get the initial element to start the process. I have the names of the controls I need to find by using Inspect and Snoop, but finding the controls by name seems to require an initial element.
|
|
|
|
|
Hi, perhaps the initial element is the biggest container, like, Canvas, InkCanvas, or it can be the main window
|
|
|
|
|
Yes, the initial element would be the main window, but obtaining that element as an object that can be used is the issue that I'm having
|
|
|
|
|
Hi, try google with wpf spy utility, you'll find snoopwpf on codeplex, also http://msdn.microsoft.com/en-us/library/ms742404.aspx[^], hope this helps. Well, this does not answer you question, but I suppose it could help you, yet also I have not used any of these tools Smile |
|
|
|
|
|
I do have the snoop sourcecode and have looked through it, but unfortunately it is a bit too complex for me to understand in its entirety.
|
|
|
|
|
Perhaps there exist another WPF code to accomplish this idea, (please excuse my English grammar, it is not my native language). Also there is no more the usual OnPaint event, it has been replaced also by OnRender or something more else, unhappiliy I don't remember now. Hope this helps, Carlos
|
|
|
|
|
hi All
Using VB6 as front end and MS access as database i am trying to do a wild search on customer address field so my problem is i need to insert the record which has record count <=1500
Below is my code which i used only to Select and insert
"gql = "Insert Into out_1 SELECT DISTINCT MSISDN,CUST_NAME,STATUS,CUST_ZIP,CUST_ADDRESS,total_outstanding,ACCOUNT_NO FROM base where CUST_ADDRESS like " & "'%" & Text3.Text & "%' group by MSISDN,CUST_NAME,STATUS,CUST_ADDRESS,CUST_ZIP,total_outstanding,ACCOUNT_NO
Can some one help me on code that insert only if record count is <=1500
|
|
|
|
|
1. VB6 is no longer supported; plan to move to a currently supported language.
2. Break the problem into pieces and work them seperately.
For example: find data sets that have more than 1500 records and less than 1500 records, then, using JUST the select statement, run the query to see what is returned.
Also, look into the 'HAVING' clause. You should be able to search for it and find help there.
|
|
|
|
|
|
|
Good advice, Richard
|
|
|
|
|
Richard, isn't a Skype Bruter malicious code?
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
|
I have a simple WinForms application with data displayed in a property grid.
Now i am trying to make the application a little more user friendly for a touch screen operation.
I have added simple user control with buttons to simulate a virtual numeric keyboard. The problem is that as soon as i press the buttons on the usercontrol the PropertyValueChanged fires even though the PropertyGrid.ContainsFocus still is true.
This is causing a problem because the input is not yet ready and may still be under/over limit causing the property grid to revert back to its old value.
First i thought it was a problem with the user control stealing focus so i added the following code that i found i a forum to the buttons but the event still fires.
Friend Class UnselectableButton
Inherits Button
' The WS_EX_NOACTIVATE value for dwExStyle prevents foreground
' activation by the system.
Private Const WS_EX_NOACTIVATE As Long = &H8000000L
''' <summary>
''' Set the form style to WS_EX_NOACTIVATE so that it will not get focus.
''' </summary>
Protected Overrides ReadOnly Property CreateParams() As CreateParams
<PermissionSet(SecurityAction.LinkDemand, Name:="FullTrust")>
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or CInt(Fix(WS_EX_NOACTIVATE))
Return cp
End Get
End Property
Public Sub New()
MyBase.New()
Me.SetStyle(ControlStyles.Selectable, False)
End Sub
Private Sub InitializeComponent()
Me.SuspendLayout()
'
'UnselectableButton
'
Me.TabStop = False
Me.ResumeLayout(False)
End Sub
End Class
Does anyone know how to suppress PropertyValueChanged or any other way around the problem.
|
|
|
|
|
|
gostaria de ciar o id auto_increment e da erro .
me ajude por favor
Sub criatabelaconfiguracoes()
Try
Dim conn As MySqlConnection
Dim strConn As String
Dim cmd As MySqlCommand
strConn = "Server ='" & txtServer.Text & "'; userid = '" & txtUser.Text & "'; password = '" & txtSenha.Text & "';"
'strConn &= "Database = mysql; pooling=false;"
conn = New MySqlConnection(strConn)
cmd = New MySqlCommand("Create Database If Not exists habitacao", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.ChangeDatabase("habitacao")
Dim sbCmd As New System.Text.StringBuilder
sbCmd.Append("CREATE TABLE configuracoes")
sbCmd.Append("(id INT(10)," & _
"tempolog varchar(255)," & _
"nomesistema varchar(255)," & _
"impressora varchar(255))")
cmd = New MySqlCommand(sbCmd.ToString, conn)
cmd.ExecuteNonQuery()
conn.Close()
criatabelausuario()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
|
|
|
|
|
You have been a member long enough to know that this is an English language site.
Use the best guess
|
|
|
|
|
That's not a problem related to Visual Basic, but to MySQL!
Hint: id INT(10) creates a "normal" numeric column, without autoincrement. I do not know the MySQL specific syntax for that, the documentation will tell you.
|
|
|
|
|
how to make calculator? in vb.net
|
|
|
|
|
Probably by creating a Windows Forms application. Google can probably find you many samples that will help.
Use the best guess
|
|
|
|
|
<pre lang="vb"><pre lang="vb"><pre lang="vb"> Hi you can check the below code to create a simple calculator with 4 functionalities.
Public Class frmcalculator
Dim Operand1 As Double
Dim Operand2 As Double
Dim [Operator] As String
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click, btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click, Button2.Click
txtsource.Text = txtsource.Text & sender.text
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
txtsource.Text = ""
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = ""
txtsource.Focus()
[Operator] = "+"
End Sub
Private Sub btndecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If InStr(txtsource.Text, ".") > 0 Then
Exit Sub
Else
txtsource.Text = txtsource.Text & "."
End If
End Sub
Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim Result As Double
Operand2 = Val(txtsource.Text)
Select Case [Operator]
Case "+"
Result = Operand1 + Operand2
MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
txtsource.Text = Result.ToString("#,###.00")
Case "-"
Result = Operand1 - Operand2
MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
txtsource.Text = Result.ToString("#,###.00")
Case "/"
Result = Operand1 / Operand2
MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
txtsource.Text = Result.ToString("#,###.00")
Case "*"
Result = Operand1 * Operand2
MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
txtsource.Text = Result.ToString("#,###.00")
End Select
txtsource.Text = Result.ToString("#,###.00")
End Sub
Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = ""
txtsource.Focus()
[Operator] = "-"
End Sub
Private Sub btnmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmultiply.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = ""
txtsource.Focus()
[Operator] = "*"
End Sub
Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = ""
txtsource.Focus()
[Operator] = "/"
End Sub
Private Sub btnaddminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
txtsource.Text = -1 * txtsource.Text
End Sub
Private Sub btnx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click
Dim convert As Single
If txtsource.Text <> 0 Then
convert = 1 / Val(txtsource.Text)
txtsource.Text = convert
End If
End Sub
Private Sub frmcalculator_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
Call btnequals_Click(sender, e)
End If
End Sub
Private Sub frmcalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class
|
|
|
|
|
Try something and then post issues here.
|
|
|
|
|
I really need help with this.
1. I have a excel file with columns with text and some with only the date in it (07/16/2013). This date can be in more than one row.
2. I then have a form where I can display all the info in the form (Eg like if I choose server, it will show me that server info on the form with all the other details that goes with it.
I get the info form my excel file.
3. I then have a button to search for info eg Server names, it then make a data grid view and show my all the servers that start with eg. Prasa.
4. Now my problem is I cannot get it to search for a date. I need help with this.
Here is my main code and my button date search code.
Is the a sample of this or can someone help me with this.
Imports System.Data.OleDb
Public Class Tapes_info
Private dtGlobal As New DataTable
Private Sub Tapes_info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dtGlobal.Clear()
Using cn As New OleDb.OleDbConnection
Dim Builder As New OleDbConnectionStringBuilder With {.DataSource = IO.Path.Combine(Application.StartupPath, "Backuptapes.xls"), .Provider = "Microsoft.ACE.OLEDB.12.0"}
Builder.Add("Extended Properties", "Excel 12.0; IMEX=1;HDR=No;")
cn.ConnectionString = Builder.ConnectionString
cn.Open()
Using cmd As OleDbCommand = New OleDbCommand With {.Connection = cn}
cmd.CommandText = "SELECT TOP 5130 F1 As Tapes, F2 As Containere, F3 as ContainerRef, F4 as DateOut FROM [Tapese$]"
Dim dr As System.Data.IDataReader = cmd.ExecuteReader
dtGlobal.Load(dr)
LstTape.DisplayMember = "Tapes"
LstTape.DataSource = dtGlobal
txtContainer.DataBindings.Add("Text", dtGlobal, "Containere")
txtContainerRef.DataBindings.Add("Text", dtGlobal, "ContainerRef")
txtDateOut.DataBindings.Add("Text", dtGlobal, "Dateout")
End Using
End Using
End Sub
Private Sub BtnSearchDateOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearchDateOut.Click
For i As Integer = 0 To dtGlobal.Rows.Count - 1
If IsDBNull(dtGlobal.Rows(i)("Dateout")) Then
dtGlobal.Rows(i)("Dateout") = ""
End If
Next
Dim query = From item In dtGlobal.AsEnumerable() Where item.Field(Of String)("Dateout").StartsWith(txtSearchDateOut.Text) Select item
If query.Count > 0 Then
Dim newDT As DataTable = query.CopyToDataTable()
MsgBox(newDT.Rows.Count.ToString() & " Date out found.")
Dim frm As New Form()
Dim dgv As New DataGridView()
dgv.DataSource = newDT
dgv.Refresh()
frm.Controls.Add(dgv)
dgv.Dock = DockStyle.Fill
frm.Size = New Size(1400, 700)
frm.Show()
Else
MsgBox("There is no Date for this found.")
End If
|
|
|
|
|