将焦点设置为外部应用程序 [英] Setting focus to an external application

查看:61
本文介绍了将焦点设置为外部应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在列表框中包含了Window的标题,

窗口的类名和窗口的hWND。


有没有办法,使用上面的数据,激活/设置焦点到

窗口?

I have contained in a listbox the Window''s caption, the class name for
the window, and the hWND of the window.

Is there a way, using the data from above, to activate/set focus to that
window?

推荐答案

一个假设您可以使用此API函数:

私有声明函数SetFocus Lib" user32" _

(ByVal hwnd As Long)As Long

但是,根据具体情况你可能需要使用别名声明它b / b
以便你的代码不会与Access混淆

SetFocus。

One assumes you could use this API function:
Private Declare Function SetFocus Lib "user32" _
(ByVal hwnd As Long) As Long
however, depending on the circumstances you may have to declare it
using an alias so that your code does not confuse it with Access''s
SetFocus.


沙拉,


你想做这样的事情吗?


Dim AccessAppExtDb作为应用程序

Dim DbCurrentDatabase作为DAO.Database

Dim DbExternalDatabase作为DAO.Database

Dim Rst作为DAO.Recoedset

Dim PathToExtDb作为字符串

设置DbCurrentDatabase = CurrentDb()

PathToExtDb =" C:\ MyFolder \ MyDatabase.mdb"

设置AccessAppExtDb =新的Access.Application

AccessAppExtDb.OpenCurrentDatabase PathToExtDb


''你可以在外部数据库中打开一个表格

AssessAppExtDb.DoCmd.OpenForm" SomeForm"


''您可以在分机中打开记录集ernal数据库与

设置Rst = AssessAppExtDb.OpenRecordset(一些SQL)


''您可以在包含此代码的数据库中打开一个表单

DbCurrentDatabase.DoCmd.OpenFormMyForm


''您可以在包含此代码的数据库中打开记录集

设置Rst = DbCurrentDatabase.OpenRecordset(" MySQL")

-

PC数据表

您的资源获取Access,Excel和Word应用程序
re******@pcdatasheet.com
www.pcdatasheet.com


超过1000名访问用户来找我求助。我的费用非常合理。



" salad" < oi*@vinegar.com>在消息中写道

news:08 **************** @ newsread1.news.pas.earthli nk.net ...
Salad,

Are you looking to do something like this ----

Dim AccessAppExtDb As Application
Dim DbCurrentDatabase As DAO.Database
Dim DbExternalDatabase As DAO.Database
Dim Rst As DAO.Recoedset
Dim PathToExtDb As String
Set DbCurrentDatabase = CurrentDb()
PathToExtDb = "C:\MyFolder\MyDatabase.mdb"
Set AccessAppExtDb = New Access.Application
AccessAppExtDb.OpenCurrentDatabase PathToExtDb

'' You can open a form in the external database with
AssessAppExtDb.DoCmd.OpenForm "SomeForm"

'' You can open a recordset in the external database with
Set Rst = AssessAppExtDb.OpenRecordset("Some SQL")

'' You can open a form in the database containing this code with
DbCurrentDatabase.DoCmd.OpenForm "MyForm"

'' You can open a recordset in the database containing this code with
Set Rst = DbCurrentDatabase.OpenRecordset("MySQL")
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Over 1000 Access users have come to me for help. My fees are very
reasonable.


"salad" <oi*@vinegar.com> wrote in message
news:08****************@newsread1.news.pas.earthli nk.net...
我在列表框中包含了Window的标题,
窗口的类名和窗口的hWND。

有没有办法,使用来自的数据上面,激活/设置焦点到那个窗口?
I have contained in a listbox the Window''s caption, the class name for the
window, and the hWND of the window.

Is there a way, using the data from above, to activate/set focus to that
window?



Lyle Fairfield写道:
Lyle Fairfield wrote:
一个假设你可以使用此API函数:
私有声明函数SetFocus Lib" user32" _
(ByVal hwnd As Long)然而,根据具体情况,您可能需要使用别名来声明它,以便您的代码不会将其与Access''s <混淆br /> SetFocus。
One assumes you could use this API function:
Private Declare Function SetFocus Lib "user32" _
(ByVal hwnd As Long) As Long
however, depending on the circumstances you may have to declare it
using an alias so that your code does not confuse it with Access''s
SetFocus.




嗨莱尔,谢谢你指着我去SetFocus。我不得不进一步探索




由于一些奇怪的原因,我无法编译...我会得到一个错误

编译错误。成员已经存在于一个对象模块中,该对象模块从该对象模块中派生出来。 ???这到底是什么意思?


无论如何,我的编译错误行是

私有声明函数_

SetFocus Lib" user32" (ByVal hwnd As Long)As Long

我搜索SetFocus Lib在应用程序的所有模块中,但没有找到

短语。嗯......


无论如何,我对Google进行了一些扫描,并提出了ShowWindow API。设置

恢复的值会正确显示页面。



Hi Lyle, thanks for pointing me towards SetFocus. I had to explore a bit
further.

I couldn''t get it to compile for some odd reason...I''d get an error
"Compile Error. Member already exists in an object module from which
this object module derives." ???...what the heck does that mean?

Anyway, my compile error line is
Private Declare Function _
SetFocus Lib "user32" (ByVal hwnd As Long) As Long
I do a search for "SetFocus Lib" in all modules in the app but that
phrase is not found. Hmmm...

Anyway, I scanned Google a bit and came up with ShowWindow API. Setting
the value to Restore displays the page correctly.


这篇关于将焦点设置为外部应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆