PDA

Click to See Complete Forum and Search --> : Clipboard Api


Dafly
Jun 26th, 2000, 03:48 AM
I have a small program that "should" envoke the Paste command within another edit control, code is below.

Private Sub Command1_Click()
Clipboard.Clear 'Clears Clipboard
Clipboard.SetData Picture1.Picture 'Copys the Picture Into The ClipBoard
Call SendMessage(TxtBox&, WM_PASTE, 0, 2) 'TxtBox& is the hWnd of a richedit control and "envokes" the Paste Command.
End Sub

The Problem I am having is that it works within its self meaning it is only working within the same exe that it was made in but not other apps like wordpad.

Does anyone have another Idea how to do it or how to fix this code?

Thank you,
Jeremy

parksie
Jun 26th, 2000, 03:33 PM
I've noticed from quite a few posts around here that people are having trouble with playing around with another window's controls. Anyway, how did you obtain the handle to the control? Did you use something (similar to FindWindow?) to do this at runtime or did you just code it in? :)

Dafly
Jun 27th, 2000, 03:15 AM
I used FindWindowEx and FindWindow API Below

-----
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-----
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal Hwnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long


Sample use start up your Calculator Program and run the code below.

dim win1 as long
Win1& = FindWindow(vbNullString,"Calculator") 'Gets the hWnd of the Calc's window

dim win1 as long
Win1& = FindWindowEx(0&,0&,vbNullString,"Calculator") 'Gets the hWnd of the Calc's window

This only gets the main windows hWnd, I mainly use FindEindowEx to get Child window hWnd's


Hope this helps, Need any more info Post again or just e-mail me and Ill be glad to help.

Jeremy