找回密码
 加入
搜索
查看: 6694|回复: 12

[AU3基础] ModernMenuRaw.au3托盘右侧空白处太长,如何变得紧凑

  [复制链接]
发表于 2011-10-16 23:13:57 | 显示全部楼层 |阅读模式
本帖最后由 lxsh010 于 2011-10-17 10:35 编辑



使用ModernMenuRaw.au3,可以给菜单添加图标,非常漂亮。

可是,右侧的空白处很长,一大片,非常影响美观。


再看一下,网管联盟深蓝老大的,


都非常紧凑。

我的意思,在托盘菜单后面,不要有那么多空白。

请问,有办法解决吗?求助于各位大侠了,谢谢!!!
#NoTrayIcon
#include "ModernMenuRaw.au3"

Opt("GUIOnEventMode", 1) ;Gui事件响应模式
Opt("GUIEventOptions", 1) ;修改特殊的 Gui 函数的返回值类型 1=立即通知
;Opt("WinTitleMatchMode",2);标题的任意子串皆可匹配
Opt("GUICloseOnESC", 0);在按下 ESC 时不退出

$nTrayIcon1 = _TrayIconCreate("拾零工具箱", "", 0)
_TrayIconSetClick(-1, 16)
_TrayIconSetState();显示托盘
$bUseAdvTrayMenu = False;菜单样式(可取值 TRUE 和 False)
$nTrayMenu1 = _TrayCreateContextMenu() ; 创建托盘上下文菜单,即右键点击托盘图标显示的菜单


$Slt001 = _TrayCreateItem("显示桌面(&X)")
_TrayItemSetIcon(-1, @SystemDir & "\SHELL32.dll", -35)
;~ GUICtrlSetOnEvent(-1, "_QuickLaunch")
$Slt002 = _TrayCreateItem("屏幕截图(&P)")
_TrayItemSetIcon(-1, @AppDataCommonDir & "\Sea_T\Sealin.DLL", -25)
;~ GUICtrlSetOnEvent(-1, "_QQscreen")
_TrayCreateItem("") ;文本为空时添加分割线
$Slt003 = _TrayCreateItem("打开 U盘(&D)")
;~ GUICtrlSetFont(-1, 9.9, 800, "", "宋体")
_TrayItemSetIcon(-1, @AppDataCommonDir & "\Sea_T\Sealin.DLL", -22)
;~ GUICtrlSetOnEvent(-1, "_OpenUsb")
$Slt004 = _TrayCreateItem("删除 U盘(&U)")
GUICtrlSetFont(-1, "", 0, 0, "Tahoma", 0)
_TrayItemSetIcon(-1, @AppDataCommonDir & "\Sea_T\Sealin.DLL", -38)
;~ GUICtrlSetOnEvent(-1, "_DelUsb")
_TrayCreateItem("") ;文本为空时添加分割线
$Slt005 = _TrayCreateItem("弹出光驱(&T)")
_TrayItemSetIcon(-1, @SystemDir & "\SHELL32.dll", -12)
;~ GUICtrlSetOnEvent(-1, "_CDROMTray1S")
$Slt006 = _TrayCreateItem("关闭光驱(&G)")
_TrayItemSetIcon(-1, @SystemDir & "\SHELL32.dll", -158)
;~ GUICtrlSetOnEvent(-1, "_CDROMTray2S")
_TrayCreateItem("") ;文本为空时添加分割线
$Slt007 = _TrayCreateItem("快速关机(&K)")
_TrayItemSetIcon(-1, @AppDataCommonDir & "\Sea_T\Sealin.DLL", -37)
;~ GUICtrlSetOnEvent(-1, "_QuickClose")
$Slt008 = _TrayCreateItem("快速重启(&Q)")
_TrayItemSetIcon(-1, @AppDataCommonDir & "\Sea_T\Sealin.DLL", -36)
;~ GUICtrlSetOnEvent(-1, "_QuickReboot")
_TrayCreateItem("") ;文本为空时添加分割线
$f2 = _TrayCreateItem("最小化/显示")
_TrayItemSetIcon(-1, @AppDataCommonDir & "\Sea_T\Sealin.DLL", -32)
 GUICtrlSetOnEvent(-1, "TrayClick")
_TrayCreateItem("") ;文本为空时添加分割线
$exitom = _TrayCreateItem("退出程序(&E)")
_TrayItemSetIcon(-1, @SystemDir & "\shell32.DLL", -28)
GUICtrlSetOnEvent(-1, "_Quit")


While 1
        Sleep(500)
WEnd


Func TrayClick() ;双击托盘隐/显窗口
        
EndFunc   ;==>TrayClick

Func _Quit() ;退出拾零工具箱
;~         WinMove("拾零工具箱", "", @DesktopWidth + 300, Default, Default, Default, 2);退出时特效显示
;~         DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", 200, "long", 0x00050001);窗体右出
;~         GUISetState(@SW_HIDE, $hGUI)
        _TrayIconDelete($nTrayIcon1) ;退出时删除托盘图标
;~         FileDelete(@ProgramFilesDir & "\Sealin\*.*")
        Exit
EndFunc   ;==>_Quit

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-10-16 23:21:18 | 显示全部楼层
无意义!~鉴定完毕
 楼主| 发表于 2011-10-16 23:45:00 | 显示全部楼层
本帖最后由 lxsh010 于 2011-10-16 23:59 编辑

回复 2# gzh888666

不好意思。我是菜鸟。
刚刚又测试一下,如果我把图标去除,,就会非常紧凑。而加上图标

_TrayItemSetIcon(-1, @SystemDir & "\shell32.DLL", -28)

则菜单又往右拉,非常不正常。

难道是ModernMenuRaw.au3的缘故,,可都是E文,谁来改一改呢?

谢谢
 楼主| 发表于 2011-10-16 23:46:55 | 显示全部楼层




楼上的兄弟,请帮帮忙行吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-10-17 00:02:16 | 显示全部楼层
发别人能直接运行的代码,是能得到问题解答的更好方式。
 楼主| 发表于 2011-10-17 00:27:32 | 显示全部楼层
回复 5# happytc

对不起,我太急了。代码可以运行了。

恳切得到大侠们的帮助。谢谢
发表于 2011-10-17 09:29:56 | 显示全部楼层
#include <GDIPlus.au3>
#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WinAPIEx.au3>
#include <WindowsConstants.au3>
#Include <Constants.au3>
#Include <GDIPlusEx.au3>
Global $iMemo


$file = FileOpenDialog("Select file", @ScriptDir, ("Icons from (*.ico; *.dll; *.exe)"))

If @error Then Exit

_GDIPlus_Startup()
$hIcon = _WinAPI_ShellExtractIcon($file,0,32,32);读取图标,创建图标句柄
$hImage=_GDIPlus_BitmapCreateFromHICON($hIcon);从图标句柄创建位图句柄
_WinAPI_DestroyIcon($hIcon)

;~ $iWidth = 32
;~ $iHeight = 32
;~ $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
;~ $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
;~ _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)
$hIcon = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage);从位图句柄创建位图

_Main()

_GDIPlus_ImageDispose ($hImage)
_WinAPI_DeleteObject($hIcon)
_GDIPlus_Shutdown()

Exit


Func _Main()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu ()
    _GUICtrlMenu_InsertMenuItem ($hFile, 0, "&New", $idNew)
    _GUICtrlMenu_InsertMenuItem ($hFile, 1, "&Open", $idOpen)
    _GUICtrlMenu_InsertMenuItem ($hFile, 2, "&Save", $idSave)
    _GUICtrlMenu_InsertMenuItem ($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem ($hFile, 4, "E&xit", $idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu ()
    _GUICtrlMenu_InsertMenuItem ($hEdit, 0, "&Cut", $idCut)
    _GUICtrlMenu_InsertMenuItem ($hEdit, 1, "C&opy", $idCopy)
    _GUICtrlMenu_InsertMenuItem ($hEdit, 2, "&Paste", $idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu ()
    _GUICtrlMenu_InsertMenuItem ($hHelp, 0, "&About", $idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu ()
    _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem ($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu ($hGUI, $hMain)

    ; Create memo control
    $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; Set New menu item to have a bitmap
    _GUICtrlMenu_SetItemBmp ($hFile, 0, $hIcon)
    MemoWrite("Item bitmap handle: 0x" & Hex(_GUICtrlMenu_GetItemBmp ($hFile, 0)))

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite

;~ Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
;~     Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
;~     If @error Then Return SetError(@error, @extended, 0)
;~     $GDIP_STATUS = $aResult[0]
;~     Return $aResult[6]
;~ EndFunc ;==>_GDIPlus_BitmapCreateFromScan0
 楼主| 发表于 2011-10-17 10:48:50 | 显示全部楼层
回复 7# 3mile

非常感谢三笑大侠的回复。。只是,,只是我运行一下,貌似没什么效果。不好意思。俺菜。
发表于 2011-10-22 21:55:50 | 显示全部楼层
回复 1# lxsh010

复制楼主的代码实行是空白处长.
以前也有过这种问题.

一摸一样的代码,复制他的代码实行不成功,自己写的代码就没问题。。。
可能是字体有关?还是编辑器有问题?输入法的问题?不明白。。。

楼主应该重新创建au3文件重写一遍,也许解决问题.
另外,加个&会增加空白处.

复制这个看看怎么样.
#NoTrayIcon
#include "ModernMenuRaw.au3"

$MenuIcon = _TrayIconCreate("By lixiaolong")

_TrayIconSetState()
_TrayIconSetClick($MenuIcon, 16);
_TrayCreateContextMenu()

$guirestor = _TrayCreateItem("显示桌面(X)")
_TrayItemSetIcon(-1, "SHELL32.dll", -35)
$gomi = _TrayCreateItem("显示桌面(X)")
_TrayItemSetIcon(-1, "SHELL32.dll", -33)
$Templixiaolong = _TrayCreateItem("显示桌面(X)")
_TrayItemSetIcon(-1, "SHELL32.dll", -5)
$IeTemp = _TrayCreateItem("显示桌面(X)")
_TrayItemSetIcon(-1, @ProgramFilesDir & "\Internet Explorer\iexplore.exe")
$exititem = _TrayCreateItem("退出(E)")
_TrayItemSetIcon(-1, "SHELL32.dll", -28)

While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $exititem
                        _TrayIconDelete($MenuIcon)
                        Exit
        EndSelect
WEnd
发表于 2011-10-22 21:56:41 | 显示全部楼层
回复 8# lxsh010


    3哥用的是GDI的!


你可以不用皮肤试试看
 楼主| 发表于 2011-11-2 22:02:33 | 显示全部楼层
回复 9# lixiaolong

小龙大哥,用了你的代码,就很正常了。

谢谢你的建议。我再试试,实在不行。就把图标都去了。。

谢谢!!!!
 楼主| 发表于 2011-11-2 22:03:14 | 显示全部楼层
回复 10# hzxymkb

谢谢,去了皮肤也是一样的。。唉,一声长叹。路漫漫其修远兮,吾将上下而求索。。

谢谢!!!!!
发表于 2011-11-3 03:25:52 | 显示全部楼层
去掉分割线...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-20 22:39 , Processed in 0.090159 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表