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. hi

hi

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • L Offline
    L Offline
    Lakshmi_p
    wrote on last edited by
    #1

    Hi all, How can i know that the user has pressed ALT+F4 key combination . Thanks in advance.

    B R 2 Replies Last reply
    0
    • L Lakshmi_p

      Hi all, How can i know that the user has pressed ALT+F4 key combination . Thanks in advance.

      B Offline
      B Offline
      baerten
      wrote on last edited by
      #2

      Hi, for example in PreTranslateMessage :

      if (msg->message == WM_KEYDOWN)
      {
      if(msg->wParam == VK_F4 && GetKeyState(VK_LMENU)<0)
      {
      //--> ALT+F4 pressed
      }

      }

      I hope it works ;)

      R L 2 Replies Last reply
      0
      • B baerten

        Hi, for example in PreTranslateMessage :

        if (msg->message == WM_KEYDOWN)
        {
        if(msg->wParam == VK_F4 && GetKeyState(VK_LMENU)<0)
        {
        //--> ALT+F4 pressed
        }

        }

        I hope it works ;)

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        baerten wrote:

        if(msg->wParam == VK_F4 && GetKeyState(VK_LMENU)<0)

        You want it to work only if the Left Alt is pressed? I would rather suggest VK_MENU instead of VK_LMENU. Moreover, I doubt if this would ever work!


        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->ßRÅhmmÃ<-·´¯`·.

        1 Reply Last reply
        0
        • L Lakshmi_p

          Hi all, How can i know that the user has pressed ALT+F4 key combination . Thanks in advance.

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          Handle WM_CLOSE and place the following code in it:

          if(GetKeyState(VK_MENU)<0 && GetKeyState(VK_F4)<0)
          {
          AfxMessageBox("Alt and F4 keys are down!");
          }

          [I am assuming that you're working on a dialog based app and using MFC. Do reply if there's something different]

          1 Reply Last reply
          0
          • B baerten

            Hi, for example in PreTranslateMessage :

            if (msg->message == WM_KEYDOWN)
            {
            if(msg->wParam == VK_F4 && GetKeyState(VK_LMENU)<0)
            {
            //--> ALT+F4 pressed
            }

            }

            I hope it works ;)

            L Offline
            L Offline
            Lakshmi_p
            wrote on last edited by
            #5

            Hi, Its working. Thanks for ur reply:)

            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