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. Problem with a button in an SDI application

Problem with a button in an SDI application

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
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.
  • E Offline
    E Offline
    Eikthrynir
    wrote on last edited by
    #1

    Hi! I have a problem with a button I have created dynamically in an SDI application in MFC. Its purpose is to terminate the application (an Exit button). It works perfectly when I click on it, but what I want to do is make it close my application when I press the Enter key. It just doesn't work, even though the button has focus. It works when I have a dialog based application, but I'm not interested in that. I want it to be an SDI application. A solution I have found is to close the application by calling PostQuitMessage method when I press the Enter key and my button has focus, but I'm interested in a more simple and elegant way if possible. Any ideas would be greatly apreciated! Thanks in advance!

    P 1 Reply Last reply
    0
    • E Eikthrynir

      Hi! I have a problem with a button I have created dynamically in an SDI application in MFC. Its purpose is to terminate the application (an Exit button). It works perfectly when I click on it, but what I want to do is make it close my application when I press the Enter key. It just doesn't work, even though the button has focus. It works when I have a dialog based application, but I'm not interested in that. I want it to be an SDI application. A solution I have found is to close the application by calling PostQuitMessage method when I press the Enter key and my button has focus, but I'm interested in a more simple and elegant way if possible. Any ideas would be greatly apreciated! Thanks in advance!

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      One way is, make that button of type CMyButton, derived from CButton, handle WM_KEYDOWN message. -- modified at 3:00 Friday 1st September, 2006

      Prasad Notifier using ATL

      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