Results 1 to 11 of 11

Thread: Transfering Data to Notepad (Revisted) [UnResolved Now]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    34

    Unhappy Transfering Data to Notepad (Revisted) [UnResolved Now]

    This is a new topic to revist the old problem titled: "To notepad..."
    located HERE

    Sorry to bring up a really old topic, but is there a way to send the text to an embeded notepad window via a dialogue box? I mean, if the user entered text into text fields, and that data was then sent to the embeded notepad window. Then, you have another dialogue box, and then be able to send more information to the same embeded notepad window? Like, this is my code for the embeded notepad part:


    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
    2. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    3. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    4. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    5. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    6. Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    7. Private Declare Function GetDesktopWindow Lib "user32" () As Long
    8. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    9. Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
    10. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    11. Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    12. Const GW_HWNDNEXT = 2
    13. Dim mWnd As Long
    14.  
    15. Function InstanceToWnd(ByVal target_pid As Long) As Long
    16.     Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
    17.     'Find the first window
    18.     test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
    19.     Do While test_hwnd <> 0
    20.         'Check if the window isn't a child
    21.         If GetParent(test_hwnd) = 0 Then
    22.             'Get the window's thread
    23.             test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
    24.             If test_pid = target_pid Then
    25.                 InstanceToWnd = test_hwnd
    26.                 Exit Do
    27.             End If
    28.         End If
    29.         'retrieve the next window
    30.         test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    31.     Loop
    32. End Function
    33.  
    34. Private Sub Form_Load()
    35.     Call MyShell
    36.     frmTip.Show
    37. End Sub
    38.  
    39. Private Sub MyShell()
    40.     'KPD-Team 1999
    41.     'URL: [url]http://www.allapi.net/[/url]
    42.     'E-Mail: [email][email protected][/email]
    43.     Dim Pid As Long
    44.     'Lock the window update
    45.     LockWindowUpdate GetDesktopWindow
    46.     'Execute notepad.Exe
    47.     Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
    48.     If Pid = 0 Then MsgBox "Error starting the app"
    49.     'retrieve the handle of the window
    50.     mWnd = InstanceToWnd(Pid)
    51.     'Set the notepad's parent
    52.     SetParent mWnd, Me.hwnd
    53.     'Put the focus on notepad
    54.     Putfocus mWnd
    55.     'Unlock windowupdate
    56.     LockWindowUpdate False
    57. End Sub

    Thank you!
    Last edited by The Dude45; Dec 30th, 2004 at 08:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width