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. RE: Visual Basic Code Help
Ok I did what you said and now I get this error

[Image: runtime2.JPG]

My Code With Changes:
code:
Private Sub Click(Btnhwnd As Long)
    Dim ChildID As Long
    Dim Nul As Long
    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 Long, CurHwnd As Long, T As String
    Dim Length As Long, x As Long, y As Long
    ' 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 Long 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 Long 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:
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 Long


Declare Function GetParent Lib "user32" (ByVal hwnd As Integer) As Long


Declare Function GetWindow Lib "user32" (ByVal hwnd%, ByVal wCmd%) As Long


Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd%, ByVal lpString$, ByVal nMaxCount%) As Long


Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long


Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Long


Declare Function SendMessageByNum& Lib "user32" Alias "SendMessage" (ByVal hwnd%, ByVal wMsg%, ByVal wparam%, ByVal lparam&)
[Image: top.gif]
11-27-2005 05:38 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