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. abt Alt+keys

abt Alt+keys

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionannouncement
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.
  • T Offline
    T Offline
    Tripura K
    wrote on last edited by
    #1

    hello all what code do i need to write in MFC in order to check if the user has clicked alt key on the key board and how can i implement Alt+F4 fuction when the user clickes alt button on the key board and button(with caption F4) which is on my dialog box which is created in an SDI application my alt and F4 button on the dialogbox has the following code in the fuction void MyDialog::OnButtonalt1() { flag=1; if( ( (WM_KEYDOWN||WM_SYSKEYDOWN) && (0x8000 ==(0x8000 & GetKeyState(18)) ) ) ) { MessageBox("in Alt"); } /*if( (WM_KEYDOWN && !GetKeyState(18)) && caps) { Invalidate(); } BYTE keyState[256]; GetKeyboardState((LPBYTE)&keyState); if( (TRUE && !(keyState[115] & 1))||(!FALSE && (keyState[115] & 1)) ) { // Simulate a key press keybd_event( 38,0x45,KEYEVENTF_EXTENDEDKEY|0,0); // Simulate a key release keybd_event(38,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0); } */ } void MyDialog::OnButtonF4() { int i = GetKeyState(115); if(i) { MessageBox("In F4"); } } Request to all to continue this

    R A 2 Replies Last reply
    0
    • T Tripura K

      hello all what code do i need to write in MFC in order to check if the user has clicked alt key on the key board and how can i implement Alt+F4 fuction when the user clickes alt button on the key board and button(with caption F4) which is on my dialog box which is created in an SDI application my alt and F4 button on the dialogbox has the following code in the fuction void MyDialog::OnButtonalt1() { flag=1; if( ( (WM_KEYDOWN||WM_SYSKEYDOWN) && (0x8000 ==(0x8000 & GetKeyState(18)) ) ) ) { MessageBox("in Alt"); } /*if( (WM_KEYDOWN && !GetKeyState(18)) && caps) { Invalidate(); } BYTE keyState[256]; GetKeyboardState((LPBYTE)&keyState); if( (TRUE && !(keyState[115] & 1))||(!FALSE && (keyState[115] & 1)) ) { // Simulate a key press keybd_event( 38,0x45,KEYEVENTF_EXTENDEDKEY|0,0); // Simulate a key release keybd_event(38,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0); } */ } void MyDialog::OnButtonF4() { int i = GetKeyState(115); if(i) { MessageBox("In F4"); } } Request to all to continue this

      R Offline
      R Offline
      rabih_kai
      wrote on last edited by
      #2

      Dear u have done it, but you can't call WM_KEYDOWN ||WM_SYSKEYDOWN from inside a command, i do believe that you have to overload it as a seperate function inside that dialog, try it and it will work... Enjoy. Rabih

      1 Reply Last reply
      0
      • T Tripura K

        hello all what code do i need to write in MFC in order to check if the user has clicked alt key on the key board and how can i implement Alt+F4 fuction when the user clickes alt button on the key board and button(with caption F4) which is on my dialog box which is created in an SDI application my alt and F4 button on the dialogbox has the following code in the fuction void MyDialog::OnButtonalt1() { flag=1; if( ( (WM_KEYDOWN||WM_SYSKEYDOWN) && (0x8000 ==(0x8000 & GetKeyState(18)) ) ) ) { MessageBox("in Alt"); } /*if( (WM_KEYDOWN && !GetKeyState(18)) && caps) { Invalidate(); } BYTE keyState[256]; GetKeyboardState((LPBYTE)&keyState); if( (TRUE && !(keyState[115] & 1))||(!FALSE && (keyState[115] & 1)) ) { // Simulate a key press keybd_event( 38,0x45,KEYEVENTF_EXTENDEDKEY|0,0); // Simulate a key release keybd_event(38,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0); } */ } void MyDialog::OnButtonF4() { int i = GetKeyState(115); if(i) { MessageBox("In F4"); } } Request to all to continue this

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        override virtual BOOL PreTranslateMessage( MSG* pMsg ) BOOL CMyDialog::PreTranslateMessage( MSG* pMsg ) { if(pMsg->message == WM_SYSKEYDOWN) { //Check for F4 && Do Something } return CDialog:: PreTranslateMessage(pMsg); }

        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