Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Button with Image

Button with Image

Scheduled Pinned Locked Moved Mobile
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    camasmartin
    wrote on last edited by
    #1

    Is it possible to create a button with an image? Or to simualate one? How? Any suggestions appreciated. camasmartin hobby programmer

    D U 2 Replies Last reply
    0
    • C camasmartin

      Is it possible to create a button with an image? Or to simualate one? How? Any suggestions appreciated. camasmartin hobby programmer

      D Offline
      D Offline
      Daniel Strigl
      wrote on last edited by
      #2

      Yes, take a look at CCeButtonST v1.2. Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)

      1 Reply Last reply
      0
      • C camasmartin

        Is it possible to create a button with an image? Or to simualate one? How? Any suggestions appreciated. camasmartin hobby programmer

        U Offline
        U Offline
        User 1083172
        wrote on last edited by
        #3

        1., In resource editor|Push Button Properties|Styles tab check in: "Owner draw" 2., In dialog message handler insert this branch: switch (message) { case WM_DRAWITEM: idCtl = (UINT) wParam; if(idCtl == IDC_BUTTON) DrawFancyButton ( (LPDRAWITEMSTRUCT) lParam, hDlg, IDC_BUTTON, IDB_BITMAP_NORMAL, IDB_BITMAP_PRESSED ); return TRUE; ... 3., Implement DrawFancyButton: void DrawFancyButton(LPDRAWITEMSTRUCT lpdis, HWND hDlg, int idCtl, int iNormalBmp, int iPressedBmp) { TCHAR ButtonText[64]; HBITMAP BitMap; RECT ButtRect; int UpSideColor, DownSideColor; HDC hdcBmp = CreateCompatibleDC(NULL); if(!(lpdis->itemState & ODS_SELECTED)) // Draw Pushed { BitMap = LoadBitmap( g_hInst, MAKEINTRESOURCE(iNormalBmp)); UpSideColor=196, DownSideColor=0; } else // Laposat rajzolok { BitMap = LoadBitmap( g_hInst, MAKEINTRESOURCE(iPressedBmp)); UpSideColor=0, DownSideColor=196; } SelectObject(hdcBmp, BitMap); BITMAP bm; GetObject(BitMap, sizeof(bm), &bm); StretchBlt ( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, lpdis->rcItem.right - lpdis->rcItem.left, lpdis->rcItem.bottom - lpdis->rcItem.top, hdcBmp, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY ); DeleteDC(hdcBmp); if(1) // We want original text also { SetBkMode(lpdis->hDC,TRANSPARENT); GetDlgItemText(hDlg,idCtl,ButtonText,64); ButtRect = lpdis->rcItem; SetTextColor(lpdis->hDC,RGB(UpSideColor, UpSideColor, UpSideColor)); DrawText(lpdis->hDC,ButtonText,-1,&ButtRect,DT_NOCLIP|DT_CENTER|DT_VCENTER); ButtRect.bottom--; ButtRect.left--; ButtRect.right--; ButtRect.top--; SetTextColor(lpdis->hDC,RGB(DownSideColor, DownSideColor, DownSideColor)); DrawText(lpdis->hDC,ButtonText,-1,&ButtRect,DT_NOCLIP|DT_CENTER|DT_VCENTER); } }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups