how to Focus on a child windows in java forms ? RRS feed

  • Question

  • Hello everone,

    i wsa using this code to focus on child window in windows form and its working 100%

    but how can i use it to focus on child window in java form

     Private Declare Auto Function FindWindowEx Lib "user32" (ByVal parentHandle As Integer,
                                                   ByVal childAfter As Integer,
                                                   ByVal lclassName As String,
                                                   ByVal windowTitle As String) As Integer
        Private Declare Auto Function PostMessage Lib "user32" (ByVal hwnd As Integer,
                                                                ByVal message As UInteger,
                                                                ByVal wParam As Integer,
                                                                ByVal lParam As Integer) As Boolean
        Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As IntPtr) As Integer
        Private Declare Function SetFocus Lib "user32.dll" (ByVal hWnd As IntPtr) As Integer

    and this code to check if the form open or not

     Dim hwnd2 As IntPtr = FindWindow(Nothing, "Scan Document")
            '  vicaopenafter12.Enabled = True
            If hwnd2 = IntPtr.Zero = True Then
    End if

    and this code to close the child

     Dim WM_QUIT As UInteger = &H12
            Dim WM_CLOSE As UInteger = &H10
            Dim x1 As Integer = FindWindowEx(0, 0, Nothing, "Print Report")
            PostMessage(x1, WM_CLOSE, 0, 0)

    How can i use it in java from ?

    thank u so much

    Thursday, January 16, 2020 1:45 PM

All replies

  • Hi Mostafa Salaheldien,

    Thank you for posting here.

    According to your description, your issue is more related to Java. Therefore, it will be more appropriate to ask your question in Java Forum

    Visual Basic forum is for VB.Net related questions as well as a Discussion board for VB.Net Language related topics.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 17, 2020 1:45 AM