Solved

How do i obtain the text from the search bar that is located in syspro's quotation window.

Posted on 2011-03-08
10
346 Views
Last Modified: 2012-05-11
Hello once again!

Im attempting to master a search query here with syspro, and without having any reference material Ive resorted to the web for help. Im Building a customized Pane, with the pane it pulls Quote num, jobs available, Quotation date, real wip value, and the number of items quoted. I got part of the view working, but what id like to setup is to be able to search for a specific quote number, or quotation date, or even by job Number. I see that Syspro already has a search bar at the top of the page, but im not sure how i would find out whats in it progmatically. is there a handle that is set with the value of the text box? or is it set to do something else and manually refresh all the panes with the data?
0
Comment
Question by:jnsprad
  • 5
  • 4
10 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35078286
jnsprad: Hi. I haven't worked with Syspro but yes it is possible to get the handle for any window using VB. You need to use the API for that.

Logic
Use FindWindow API to get the handle of the window using it's caption.

Enumerate Child windows (even textbox is window) and get it's handle.

Sid
0
 
LVL 1

Author Comment

by:jnsprad
ID: 35087701
I understand your api command. But what i dont get is the · lpClassName what is that supposed to be? and how would i obtain that information from the other window?  I think your on to something though, if i could get its handle though, Syspro doenst use .net frame work (;-() so i cant use the.text to get the information inside of it... how would i go about reading the handle....the code syspro has is extreemly dull compared to .net.. i cant even use one line to define a variable. in .net i could use
 dim variable as string = "Something"

Open in new window

, in this i have to use:
 
dim varriable
varriable = "anyhting here, string, int, long anything"

Open in new window


just for refference, the code im using to find the windows handle is:
Public Class Form1
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim name As String = FindWindow(, "Job Query")
        Messagebox.show(name)
    End Sub
End Class

Open in new window


 the location of the text bar
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35087861
To start with, change the Type of 'name' from String to Long as that is that FindWindow Returns. Second use vbnullstring. See this code. Does the messagebox return a 'Number'?

Public Class Form1
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button1.Click
        Dim name As Long = FindWindow(vbNullString, "Job Query")
        MessageBox.Show(name)
    End Sub
End Class

Open in new window


Sid
0
 
LVL 1

Author Comment

by:jnsprad
ID: 35137047
Sorry for the log timed reply, work is getting busy. Your code does return a number. although its not a static number... Changes everytime i click the button
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35137139
>>>Your code does return a number.

That's good :)

>>>Changes everytime i click the button

Yes, It will.

Let me write the next part and post it back. Will be able to do it in the next couple of hours as I am stepping out for sometime :)

Sid
0
 
LVL 1

Author Comment

by:jnsprad
ID: 35164588
bump?
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35166184
jnsprad: Guess I am getting old. Sorry to have missed your thread.

Ok, since I don't have access to SysPro, here is the code that I tried with notepad and it works. You will have to do the rest at your end. However I am sure this will get you started.

Logic: Every Window has a HANDLE. Even menus in a window (Known as Child Windows) have a handle. Once you get the handle of a child window you can do what you want.

Now in your case SysPro has a handle. There are many child windows. The menu where the combobox is parked also has a handle. The combobox (Child Window of menubar) also has it's own handle. So you have to first find the handle of Syspro (ALREADY DONE ABOVE). Then you need to enumerate and get handle of all child windows. One of the child window is the Menubar where combo resides. Once you get the handle of that menu bar you again enumerate through child windows of that menubar and get the handle of the combobox.

The below example will give you the handle of all the child windows. Please note I am testing it with notepad. Please amend the code for syspro.

Hope this helps.

Sid

Code in a Module

Imports System.Runtime.InteropServices

Module Module1
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Public Function FindWindow( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As IntPtr
    End Function

    <DllImport("User32.dll")> _
    Public Function EnumChildWindows _
        (ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, _
        ByVal lParam As IntPtr) As Boolean
    End Function

    Public Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean

    Public Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr()
        Dim ChildrenList As New List(Of IntPtr)
        Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList)
        Try
            EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle))
        Finally
            If ListHandle.IsAllocated Then ListHandle.Free()
        End Try
        Return ChildrenList.ToArray
    End Function

    Private Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean
        Dim ChildrenList As List(Of IntPtr) = GCHandle.FromIntPtr(Parameter).Target
        If ChildrenList Is Nothing Then Throw New Exception("GCHandle Target could not be cast as List(Of IntPtr)")
        ChildrenList.Add(Handle)
        Return True
    End Function
End Module

Open in new window


Code in the Form Area

Public Class Form1
    Dim lpszParentClass As String = "Notepad"
    Dim lpszParentWindow As String = "Untitled - Notepad"

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim name As New IntPtr(0)
        name = FindWindow(lpszParentClass, lpszParentWindow)
        Dim i As Integer
        '~~> This will give you the handle of the main window
        Debug.Print(name)
        Dim childWindows() As IntPtr = GetChildWindows(name)

        '~~> This will give you the handle of all child windows
        For i = 0 To childWindows.Length - 1
            Debug.Print(childWindows(i).ToString)
        Next
    End Sub
End Class

Open in new window

0
 
LVL 1

Author Comment

by:jnsprad
ID: 35506164
I have had Syllogist walk me through the procedure. I wasnt able to successfully able to gather the item due to multiple programming languages being used to produce the application. Ticket closed. Point awarded
0
 
LVL 1

Author Closing Comment

by:jnsprad
ID: 35506172
Can be applied to any other programs as well..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now