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. General Programming
  3. C / C++ / MFC
  4. How to achieve pushbutton type effect using bitmaps

How to achieve pushbutton type effect using bitmaps

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicstutorial
2 Posts 2 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.
  • S Offline
    S Offline
    sayonee
    wrote on last edited by
    #1

    Hello there I have a issue related to the usage of the bitmap enabled Dialog window.I have created a keyboard type layout and i wish to get the input through keyboard also.When i use the mouse I am able to get the button(s) pressed and also all the buttons are working fine - the other images DEFAULT,SELECTED,DISABLED ..all get loaded and work since I am using the function here m_BtnBtn1Ctrl.LoadBitmaps ,But then any key pressed on keyboard and the corresponding character on the screen isn't able to do the same as I have been able to do it with clicking of the mouse(and using the Loadbitmaps() function ). I am using these 3 functions to achieve the same action and effect as that using a mouse LoadBitmap() SetBitmap() Invalidate() I also tried this piece of code HBITMAP hbm = (HBITMAP)LoadImage(NULL, "\\res\\Selected\\bitmap21.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); and bitmap.Attach((HBITMAP)LoadImage(NULL, "\\res\\Selected\\bitmap21.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION)); but these don't seem to give the pressed button effect though internally they work.Can some one please help me with this Thanks and regards Sayonee ====RELATED CODING PART========== BOOL KeyBoard_press::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class CString strTemp; if (pMsg->message == WM_KEYDOWN) { if ( pMsg->wParam == 0x41 || pMsg->wParam == 0x61) //check for both 'a' and 'A' OnBtnBtn1(); if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_DELETE || pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_TAB || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || GetKeyState (VK_CONTROL)) { ::TranslateMessage (pMsg); ::DispatchMessage (pMsg); return TRUE; // DO NOT process further } } return CDialog::PreTranslateMessage(pMsg); }

    S 1 Reply Last reply
    0
    • S sayonee

      Hello there I have a issue related to the usage of the bitmap enabled Dialog window.I have created a keyboard type layout and i wish to get the input through keyboard also.When i use the mouse I am able to get the button(s) pressed and also all the buttons are working fine - the other images DEFAULT,SELECTED,DISABLED ..all get loaded and work since I am using the function here m_BtnBtn1Ctrl.LoadBitmaps ,But then any key pressed on keyboard and the corresponding character on the screen isn't able to do the same as I have been able to do it with clicking of the mouse(and using the Loadbitmaps() function ). I am using these 3 functions to achieve the same action and effect as that using a mouse LoadBitmap() SetBitmap() Invalidate() I also tried this piece of code HBITMAP hbm = (HBITMAP)LoadImage(NULL, "\\res\\Selected\\bitmap21.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); and bitmap.Attach((HBITMAP)LoadImage(NULL, "\\res\\Selected\\bitmap21.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION)); but these don't seem to give the pressed button effect though internally they work.Can some one please help me with this Thanks and regards Sayonee ====RELATED CODING PART========== BOOL KeyBoard_press::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class CString strTemp; if (pMsg->message == WM_KEYDOWN) { if ( pMsg->wParam == 0x41 || pMsg->wParam == 0x61) //check for both 'a' and 'A' OnBtnBtn1(); if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_DELETE || pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_TAB || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || GetKeyState (VK_CONTROL)) { ::TranslateMessage (pMsg); ::DispatchMessage (pMsg); return TRUE; // DO NOT process further } } return CDialog::PreTranslateMessage(pMsg); }

      S Offline
      S Offline
      Sauro Viti
      wrote on last edited by
      #2

      This is the third time that you post this question on this forum, and you posted it aloso in the Q&A. I suggest you to make your question too clear, rather than insisting in post it as is. And again, if something on an answer is not clear, add a comment to that answer: who wrote it probably could add more explainations.

      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