* Windows FindWindowA, GetSystemMenu and RemoveMenu sample code;
* Richard A. DeVenezia;
* http://www.devenezia.com;
*
* 6/9/01
* Disable the menu item 'Close' (and X icon) of a SAS session;
*;
filename SASCBTBL catalog 'WORK.WINAPI.NOXICON.SOURCE';
data _null_;
file SASCBTBL;
input ;
put _infile_;
cards4;
routine FindWindowA
module = user32
minarg = 2
maxarg = 2
stackpop = called
returns = ulong
;
arg 1 char input byaddr format=$cstr200.; * LPCTSTR lpClassName;
arg 2 char input byaddr format=$cstr200.; * LPCTSTR lpWindowName;
ROUTINE GetSystemMenu
module = user32
minarg = 2
maxarg = 2
stackpop = called
returns = long
;
arg 1 num input byvalue format=ib4.; * HWND hwnd;
arg 2 num input byvalue format=ib4.; * BOOL bRevert;
ROUTINE RemoveMenu
module = user32
minarg = 3
maxarg = 3
stackpop = called
returns = long
;
arg 1 num input byvalue format=pib4.; * HMENU hMenu;
arg 2 num input byvalue format=ib4.; * UINT uPosition;
arg 3 num input byvalue format=ib4.; * UINT uFlags;
;;;;
data _null_;
WinClass = 'SAS aws';
WinTitle = 'SAS';
hWndSas = modulen ('FindWindowA', WinClass, WinTitle);
hMenuSas = modulen ('GetSystemMenu', hWndSas, 0);
* assume the standard window menu,
* (that drop down menu shown when upper left icon clicked or
* when icon in task bar right clicked)
* is Restore:Move:Size:Minimize:Maximize:Separator:Close
*;
mf_bypos = 0400X;
rc = modulen ('RemoveMenu', hMenuSas, 6, mf_bypos); * remove Close;
rc = modulen ('RemoveMenu', hMenuSas, 5, mf_bypos); * remove Separator;
run;
博客给出了Windows FindWindowA、GetSystemMenu和RemoveMenu的示例代码,用于禁用SAS会话的“关闭”菜单项及X图标。代码通过调用user32模块中的相关例程,获取窗口句柄和菜单句柄,进而移除关闭菜单和分隔符。
&spm=1001.2101.3001.5002&articleId=69978&d=1&t=3&u=a03d49b9b98140d6b383dabfa1996000)
368

被折叠的 条评论
为什么被折叠?



