惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - max chan

企业管理软件开发XP iframe 高度自动调节,最简单解决 被逼上 Visual Studio 2008 被逼上 visual studio 2005 超级gnFindWindow FLL - C++与VFP 双向混合编程 C++ 松花江上 复习 树-递归 全面自定义 - 代码挂接 设计原则 聪明与代价 VFP程序,全面自定义之表单/类 VFP通用代码(vcx/scx/prg)混淆器,可以下载了 备份策略 死里逃生 先舍后得 VFP -> dot net 过渡 -- foxpro toolkit for dot net VFP与DOT NET之间的过渡 - SEDNA
函数glDefinePopup(),动态定义多级的popup菜单
max chan · 2007-08-30 · via 博客园 - max chan

动态的定义POPUP,涉及字符串处理、递归、菜单定义语句等等。

也挺费劲的,

做出这个函数,就可扩展基类 _FORM, 以加上 接口:_c菜单定义 、_v菜单事件() 。  

(1) 使用例子

TEXT to cMenu 
文件
    打开
        EXCEL
        WORD
    关闭
    Quit
    
编辑
    Copy
    paste
帮助    
ENDTEXT

glDefinePopup(cMenu,

'abc')    
Activate Popup abc

(2)函数定义

*******************************************************************
Function glDefinePopup
Lparameters tcPopupDefine, tcPopupName 
*- 功能: 定义多级的关联popup菜单
*-
*- 参数
*- (1) tcPopupDefine: 菜单定义字符串,每项以换行分隔,以TAB确定级别
*- 例子: 
*- text to cPpDefine
*-    文件
*-        打开
*-            EXCEL
*-            WORD
*-        关闭
*- endtext
*-
*- (2) tcPopupName: 定出来的POPUP的名字
*-
Local i,cLine,n当前级数,n上级id_

Release POPUPS (tcPopupName) extended 

*- 转变为链表结构 ----------------
Create Cursor _csDefine_menu_MenuStru (id_ i , fid_ i , 菜单定义 c(
240), 级数 i,子女数 i )
For i=1 to GetWordCount(tcPopupDefine,Chr(13))
    cLine 
= Alltrim( GetWordNum(tcPopupDefine,i,Chr(13)) , 1Chr(10),Chr(32))
    
If Empty(cLine)
        
Loop
    EndIf 
    n当前级数 
=  _n求级数(cLine) 

    n上级id_
=0
    
Do while not bof() && 往回找,找到级别比自己小[1级]的, 就是父. 取其id作fid_, 父的子女数+1
        
If 级数 < n当前级数
            n上级id_ 
=  id_
            
Replace 子女数 with 子女数+1
            
Exit
        EndIf         
        Skip 
-1
    EndDo 
    
    Append Blank 
    
Replace id_ with i, fid_ with n上级id_, 级数 with n当前级数, 菜单定义 with Ltrim(cLine,1,Chr(9)) 
Next 

_vDefinePopUp(
0,0,tcPopupName)
Return .t.
**********************************************
Function _vDefinePopup
Lparameters tn上级id, tn上级barID, tc上级popUp名
Local nBarCnt,nRecNo,c本级popup名

    
If tn上级barID = 0
    c本级popup名 
= tc上级popUp名
Else
    c本级popup名 
= tc上级popUp名+'_'+Alltrim(Str(tn上级barID,10))
    _vfp.DoCmd( Textmerge('On Bar <<tn上级barID>> of <<tc上级popUp名>> activate popup <<c本级popup名>>'))
EndIf     
_vfp.DoCmd( Textmerge(
"Define Popup <<c本级popup名>> shortcut relative "))
_vfp.DoCmd( Textmerge(
"On Selection Popup <<c本级popup名>> Deactivate Popup <<c本级popup名>> "))
*---

nBarCnt
=0
nRecNo
=Recno()
Scan 
for fid_ = tn上级id
    nBarCnt 
= nBarCnt + 1 
    _vfp.DoCmd( Textmerge(
"define Bar <<nBarCnt>>  of <<c本级popup名>> prompt '<<Trim(菜单定义)>>' " ))
    
    
If 子女数 > 0
        _vDefinePopup(id_,nBarCnt,c本级popup名)
    EndIf     
EndScan 
Go (nRecNo)
Return 

**********************************************
Function _n求级数
Lparameters tcStr
Local nCnt,i
nCnt
=0
For i=1 To Len(tcStr)
    
If Substr(tcStr,i,1)=Chr(9)
        nCnt 
= nCnt + 1
    
Else
        
Exit
    Endif
Next

Return nCnt+1
**********************************************************