Jump to content
Sign in to follow this  
ame1011

Transparent Bmp Menu Image

Recommended Posts

ame1011

Hi There I have the following code:

#include <Array.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <Constants.au3>
#include <Date.au3>
#include <WinAPI.au3>
#include <_XMLDomWrapper.au3>
#include <GUICtrlSetOnHover_UDF.au3>
#include <GIFAnimation.au3>
#include <StringSize.au3>
#include <SendMessage.au3>
#include <GuiMenu.au3>


Local $iGuiWidth = 1400
Local $iGuiHeight = 900
Local $hMenuFile, $hMenuLibrary, $hMenuEdit, $hMenuView, $hMenuOptions, $hMenuHelp, $hMainMenu
Local Enum $idFileNewSeries = 1000, $idFileSeparator1, $idFileAddFile, $idFileAddFolder, $idLibraryBackup, $idLibraryOrganize, $idLibraryExport, $idFileSeparator2, $idFileUpdate, $idFileSeparator3, $idFileExit
Local Enum $idEditUndo = 2000, $idEditSeparator1, $idEditCut, $idEditCopy, $idEditPaste, $idEditDelete, $idEditSelectAll, $idEditSelectNone
Local Enum $idViewAsList = 3000, $idViewAsBanners, $idViewSeparator1, $idViewOptions
Local Enum $idOptionsPreferences = 4000
Local Enum $idHelpHelp = 5000, $idHelpIntro, $idHelpSeparator1, $idHelpAbout
Local $hBmpCreate

$hGui = GUICreate("TEST APP", $iGuiWidth, $iGuiHeight, (@DesktopWidth-$iGuiWidth)/2, (@DesktopHeight-$iGuiHeight)/2, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetFont(8, 400, 0, "Verdana")

;icons
;---File
$hBmpCreate = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Create.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpNewVideo = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\New Video.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpAddFolder = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Add Folder.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpCD = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\CD.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpNotes = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Notes.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpExport = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Export.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpUpdate = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Update.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpExit = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Exit.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
;---Edit
$hBmpUndo = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Undo.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpCut = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Cut.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpCopy = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Copy.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpPaste = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Paste.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpDelete = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Delete.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpSelectAll = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Select All.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpSelectNone = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Select None.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
;---Preferences
$hBmpOptions = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Options.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
;---Help
$hBmpHelp = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Help.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpIntro = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\Intro.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))
$hBmpAbout = _WinAPI_LoadImage(0, @ScriptDir & "\_Resources\icons\About.bmp", $IMAGE_BITMAP, 16, 16, BitOR($LR_LOADTRANSPARENT,$LR_LOADFROMFILE))


;File Menu
$hMenuFile = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 0, "New Series", $idFileNewSeries)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 1, "", $idFileSeparator1)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 2, "Add File to Library ...", $idFileAddFile)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 3, "Add Folder to Library ...", $idFileAddFolder)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 5, "", $idFileSeparator2)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 6, "Update Info from Web", $idFileUpdate)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 7, "", $idFileSeparator3)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 8, "Exit", $idFileExit)
;---Images
_GUICtrlMenu_SetItemBmp($hMenuFile, $idFileNewSeries, $hBmpCreate, False)
_GUICtrlMenu_SetItemBmp($hMenuFile, $idFileAddFile, $hBmpNewVideo, False)
_GUICtrlMenu_SetItemBmp($hMenuFile, $idFileAddFolder, $hBmpAddFolder, False)
_GUICtrlMenu_SetItemBmp($hMenuFile, $idFileUpdate, $hBmpUpdate, False)
_GUICtrlMenu_SetItemBmp($hMenuFile, $idFileExit, $hBmpExit, False)

;Library Menu
$hMenuLibrary = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMenuLibrary, 0, "Backup to Disc ...", $idLibraryBackup)
_GUICtrlMenu_InsertMenuItem ($hMenuLibrary, 1, "Organize Library ...", $idLibraryOrganize)
_GUICtrlMenu_InsertMenuItem ($hMenuLibrary, 2, "Export Library ...", $idLibraryExport)
;---Images
_GUICtrlMenu_SetItemBmp($hMenuLibrary, $idLibraryBackup, $hBmpCD, False)
_GUICtrlMenu_SetItemBmp($hMenuLibrary, $idLibraryOrganize, $hBmpNotes, False)
_GUICtrlMenu_SetItemBmp($hMenuLibrary, $idLibraryExport, $hBmpExport, False)

;Edit Menu
$hMenuEdit = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 0, "Undo", $idEditUndo)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 1, "", $idEditSeparator1)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 2, "Cut", $idEditCut)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 3, "Copy", $idEditCopy)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 4, "Paste", $idEditPaste)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 5, "Delete", $idEditDelete)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 6, "Select All", $idEditSelectAll)
_GUICtrlMenu_InsertMenuItem ($hMenuEdit, 7, "Select None", $idEditSelectNone)
;---Images
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditUndo, $hBmpUndo, False)
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditCut, $hBmpCut, False)
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditCopy, $hBmpCopy, False)
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditPaste, $hBmpPaste, False)
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditDelete, $hBmpDelete, False)
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditSelectAll, $hBmpSelectAll, False)
_GUICtrlMenu_SetItemBmp($hMenuEdit, $idEditSelectNone, $hBmpSelectNone, False)

;View Menu
$hMenuView = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMenuView, 0, "as List", $idViewAsList)
_GUICtrlMenu_InsertMenuItem ($hMenuView, 1, "as Banners", $idViewAsBanners)
_GUICtrlMenu_InsertMenuItem ($hMenuView, 2, "", $idViewSeparator1)
_GUICtrlMenu_InsertMenuItem ($hMenuView, 3, "View Options ...", $idViewOptions)
;---Images
_GUICtrlMenu_SetItemBmp($hMenuView, $idViewOptions, $hBmpOptions, False)

;Options Menu
$hMenuOptions = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMenuOptions, 0, "Preferences", $idOptionsPreferences)
;---Images
_GUICtrlMenu_SetItemBmp($hMenuOptions, $idOptionsPreferences, $hBmpOptions, False)

;Help Menu
$hMenuHelp = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMenuHelp, 0, "TV Squirrel Help", $idHelpHelp)
_GUICtrlMenu_InsertMenuItem ($hMenuHelp, 1, "Indroduction", $idHelpIntro)
_GUICtrlMenu_InsertMenuItem ($hMenuHelp, 2, "", $idHelpSeparator1)
_GUICtrlMenu_InsertMenuItem ($hMenuHelp, 3, "About TV Squirrel", $idHelpAbout)
;---Images
_GUICtrlMenu_SetItemBmp($hMenuHelp, $idHelpHelp, $hBmpHelp, False)
_GUICtrlMenu_SetItemBmp($hMenuHelp, $idHelpIntro, $hBmpIntro, False)
_GUICtrlMenu_SetItemBmp($hMenuHelp, $idHelpAbout, $hBmpAbout, False)

; Create Main menu
$hMainMenu = _GUICtrlMenu_CreateMenu ()
_GUICtrlMenu_InsertMenuItem ($hMainMenu, 0, "File", 0, $hMenuFile)
_GUICtrlMenu_InsertMenuItem ($hMenuFile, 4, "Library", 0, $hMenuLibrary)
_GUICtrlMenu_InsertMenuItem ($hMainMenu, 2, "Edit", 0, $hMenuEdit)
_GUICtrlMenu_InsertMenuItem ($hMainMenu, 3, "View", 0, $hMenuView)
_GUICtrlMenu_InsertMenuItem ($hMainMenu, 4, "Options", 0, $hMenuOptions)
_GUICtrlMenu_InsertMenuItem ($hMainMenu, 5, "Help", 0, $hMenuHelp)

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

$hBannerBg = GUICtrlCreatePic(@ScriptDir & "\_Resources\MainTopBg.jpg", 0, 0, $iGuiWidth, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKHCENTER+$GUI_DOCKHEIGHT)
$hBgBottom = GUICtrlCreatePic(@ScriptDir & "\_Resources\MainBotBg.jpg", 0, $iGuiHeight-50, $iGuiWidth, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKHEIGHT)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

My Problem is that the images in the menu Items still have a magenta background instead of it being turned transparent.

Isn't that what "$LR_LOADTRANSPARENT" was supposed to do?

Thanks in advance


[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites
Authenticity

What $LR_LOADTRANSPARENT does with the image is to get the top-left pixel of the image to load, turn each pixel in the image to the following color and that's it:

#include <WinAPI.au3>
#include <WindowsConstants.au3>

$iWndClr = _WinAPI_GetSysColor($COLOR_WINDOW)

which by default is set to white.

LR_LOADTRANSPARENT Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the default window color (COLOR_WINDOW). All pixels in the image that use that entry become the default window color. This value applies only to images that have corresponding color tables. If fuLoad includes both the LR_LOADTRANSPARENT and LR_LOADMAP3DCOLORS values, LRLOADTRANSPARENT takes precedence. However, the color table entry is replaced with COLOR_3DFACE rather than COLOR_window.

You can use _WinAPI_SetLayeredWindowAttributes() to set the transparent pixel in the window. Search the forums.

Share this post


Link to post
Share on other sites
ame1011

This seems to work for making my gui or sections of it transparent, what I'm looking for is to make my bmp images used in my menu transparent.


[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.