What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Visual Basic Code Help

Visual Basic Code Help
Author: Message:
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. Huh?  Visual Basic Code Help
I found this code on planetsourcecode and I need to know how to get it to work.

code:
Private Sub Click(Btnhwnd As Integer)
    Dim ChildID As Integer
    Dim Nul As Integer
    Const GWW_ID = (-12)
    ChildID = GetWindowWord(Btnhwnd, GWW_ID)
    Nul = SendMessageByNum(GetParent(Btnhwnd), WM_COMMAND, ChildID, ByVal CLng(Btnhwnd))
End Sub


Private Sub Command1_Click()
    'On Error Resume Next
    Dim Btn As Integer, CurHwnd As Integer, T As String
    Dim Length As Integer, x As Integer, y As Integer
    ' Trying to find the handle of the View
    '     Code Button so that
    ' by clicking this program's button, we
    '     can see the code
    ' window for this form.
    CurHwnd = GetDesktopWindow() 'Get Desktop handle
    CurHwnd = GetWindow(CurHwnd, GW_Child) 'Find Child Windows of Desktop


    Do
        If CurHwnd = 0 Then Exit Do 'No (more) matches found
        ' Find out how Integer the text in this win


        '     dow is
            Length = GetWindowTextLength(CurHwnd)
            T = Space$(Length + 1) 'Allocate buffer space
            Length = GetWindowText(CurHwnd, T, Length + 1)


            If InStr(UCase$(T), "PROJECT") Then
                ' The word "Project" was found in this W
                '     indow's text
                ' so this is likely VB's "Project" windo
                '     w
                CurHwnd = GetWindow(CurHwnd, GW_Child)
                ' Looking now for the Project Window's c
                '     hild windows


                Do
                    If CurHwnd = 0 Then Exit Sub 'No (more) matches found
                    ' Find out how Integer the text in this win


                    '     dow is
                        Length = GetWindowTextLength(CurHwnd)
                        T = Space$(Length + 1) 'Allocate buffer space
                        Length = GetWindowText(CurHwnd, T, Length + 1)


                        If InStr(UCase$(T), "VIEW CODE") Then
                            ' This is the handle we want
                            Click CurHwnd 'Click the View Code Button
                            Exit Sub 'Exit the Sub
                        End If
                        CurHwnd = GetWindow(CurHwnd, GW_HWNDNEXT) 'Keep looking
                    Loop
                End If
                CurHwnd = GetWindow(CurHwnd, GW_HWNDNEXT) 'Keep looking
            Loop
        End Sub

Module Code:
code:
Global Const WM_COMMAND = &H111
Global Const GW_Child = 5
Global Const GW_HWNDFIRST = 0
Global Const GW_HWNDLAST = 1
Global Const GW_HWNDNEXT = 2
Global Const GW_HWNDPREV = 3
Global Const GW_OWNER = 4


Declare Function GetDesktopWindow Lib "User32" () As Integer


Declare Function GetParent Lib "User32" (ByVal hWnd As Integer) As Integer


Declare Function GetWindow Lib "User32" (ByVal hWnd%, ByVal wCmd%) As Integer


Declare Function GetWindowText Lib "User32" (ByVal hWnd%, ByVal lpString$, ByVal nMaxCount%) As Integer


Declare Function GetWindowTextLength Lib "User32" (ByVal hWnd As Integer) As Integer


Declare Function GetWindowWord Lib "User32" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer


Declare Function SendMessageByNum& Lib "User32" Alias "SendMessage" (ByVal hWnd%, ByVal wMsg%, ByVal wparam%, ByVal lparam&)

I get this error when I run the code

[Image: runtime.JPG]
[Image: top.gif]
11-27-2005 05:05 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Visual Basic Code Help - by DJeX on 11-27-2005 at 05:05 AM
RE: Visual Basic Code Help - by Mnjul on 11-27-2005 at 05:15 AM
RE: Visual Basic Code Help - by DJeX on 11-27-2005 at 05:38 AM
RE: Visual Basic Code Help - by Mnjul on 11-27-2005 at 05:56 AM
RE: Visual Basic Code Help - by DJeX on 11-27-2005 at 07:15 AM
RE: Visual Basic Code Help - by Mike on 11-27-2005 at 08:07 AM
RE: Visual Basic Code Help - by IKillThings on 11-27-2005 at 08:13 AM
RE: Visual Basic Code Help - by Mike on 11-27-2005 at 08:22 AM
RE: Visual Basic Code Help - by CookieRevised on 11-27-2005 at 10:21 AM
RE: Visual Basic Code Help - by DJeX on 11-27-2005 at 07:41 PM
RE: RE: Visual Basic Code Help - by CookieRevised on 11-27-2005 at 08:29 PM
RE: Visual Basic Code Help - by DJeX on 11-27-2005 at 09:44 PM
RE: Visual Basic Code Help - by CookieRevised on 11-27-2005 at 11:01 PM
RE: Visual Basic Code Help - by DJeX on 11-27-2005 at 11:50 PM
RE: Visual Basic Code Help - by CookieRevised on 11-28-2005 at 12:11 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On