Can"t use SendMessage...WM_PASTE with a regular Text Box
Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 04:17:16 von DM McGowan II
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
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 05:12:40 von Tom van Stiphout
On Tue, 30 Oct 2007 22:17:16 -0500, "Neil" wrote:
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
>
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 11:52:12 von Ron Weiner
Access Controls as *VERY* lightweight. In order for the control to *even*
have an Hwnd the control must have the focus. Try setting the focus to the
control and then calling your paste routine.
Ron W
"Neil" wrote in message
news:ktSVi.3527$Vx3.1143@nlpi069.nbdc.sbc.com...
> 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
>
>
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 15:07:15 von DM McGowan II
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" wrote in message
news:920gi3d60494c7af5pbd941mr4q33bkc2u@4ax.com...
> On Tue, 30 Oct 2007 22:17:16 -0500, "Neil" wrote:
>
> 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
>>
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 15:08:19 von DM McGowan II
Thanks, but, yeah, it had the focus. Per my other post in this thread, the
problem seems to be the ctl.hwnd statement, which seems to be invalid in
Access. Need to be able to get the control handle.
Thanks!
"Ron Weiner" wrote in message
news:%23DeRQv6GIHA.3600@TK2MSFTNGP06.phx.gbl...
> Access Controls as *VERY* lightweight. In order for the control to *even*
> have an Hwnd the control must have the focus. Try setting the focus to
> the control and then calling your paste routine.
>
> Ron W
> "Neil" wrote in message
> news:ktSVi.3527$Vx3.1143@nlpi069.nbdc.sbc.com...
>> 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
>>
>>
>
>
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 15:19:02 von DM McGowan II
Re. my other message, found some code by Dev Ashish that does that. Working
now. Thanks.
"Ron Weiner" wrote in message
news:%23DeRQv6GIHA.3600@TK2MSFTNGP06.phx.gbl...
> Access Controls as *VERY* lightweight. In order for the control to *even*
> have an Hwnd the control must have the focus. Try setting the focus to
> the control and then calling your paste routine.
>
> Ron W
> "Neil" wrote in message
> news:ktSVi.3527$Vx3.1143@nlpi069.nbdc.sbc.com...
>> 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
>>
>>
>
>
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 15:19:02 von DM McGowan II
Re. my other message, found some code by Dev Ashish that does that. Working
now. Thanks.
"Tom van Stiphout" wrote in message
news:920gi3d60494c7af5pbd941mr4q33bkc2u@4ax.com...
> On Tue, 30 Oct 2007 22:17:16 -0500, "Neil" wrote:
>
> 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
>>
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 31.10.2007 21:05:18 von XXXusenet
"Neil" wrote in
news:q90Wi.2166$yV6.1548@newssvr25.news.prodigy.net:
> 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/
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 01.11.2007 02:32:57 von DM McGowan II
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" wrote in message
news:Xns99DAA30BF8226f99a49ed1d0c49c5bbb2@216.196.97.142...
> "Neil" wrote in
> news:q90Wi.2166$yV6.1548@newssvr25.news.prodigy.net:
>
>> 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/
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 04.11.2007 02:37:54 von XXXusenet
"Neil" wrote in
news:d1aWi.13092$4V6.7578@newssvr14.news.prodigy.net:
> 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/
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 04.11.2007 12:42:56 von DM McGowan II
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" wrote in message
news:Xns99DDDB7E9DD1Ff99a49ed1d0c49c5bbb2@216.196.97.142...
> "Neil" wrote in
> news:d1aWi.13092$4V6.7578@newssvr14.news.prodigy.net:
>
>> 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/
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 04.11.2007 20:18:39 von XXXusenet
"Neil" wrote in
news:ufiXi.689$RR6.225@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/
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 04.11.2007 21:18:16 von lyle
On Nov 4, 6:42 am, "Neil" wrote:
> 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?
Re: Can"t use SendMessage...WM_PASTE with a regular Text Box
am 05.11.2007 05:12:05 von DM McGowan II
You're right, that works. I was wrong (again). I was confused in thinking
that the issue was that the form was opened in dialog mode. That wasn't the
issue. As you noted, Docmd... Paste works even in dialog mode.
The problem here is that the Cut, Copy, and Paste menu commands are not
available with the ActiveX rich text box controls, but Ctrl+V pasting is
available. Thus, when I ran Docmd...Paste into one of the rich text box
controls, I got the error -- not because the form was open in dialog mode,
but because the rich text boxes don't support the built-in Edit | Paste
function.
Calling the API Paste, and, thus, circumventing the Edit menu altogether,
resolved the problem -- though I could have used a SendKeys ^V to perform
the paste instead. But I think the API Paste is a more elegant solution than
SendKeys.
So, the problem did, indeed, need the API Paste instead of Docmd....Paste;
but it was for reasons other than what I had originally thought.
"lyle" wrote in message
news:1194207496.315031.234950@d55g2000hsg.googlegroups.com.. .
> On Nov 4, 6:42 am, "Neil" wrote:
>
>> 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?
>