Jump to content
Tuts 4 You

Forums

  1. Community Discussions

    1. Terms, Privacy Policy & Frequently Asked Questions   (110,779 visits to this link)

      Very important! Please read before sign up and posting...

    2. General Discussions and Off Topic

      General and off-topic conversations and discussions here...

      9,856
      posts
    3. Artscene Community

      Share graphic, ASCII, module, demo, intro ideas and works...

      7,375
      posts
    4. Site Bug Reports and Feedback

      Bugs, feedback and ideas regarding this site...

      2,022
      posts
  2. Reverse Code Engineering

    1. Challenge of Reverse Engineering

      Try a challenge or contribute your own, any platform or operating system...

      12,767
      posts
    2. Hardware Reverse Engineering

      Reverse engineering of circuitry hardware and firmware...

      145
      posts
    3. Network Security

      Discussions on network security, holes, exploits and other issues...

      422
      posts
    4. Malware Reverse Engineering

      Debugging, disassembling and documenting interesting malware...

      1,376
      posts
    5. Reverse Engineering Articles

      Share an interesting blog, news page or other RE related site...

      1,259
      posts
    6. Employment and Job Vacancies

      Advertise a job or seek an employment opportunity...

      143
      posts
  3. Developers Forums

    1. Programming and Coding

      Programming and coding tips, help and solutions...

      11,177
      posts
    2. Programming Resources

      Share an interesting blog, news page or other resource...

      250
      posts
    3. Software Security

      Securing your software against reverse engineering...

      609
      posts
  4. Community Projects

    1. Scylla Imports Reconstruction

      Development and support forum for the Scylla project...

      473
      posts
    2. x64dbg

      An open-source x64/x32 debugger for windows...

      1,042
      posts
    3. Future Community Projects

      Looking for support and interested partners for a future project?

      124
      posts
    4. Community Projects Archive

      Old and inactive projects moved to long term support...

      792
      posts
  • Posts

    • whoknows
      Opera is a Chromium-based browser IE is a Chromium-based browser Brave is a Chromium-based browser man use the #1 browser, brave ...
    • Teddy Rogers
      I knocked up a quick example, you could do something similar to this... Declare.i WinProc(hWnd, Msg, wParam, lParam) Declare.i SetMenuItemBold(MenuNum) Global hMenu If OpenWindow(0, 0, 0, 250, 100,"Right click in the window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If SetWindowCallback(@WinProc()) hMenu = CreatePopupMenu(0) If hMenu ; Create a text array for the menu item text. Global Dim menutext.s(4) menutext(0) = " MenuItem 0" menutext(1) = " MenuItem 1" menutext(2) = " MenuItem 2" menutext(3) = " End" ; Create the menu items and point to the array containing the text. MenuItem(0, menutext(0)) MenuItem(1, menutext(1)) MenuItem(2, menutext(2)) MenuItem(3, menutext(3)) ; Set menu items to #MFT_OWNERDRAW For a = 0 To 3 With tag.MENUITEMINFO \cbSize = SizeOf(MENUITEMINFO) \fMask = #MIIM_TYPE \fType = #MFT_OWNERDRAW \dwTypeData = @menutext(a) SetMenuItemInfo_(hMenu, a, #True, @tag) EndWith Next EndIf ; PureBasic window event loop. Repeat Event = WaitWindowEvent() Select Event Case #PB_Event_RightClick DisplayPopupMenu(0, WindowID(0)) ; When a menu item is clicked on set it to bold. Case #PB_Event_Menu Select EventMenu() Case 0 : SetMenuItemBold(EventMenu()) Case 1 : SetMenuItemBold(EventMenu()) Case 2 : SetMenuItemBold(EventMenu()) Case 3 : End EndSelect EndSelect Until Event = #PB_Event_CloseWindow EndIf EndIf Procedure.i WinProc(hWnd, Msg, wParam, lParam) Static hbrush Select Msg Case #WM_DESTROY ; Delete created objects once the window is destroyed. DeleteObject_(hbrush) Case #WM_MEASUREITEM ; lParam - Pointer to a MEASUREITEMSTRUCT structure that contains the dimensions of the owner-drawn control or menu item. *lpm.MEASUREITEMSTRUCT = lParam ; Define the width and height for the menu item to be created. *lpm\itemWidth = 200 *lpm\itemHeight = 30 Case #WM_DRAWITEM: ; lParam - Pointer to a DRAWITEMSTRUCT structure containing information about the item to be drawn and the type of drawing required. *lpd.DRAWITEMSTRUCT = lParam ; If a menu item is selected, use #COLOR_MENUHILIGHT. If *lpd\itemState & #ODS_SELECTED hbrush = CreateSolidBrush_(GetSysColor_(#COLOR_MENUHILIGHT)) SelectObject_(*lpd\hDC, hbrush) EndIf ; Set the background mix mode of the specified device context to #TRANSPARENT. ; This sets the text background to #TRANSPARENT (otherwise its background will be filled a different colour from that of the menu). SetBkMode_(*lpd\hDC, #TRANSPARENT) ; Set the device context boundary pen colour, the null pen draws nothing. SelectObject_(*lpd\hDC, GetStockObject_(#NULL_PEN)) ; A rectangle that defines the boundaries of the control to be drawn. ; When drawing menu items, the owner window must not draw outside the boundaries of the rectangle defined by the rcItem member. Rectangle_(*lpd\hDC, *lpd\rcItem\left, *lpd\rcItem\top, *lpd\rcItem\right, *lpd\rcItem\bottom) If menutext(*lpd\itemID) = menutext(1) SetTextColor_(*lpd\hDC, #Green) DrawText_(*lpd\hDC, menutext(*lpd\itemID), -1, @*lpd\rcItem, #Null) ElseIf menutext(*lpd\itemID) = menutext(2) ; Calculate the length of the menu item text. DrawText_(*lpd\hDC, menutext(*lpd\itemID), -1, @*lpd\rcItem, #DT_CALCRECT) ; Set the menu item text colour and then draw it. SetTextColor_(*lpd\hDC, #Blue) DrawText_(*lpd\hDC, menutext(*lpd\itemID), -1, @*lpd\rcItem, #Null) ; Save the old right co-ordinate so we can offset the additional menu item text. oldRight = *lpd\rcItem\right ; Calculate the length of the additional menu item text. DrawText_(*lpd\hDC, " Tuts4You", -1, @*lpd\rcItem, #DT_CALCRECT) ; Calculate the offset to add the new text in the menu. *lpd\rcItem\left = oldRight *lpd\rcItem\right + oldRight ; Set the menu item text colour and then draw it. SetTextColor_(*lpd\hDC, #Red) DrawText_(*lpd\hDC, " Tuts4You", -1, @*lpd\rcItem, #Null) Else DrawText_(*lpd\hDC, menutext(*lpd\itemID), -1, @*lpd\rcItem, #Null) EndIf EndSelect ProcedureReturn #PB_ProcessPureBasicEvents EndProcedure Procedure SetMenuItemBold(hMenuNumSel) bold.MENUITEMINFO bold\cbSize = SizeOf(bold) bold\fMask = #MIIM_STATE bold\fState = #MFS_DEFAULT SetMenuItemInfo_(hMenu, hMenuNumSel, #True, bold) EndProcedure Ted. Coloured Menu Item.exe
    • LCF-AT
      Hi again, ok thanks again for the info.I have test it now with TextOut and ExtTextOut + new color function and it seems to work. Now I got a small another problem to receive WM_DRAWITEM and WM_MEASUREITEM messages.So in my case I did create a contextmenu by button press and not via right mouse.How to handle this problem now to get triggered at the 2 messages? greetz
  • Popular Contributors

    1. 1
      CodeExplorer
      CodeExplorer
      16
    2. 2
      Teddy Rogers
      Teddy Rogers
      6
    3. 3
      Rextor
      Rextor
      4
    4. 4
      Progman
      Progman
      2
    5. 5
      3dsboy08
      3dsboy08
      2
  • Member Statistics

    • Total Members
      11,845
    • Most Online
      619

    sparsh
    Newest Member
    sparsh
    Joined
×
×
  • Create New...