473,508 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't use SendMessage...WM_PASTE with a regular Text Box

Anyone have any idea why

SendMessage ctl.hwnd, WM_PASTE, 0, 0

isn't working from a regular Access text box (form is opened normally, not
in dialog more)? I realize I can just use docmd.RunCommand acCmdPaste. But I
have a reason for needing to do it this way. When I run the code I get the
message, "Object doesn't support this property or method" (error 438). Any
ideas why this is happening? Thanks!

Neil
Here is the code I'm using:

Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Const WM_PASTE = &H302

Function MyFunc(ctl as control)
SendMessage ctl.hwnd, WM_PASTE, 0, 0
End Function
Oct 31 '07 #1
9 4683
On Tue, 30 Oct 2007 22:17:16 -0500, "Neil" <no****@nospam.netwrote:

Yes. You are assuming that the controls you see on the screen actually
exist. Not so in MsAccess. They are PAInTED on the form, but only the
control with input focus actually exists and has a valid window
handle.

-Tom.
>Anyone have any idea why

SendMessage ctl.hwnd, WM_PASTE, 0, 0

isn't working from a regular Access text box (form is opened normally, not
in dialog more)? I realize I can just use docmd.RunCommand acCmdPaste. But I
have a reason for needing to do it this way. When I run the code I get the
message, "Object doesn't support this property or method" (error 438). Any
ideas why this is happening? Thanks!

Neil
Here is the code I'm using:

Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Const WM_PASTE = &H302

Function MyFunc(ctl as control)
SendMessage ctl.hwnd, WM_PASTE, 0, 0
End Function
Oct 31 '07 #2
Yes, it had the focus. I called it from the OnClick event of the control
itself (just as a simple test to start with).

Also, if I change the object type to Textbox instead of Control, I see that
hwnd isn't a valid property anyway. So that must be what the problem is.

So the question now is: how to get a control handle in Access?

Thanks!

"Tom van Stiphout" <no*************@cox.netwrote in message
news:92********************************@4ax.com...
On Tue, 30 Oct 2007 22:17:16 -0500, "Neil" <no****@nospam.netwrote:

Yes. You are assuming that the controls you see on the screen actually
exist. Not so in MsAccess. They are PAInTED on the form, but only the
control with input focus actually exists and has a valid window
handle.

-Tom.
>>Anyone have any idea why

SendMessage ctl.hwnd, WM_PASTE, 0, 0

isn't working from a regular Access text box (form is opened normally, not
in dialog more)? I realize I can just use docmd.RunCommand acCmdPaste. But
I
have a reason for needing to do it this way. When I run the code I get the
message, "Object doesn't support this property or method" (error 438). Any
ideas why this is happening? Thanks!

Neil
Here is the code I'm using:

Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Const WM_PASTE = &H302

Function MyFunc(ctl as control)
SendMessage ctl.hwnd, WM_PASTE, 0, 0
End Function

Oct 31 '07 #3
Re. my other message, found some code by Dev Ashish that does that. Working
now. Thanks.

"Tom van Stiphout" <no*************@cox.netwrote in message
news:92********************************@4ax.com...
On Tue, 30 Oct 2007 22:17:16 -0500, "Neil" <no****@nospam.netwrote:

Yes. You are assuming that the controls you see on the screen actually
exist. Not so in MsAccess. They are PAInTED on the form, but only the
control with input focus actually exists and has a valid window
handle.

-Tom.
>>Anyone have any idea why

SendMessage ctl.hwnd, WM_PASTE, 0, 0

isn't working from a regular Access text box (form is opened normally, not
in dialog more)? I realize I can just use docmd.RunCommand acCmdPaste. But
I
have a reason for needing to do it this way. When I run the code I get the
message, "Object doesn't support this property or method" (error 438). Any
ideas why this is happening? Thanks!

Neil
Here is the code I'm using:

Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Const WM_PASTE = &H302

Function MyFunc(ctl as control)
SendMessage ctl.hwnd, WM_PASTE, 0, 0
End Function

Oct 31 '07 #4
"Neil" <no****@nospam.netwrote in
news:q9*****************@newssvr25.news.prodigy.ne t:
Re. my other message, found some code by Dev Ashish that does
that. Working now.
Why do you need to do this? I can't imagine ever needing it in any
of my Access apps.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Oct 31 '07 #5
Ah! Well, here's the deal. I needed to paste some text into a field from the
clipboard. However, that form is opened using acDialog. When that's the
case, Access Docmd Paste doesn't work. However, using SendMessage I was able
to paste the text from the clipboard into the textbox, even when it was open
in dialog mode.

(Now you might ask why I would need to paste data from the clipboard into a
text box with its form opened in dialog mode. If you want to know, I'll tell
you; but I wasn't sure if you wanted that much information.)

"David W. Fenton" <XX*******@dfenton.com.invalidwrote in message
news:Xn**********************************@216.196. 97.142...
"Neil" <no****@nospam.netwrote in
news:q9*****************@newssvr25.news.prodigy.ne t:
>Re. my other message, found some code by Dev Ashish that does
that. Working now.

Why do you need to do this? I can't imagine ever needing it in any
of my Access apps.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

Nov 1 '07 #6
"Neil" <no****@nospam.netwrote in
news:d1******************@newssvr14.news.prodigy.n et:
Ah! Well, here's the deal. I needed to paste some text into a
field from the clipboard. However, that form is opened using
acDialog. When that's the case, Access Docmd Paste doesn't work.
However, using SendMessage I was able to paste the text from the
clipboard into the textbox, even when it was open in dialog mode.

(Now you might ask why I would need to paste data from the
clipboard into a text box with its form opened in dialog mode. If
you want to know, I'll tell you; but I wasn't sure if you wanted
that much information.)
It sounds to me as though you're doing things wrong.

Again, I see no reason why one should ever need to do this. If you
need your dialog to get information from outside itself, there are
numerous ways to do it that don't require API calls of any kind.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Nov 4 '07 #7
Well, remember I wrote:
>(Now you might ask why I would need to paste data from the
clipboard into a text box with its form opened in dialog mode. If
you want to know, I'll tell you; but I wasn't sure if you wanted
that much information.)
So, instead of judging whether I'm doing things right or wrong, why don't
you just get that information? I didn't give it to you at first because I
didn't know if you wanted to go that deep into my situation. So here it is.

Users have a series of Word docs that they need to copy and paste from into
rich text fields in my database. By copying and pasting, they retain the
formatting in the Word docs, which needs to be preserved. One of the places
they need to paste into is a form bound to a child table (not a dialog box),
which is opened in dialog mode for coding reasons. So, when they need to
paste into this child form/table, which is open in dialog mode, there is no
way to do this apart from the API call.

Now, that being said, now that I've explained my situation, how would you
accomplish the same thing without using the API call? Don't say that you
wouldn't use rich text boxes to begin with, because that's not a valid
argument. My situation/client's needs require them. So, given the situation
I've described above, how would you accomplish it without the API call to
perform the paste?

Neil


"David W. Fenton" <XX*******@dfenton.com.invalidwrote in message
news:Xn**********************************@216.196. 97.142...
"Neil" <no****@nospam.netwrote in
news:d1******************@newssvr14.news.prodigy.n et:
>Ah! Well, here's the deal. I needed to paste some text into a
field from the clipboard. However, that form is opened using
acDialog. When that's the case, Access Docmd Paste doesn't work.
However, using SendMessage I was able to paste the text from the
clipboard into the textbox, even when it was open in dialog mode.

(Now you might ask why I would need to paste data from the
clipboard into a text box with its form opened in dialog mode. If
you want to know, I'll tell you; but I wasn't sure if you wanted
that much information.)

It sounds to me as though you're doing things wrong.

Again, I see no reason why one should ever need to do this. If you
need your dialog to get information from outside itself, there are
numerous ways to do it that don't require API calls of any kind.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

Nov 4 '07 #8
"Neil" <no****@nospam.netwrote in
news:uf***************@newssvr22.news.prodigy.net:
Now, that being said, now that I've explained my situation, how
would you accomplish the same thing without using the API call?
Don't say that you wouldn't use rich text boxes to begin with,
because that's not a valid argument. My situation/client's needs
require them. So, given the situation I've described above, how
would you accomplish it without the API call to perform the paste?
I don't know.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Nov 4 '07 #9
On Nov 4, 6:42 am, "Neil" <nos...@nospam.netwrote:
Users have a series of Word docs that they need to copy and paste from into
rich text fields in my database. By copying and pasting, they retain the
formatting in the Word docs, which needs to be preserved. One of the places
they need to paste into is a form bound to a child table (not a dialog box),
which is opened in dialog mode for coding reasons. So, when they need to
paste into this child form/table, which is open in dialog mode, there is no
way to do this apart from the API call.
When I run
DoCmd.OpenForm "employees", acNormal, , , , acDialog

and click on

Command34

Private Sub Command34_Click()
Me.LastName.SetFocus
DoCmd.RunCommand acCmdPaste
End Sub

the contents ot the clipboard are pasted into the LastName textbox.

Could you, please,explain the conditions (again maybe) which prevent
this from being used in the situation in question?

Nov 4 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2146
by: Sn | last post by:
Does anyone know how to use the SendMessage() function to save a text file in UTF-8 format. what are the Msg, Wparam and the lParam parameters passed to the function?
5
5843
by: Adam Clauss | last post by:
I am attempting to set the text on a richedit control in another application using EM_SETTEXTEX:...
2
1232
by: Husam | last post by:
Hi evreyBody: I set the text of internet explorer to www.yahoo.com by using sendmessage function and here what I did: SendMessage(hWnd, WM_SETTEXT, 0, "http://www.yahoo.com/") but i found...
22
9188
by: SQACSharp | last post by:
I'm trying to get the control name of an editbox in another window. The following code set the value "MyPassword" in the password EditBox but it fail to return the control name of the EditBox. ...
1
2634
by: tommyk | last post by:
Hi I am using the following code to search for a given string in either a listbox or a combo box, but the function always returns the index as "-1". The function fires from the change event of a...
15
10350
by: Necromis | last post by:
Ok, I am really losing it. I cannot seem to wrap my head around the SendMessage function/method. What I am trying to do is send text/data to an instance of a window that I know the handle of from...
1
13379
by: Necromis | last post by:
Ok, I have gotten my head around things better regarding SendMessage and FindWindow functions. However, I am running into an issue with my code still. The program I am working with is EXTRA! by...
14
12610
by: Kerem Gümrükcü | last post by:
Hi, i want to emulate a (synchronous) BroadCastSystemMessage with EnumWindows and SendMessage. I dont want to use the BroadcastSystemMessage because it needs the SE_TCB_NAME Privilege (you...
1
1248
by: FadeOut | last post by:
Hi everyone, I'm trying to make an application who sends querys to a tcp server who will then send an answer containing "rows" of commas separated values as an answer. I'm pretty new to tcp...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.