Results 1 to 7 of 7

Thread: VB6 - X3Button

Threaded View

  1. #1

    Thread Starter
    Addicted Member Xiphias3's Avatar
    Join Date
    Jan 2009
    Location
    Clarendon, Jamaica
    Posts
    188

    Cool VB6 - X3Button

    Here's a command button user control. It's in the finalizing stage but if anyone is interested you can check out the code. It seems to be waaaaaaaayyy more stable when compiled than when in IDE.
    Thanks to Eduardo (olelib.tlb), TheScrams.com (Tooltip class), LaVolpe and Steve McMahon (graphics) and people on forums like this. Goodnight.

    X3BMenu:
    vb Code:
    1. Private WithEvents m As X3BMenu
    2.  
    3. Private Sub m_drawItem(ByVal lpDrawItemStruct As Long)
    4.     Dim d As DRAWITEMSTRUCT, szTxt As String, hGraphics As Long, tp As X3TextPrinter
    5.  
    6.     Call m.fillDrawItemStruct(VarPtr(d), lpDrawItemStruct)
    7.     szTxt = m.getMenuItemText(d.CtlID)
    8.  
    9.     Set tp = New X3TextPrinter
    10.     Call tp.setText(szTxt)
    11.     Call tp.setAlignment(EHAlignment.HCenter, EVAlignment.VCenter)
    12.     Call tp.setFont("Tahoma", 15, tp.getFontFlags(m.hasState(d.itemState, ODS_SELECTED), m.hasState(d.itemState, ODS_SELECTED), False, False))
    13.     Call tp.setLayoutRect(d.rcItem.Left, d.rcItem.Top, (d.rcItem.Right - d.rcItem.Left), (d.rcItem.Bottom - d.rcItem.Top))
    14.     Call tp.setOutlineEffect(&HFF0000FF, 190, 3)
    15.     Call tp.setTextColor(&HFFFFFFFF)
    16.  
    17.     hGraphics = mUtil.getGraphicsContext(d.hdc)
    18.     Call mUtil.setAAGraphicsSmoothingMode(hGraphics)
    19.     Call mUtil.fillRectGDIP(hGraphics, &HFFFFFFFF, tp.DestX, tp.DestY, tp.DestW, tp.DestH)
    20.     Call tp.printText(hGraphics)
    21.     Call mUtil.deleteGraphicsContext(hGraphics)
    22. End Sub
    23.  
    24. Private Sub m_measureItem(lW As Long, lH As Long, ByVal lData As Long, ByVal nID As Integer)
    25.     lH = 20
    26.     lW = (X3Button1.Width \ Screen.TwipsPerPixelX)
    27. End Sub
    28.  
    29. Private Sub X3Button1_click(sX As Single, sY As Single)
    30.     Dim i As X3BIcon
    31.  
    32.     Set m = New X3BMenu
    33.     Set i = New X3BIcon
    34.  
    35.     Call i.loadIcon("d:\Programming\X3 Battlefield IRC\alpha.png")
    36.     Call m.setMenuItemText("Xiphias3", "Desolator", "\-", "Cancel")
    37.     Call m.setCheckmarkIcons(i, i, , i)
    38.     Call m.createMenu
    39.     Call m.setMenuItemChecked(0, True)
    40.     Call m.setMenuItemOwnerDrawStatus(1, True)
    41.     Call m.showMenu(X3Button1.hWnd, ALIGN_RIGHT)
    42. End Sub
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Hack; Jan 8th, 2010 at 07:19 AM. Reason: Removed Compiled Code From Attachment

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width