Click here to Skip to main content
16,011,680 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: linking erros Pin
Steen Krogsgaard10-Aug-05 22:40
Steen Krogsgaard10-Aug-05 22:40 
GeneralRe: linking erros Pin
Anonymous11-Aug-05 6:25
Anonymous11-Aug-05 6:25 
GeneralRe: linking erros Pin
11-Aug-05 6:38
suss11-Aug-05 6:38 
GeneralRe: linking erros Pin
Steen Krogsgaard11-Aug-05 20:40
Steen Krogsgaard11-Aug-05 20:40 
GeneralRe: linking erros Pin
Anonymous11-Aug-05 2:55
Anonymous11-Aug-05 2:55 
QuestionHow to get the virtual-key code value of the character? Pin
gohappy_19999-Aug-05 20:17
gohappy_19999-Aug-05 20:17 
AnswerRe: How to get the virtual-key code value of the character? Pin
ThatsAlok9-Aug-05 22:49
ThatsAlok9-Aug-05 22:49 
AnswerRe: How to get the virtual-key code value of the character? Pin
Bob Stanneveld10-Aug-05 1:15
Bob Stanneveld10-Aug-05 1:15 
Hello,

I don't think that there is an easy way to do it, but you can always use a map:
<list>
  • Create a separate module create a private map that on initialization maps all virtual key codes to their ASCII (or UNICODE) counterparts.
  • Create a routine that returns the key code for the character passed to it.
    Example:
    // module CharToVKCode
    #include <map>
    
    static std::map<TCHAR, UINT>  g_KeyCodeMap;
    static bool g_bInitialized = false;
    
    static void InitializeKeyCodeMap()
    {
        g_KeyCodeMap.insert(std::make_pair(_T(SomeChar), VK_SomeChar));
        // do this for all virtual key codes
        g_bInitialized = true;
    }
    
    int CharacterToVKCode(TCHAR Char)
    {
        if( !g_bInitialized )
            InitializeKeyCodeMap();
    
        std::map<UINT, TCHAR>::const_iterator ci = g_KeyCodeMap.find(Char);
        if( ci == g_KeyCodeMap.end() ) 
            return -1;
    
        return c_i.second;
    }


    If I remember correctly, the VK_CODES in ASCII builds is the ASCII code of the character. So the VK code for ':' is static_cast<int>(':');. I could be wrong about this though.

    Behind every great black man...
                ... is the police. - Conspiracy brother


    Blog[^]

  • GeneralConverting String *s to int. Pin
    Member 34198919-Aug-05 19:41
    Member 34198919-Aug-05 19:41 
    GeneralRe: Converting String *s to int. Pin
    Kevin McFarlane9-Aug-05 23:08
    Kevin McFarlane9-Aug-05 23:08 
    GeneralRe: Converting String *s to int. Pin
    Member 34198919-Aug-05 23:19
    Member 34198919-Aug-05 23:19 
    GeneralRe: Converting String *s to int. Pin
    toxcct10-Aug-05 1:21
    toxcct10-Aug-05 1:21 
    Generaloverloaded member function Pin
    Member 21610049-Aug-05 17:23
    Member 21610049-Aug-05 17:23 
    GeneralRe: overloaded member function Pin
    Christian Graus9-Aug-05 17:26
    protectorChristian Graus9-Aug-05 17:26 
    GeneralRe: overloaded member function Pin
    Member 21610049-Aug-05 18:14
    Member 21610049-Aug-05 18:14 
    GeneralRe: overloaded member function Pin
    Christian Graus9-Aug-05 18:23
    protectorChristian Graus9-Aug-05 18:23 
    GeneralRe: overloaded member function Pin
    Member 21610049-Aug-05 20:20
    Member 21610049-Aug-05 20:20 
    GeneralRe: overloaded member function Pin
    Christian Graus10-Aug-05 9:57
    protectorChristian Graus10-Aug-05 9:57 
    GeneralRe: overloaded member function Pin
    sunit59-Aug-05 19:24
    sunit59-Aug-05 19:24 
    GeneralRe: overloaded member function Pin
    khan++9-Aug-05 19:54
    khan++9-Aug-05 19:54 
    GeneralRe: overloaded member function Pin
    David Crow10-Aug-05 4:01
    David Crow10-Aug-05 4:01 
    GeneralQuestion about Dialog Pin
    Aqueel9-Aug-05 17:20
    Aqueel9-Aug-05 17:20 
    GeneralRe: Question about Dialog Pin
    Christian Graus9-Aug-05 17:27
    protectorChristian Graus9-Aug-05 17:27 
    GeneralRe: Question about Dialog Pin
    Ravi Bhavnani9-Aug-05 17:52
    professionalRavi Bhavnani9-Aug-05 17:52 
    Generalsystemroot Pin
    namespaceuser9-Aug-05 17:11
    namespaceuser9-Aug-05 17:11 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.