English
Source / code snippets

Icon Menu Menuitem Ownerdraw Popupmenu

 
OwnerDraw PopupMenu integrally simply:

Download
CompileMarkSeparation
 {$cleq}
cls
popup "Hallo"
appendMenu 100,"Welt"
appendMenu 200,"Welt"
appendMenu 300,"Welt"
appendMenu 400,"Welt"
appendMenu 500,"Welt"
Var hIcon1& = @create("hIcon", "Icon_Test.dll", 0)
Var hIcon2& = @create("hIcon", "Icon_Test.dll", 1)
Var hIcon3& = @create("hIcon", "Icon_Test.dll", 2)
setWindowLong(hWnd,gwl_userData,setWindowLong(hWnd,gwl_wndProc,procaddr(hWnd.wndProc,4)))
modifyMenu(&hMenu,200,MF_BYCOMMAND | MF_OWNERDRAW,200,hIcon1&)
modifyMenu(&hMenu,300,MF_BYCOMMAND | MF_OWNERDRAW,300,hIcon2&)
modifyMenu(&hMenu,400,MF_BYCOMMAND | MF_OWNERDRAW,300,hIcon3&)

while 1

    waitinput

wend

end

nProc hWnd.wndProc

    Parameters wnd&,msg&,wp&,lp&

    if msg&==WM_MEASUREITEM

        return 1

    elseif msg&==WM_DRAWITEM

        if long(lp&,0)==ODT_MENU

            var dc&=long(lp&,24)
            setTextColor(dc&,iff(long(lp&,16)==257,$FF0000,$0000FF))
            SetBkMode(dc&,TRANSPARENT)
            selectObject(dc&,createPen(PS_SOLID,0,iff(long(lp&,16)==257,$777777,$CCCCCC)))
            selectObject(dc&,CreateSolidBrush(iff(long(lp&,16)==257,$AAAAAA,$DDDDDD)))
            Rectangle(dc&,Long(lp&,28),Long(lp&,32),Long(lp&,36),Long(lp&,40))
            drawText(dc&,GetSystemMetrics(71)+4,Long(lp&,32),"Test")
            drawIconEx(dc&,Long(lp&,28),Long(lp&,32),long(lp&,44),16,16,0,0,3)

        endif

        return 1

    endif

    return callWindowProc(getWindowLong(wnd&,gwl_userData),wnd&,msg&,wp&,lp&)

endproc




emerged from: Bitmaps in the Menu: [...] 
 
10/11/10  
 



Nochmal rather & chicker:
CompileMarkSeparation
 {$cleq}
cls
popup "Hallo"
appendODMenuItem(100,"Hallo",0)
appendODMenuItem(200,"Welt",create("hIcon", "A"))
appendODMenuItem(300,"Hallo",create("hIcon", "PROFAN"))
appendODMenuItem(400,"Welt",create("hIcon", "BAUM"))
appendODMenuItem(500,"Hallo",create("hIcon", "WASSER"))
appendODMenuItem(600,"Welt",create("hIcon", "A"))
appendODMenuItem(700,"Hallo",0)
setWindowLong(hWnd,gwl_userData,setWindowLong(hWnd,gwl_wndProc,procaddr(hWnd.wndProc,4)))

while 1

    waitinput

wend

end

nProc hWnd.wndProc

    Parameters wnd&,msg&,wp&,lp&

    if msg&==WM_MEASUREITEM

        long lp&,12=100,GetSystemMetrics(SM_CYMENUSIZE)+3
        return 1

    elseif msg&==WM_DRAWITEM

        if long(lp&,0)==ODT_MENU

            var itm&=long(lp&,20)
            var dc&=long(lp&,24)
            SetBkMode(dc&,TRANSPARENT)

            if long(lp&,16)==257

                selectObject(dc&,createPen(PS_SOLID,0,$555555))
                selectObject(dc&,CreateSolidBrush($FF9933))
                setTextColor(dc&,$FFFFFF)

            elseif long(lp&,16)==256

                selectObject(dc&,createPen(PS_SOLID,0,getSysColor(COLOR_MENU)))
                selectObject(dc&,CreateSolidBrush(getSysColor(COLOR_MENU)))
                setTextColor(dc&,0)

            endif

            var txt&=dim(101)
            getMenuString(getMenu(hWnd),long(lp&,8),txt&,100,0)
            Rectangle(dc&,Long(lp&,28),Long(lp&,32),Long(lp&,36),Long(lp&,40))
            drawText(dc&,GetSystemMetrics(71)+8,Long(lp&,32)+3,string$(txt&,0))
            drawIconEx(dc&,Long(lp&,28)+2,Long(lp&,32)+3,long(lp&,44),16,16,0,0,3)
            dispose(txt&)

        endif

        return 1

    endif

    return callWindowProc(getWindowLong(wnd&,gwl_userData),wnd&,msg&,wp&,lp&)

endproc

proc appendODMenuItem

    parameters itm&,txt$,icn&
    appendMenu itm&,txt$
    modifyMenu(&hMenu,itm&,MF_BYCOMMAND | MF_OWNERDRAW,itm&,icn&)

<
s=s4 href='./../../Function-References/XProfan/endproc/'>endproc


8 kB
Hochgeladen:10/11/10
Downloadcounter214
Download
 
10/11/10  
 




E.T.

XProfan 11.2.1.8a.63 Praekompiler [XPSE]
copyright (C) 1998-2010 XProfan.com, built DE.

File: c:documents and Settings....prf (38)
Objektcode: POLINK: warning: Unrecognized keyword '_MIT_ICON_A
US_DLL' in module-definition file 'C:DOKUME~1MARIODESKTOPM
ENMIT~1.EXT'; ignored.
Creating object: MEN.EXP
Creating library: MEN.LIB

warning: Error in the Assembler Linker

[C ]ompile [I ]nterpr [L ]ink [R ]unPrc Run[E ]xe [s ]ource [H ]ilfe

XPSE:>
 
Grüße aus Sachsen... Mario
WinXP, Win7 (64 Bit),Win8(.1),Win10, Win 11, Profan 6 - X4, XPSE, und 'nen schwarzes, blinkendes Dingens, wo ich das alles reinschütte...
10/12/10  
 



I type time the way and/ or Dateiname, whom You for XPrf give away have, Umlaute and/ or Freizeichen contains - so can the externe Linker not bypass.

In subesquent versions of XPSE try I way and Dateiname for Linker "egal" his To let.

my hint: C:\dev\englishNamedProjectName\englishNamedSourceFileName.xprf
 
10/12/10  
 




E.T.
Well then warens probably the space, which me here "Lehrzeichen" staid having.
but again what learnt...
 
Grüße aus Sachsen... Mario
WinXP, Win7 (64 Bit),Win8(.1),Win10, Win 11, Profan 6 - X4, XPSE, und 'nen schwarzes, blinkendes Dingens, wo ich das alles reinschütte...
10/12/10  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

7.239 Views

Themeninformationen

this Topic has 2 subscriber:

iF (3x)
E.T. (2x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie