Results 1 to 5 of 5

Thread: detect focus

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Question detect focus

    Code:
    case WM_COMMAND:
    		switch(wParam)
    		{
    		case EN_SETFOCUS:
    			MessageBox(NULL,"Edit box has focus", "Focus",MB_OK);
    		}
    I am trying to detect when my editbox has gained focus. Im not sure about the switch statement. Also what is a HIWORD and LOWORD? Thanks
    Matt

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    What are you not sure about with the switch statements?

    HIWORD is the high WORD of a double word (DWORD) type. WORD is 16 bits, and DWORD is 32-bits. If you imagine it in binary, the high word is the left 16 bits, and the low word is the right 16 bits.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Is the code working? Here is info on the EN_SETFOCUS message
    Code:
    EN_SETFOCUS
    The EN_SETFOCUS notification message is sent when an edit control receives the keyboard focus. The parent window of the edit control receives this notification message through the WM_COMMAND message. 
    
    EN_SETFOCUS 
    idEditCtrl = (int) LOWORD(wParam); // identifier of edit control 
    wNotifyCode = HIWORD(wParam);      // notification code 
    hwndEditCtrl = (HWND) lParam;      // handle of edit control
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    no the code doesn't work. Im not sure about the first part of the switch statement

    Code:
    switch(wParam)
    What should go where wParam is? Right now when I click in the edit box nothing happens.
    Matt

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I think it's meant to be HIWORD(wParam)
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width