精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● VFP>>〖外部引用〗>>Re:如何避免同时运行程序的两个例程?我想做得专业一些,该怎么做

主题:Re:如何避免同时运行程序的两个例程?我想做得专业一些,该怎么做
发信人: pig2609(肥猪)
整理人: hunter__fox(2002-03-16 21:48:54), 站内信件
uTag=_screen.caption
_screen.caption=''
IF gnFindWindow(guTag)>0
    glSetForegroundWindow(guTag)
    QUIT
ELSE
   _screen.caption=guTag
ENDIF

*********************************
FUNCTION gnFindWindow
*--return a window's handle 
PARAMETER tcWinCaption
DECLARE integer FindWindow in WIN32API as _dll_findwindow string cNull, string cWinName
RETURN _dll_Findwindow(0,tcWinCaption)
********************************************************************
FUNCTION glShowWindow
PARAMETER tuHandlOrCaption,tnShowCmd

* SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_NORMAL = 1
* SW_SHOWMINIMIZED = 2, SW_SHOWMAXIMIZED = 3
* SW_MAXIMIZE = 3, SW_SHOWNOACTIVATE = 4, SW_SHOW = 5
* SW_MINIMIZE = 6, SW_SHOWMINNOACTIVE = 7, SW_SHOWNA = 8
* SW_RESTORE = 9,  SW_SHOWDEFAULT = 10, SW_MAX = 10

LOCAL lnWhnd,llRet
If Type('tuHandlOrCaption') = "C"
lnWhnd = gnFindWindow(tuHandlOrCaption)
Else
If Type('tuHandlOrCaption') <> 'N'
Return .F.
EndIf
lnWhnd=tuHandlOrCaption
EndIf

DECLARE integer ShowWindow in WIN32API as _dll_ShowWindow integer hWinHandle, integer nShowCmd

llRet= ( _dll_ShowWindow(lnWhnd,tnShowCmd)#0 )
RETURN llRet
********************************************************************
FUNCTION glSetForegroundWindow
PARAMETER tuHandlOrCaption
LOCAL lnWhnd,llRet
If Type('tuHandlOrCaption') = "C"
lnWhnd = gnFindWindow(tuHandlOrCaption)
Else
If Type('tuHandlOrCaption') <> 'N'
Return .F.
EndIf
lnWhnd=tuHandlOrCaption
EndIf

DECLARE integer SetForegroundWindow in WIN32API as _dll_SetForegroundWindow integer hWinHandle

llRet= ( _dll_SetForegroundWindow(lnWhnd)#0 )
RETURN llRet
********************************************************************

[关闭][返回]