Thread: Code needed

  1. #1
    Registered User PanzTec's Avatar
    Join Date
    Sep 2004
    Posts
    24

    Code needed

    ok... iv made a program with a switch that has a char like this

    PHP Code:
    char k[128]// one byte
    switch(k)
    {
    case 
    "help":
    {
    //print something
    }break;
    default:
    {
    //do something
    }break;

    but i need to make it so that I can send a msg to a switch with out it being a char(as it only does int) and carry out a function kinder like the following code
    PHP Code:
    LRESULT CALLBACK WindowProc(HWND hwnd,
                                
    UINT msg,
                                
    WPARAM wparam,
                                
    LPARAM lparam)
    {
        
    PAINTSTRUCT ps;
        
    HDC         hdc;

        switch(
    msg)
        {
        case 
    WM_CREATE:
            {
                                     return(
    0);
                                    }break;

        case 
    WM_PAINT:
            {
            
    // simply validate the window
            
    hdc BeginPaint(hwnd,&ps);     
            

            
    EndPaint(hwnd,&ps);

            
    // return success
            
    return(0);
               } break;
        case 
    WM_CHAR:
            {
                
    int ascii_code wparam;
                
    int Key_state =lparam;
                
    #define ESC_STATE 0x10001
                
    if(Key_state ESC_STATE)
                {
                    
    msg WM_CLOSE;
                }
            }
        case 
    WM_DESTROY:
            {

                
    PostQuitMessage(0);//quiting the program

                
    return(0);
            }break;
        return(
    DefWindowProc(hwndmsgwparamlparam));


    Last edited by PanzTec; 11-13-2004 at 05:56 AM.
    The Matrix Will Live Again!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can't use strings with a switch. And your array, yeah, that's not "one byte". switches work off integers. Anything integeral is allowed as a value for a switch.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User PanzTec's Avatar
    Join Date
    Sep 2004
    Posts
    24
    my AIE instructer told me a array that was 128 long was = to one byte..... if u wanna know what the AIE is look here http://aie.act.edu.au/ but anyway. i know char's cant be used in a switch i just wanna know how in my second bit of code i can type msg = WM_CLOSE and it to work and what type the msg is or its struct of UINT. I just wanna know how i can type in help and for me to only type in the switch case help: if u get what i mean
    Last edited by PanzTec; 11-13-2004 at 05:57 AM.
    The Matrix Will Live Again!

  4. #4
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    if you mean you wanna send message to your window procedure,why not use "SendMessage()"

    Code:
    SendMessage(hwnd,MS_CHAR,WPARAM,LPARAM);
    hope it is what you need.

    blow me ... ...

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    You can use an STL map from strings to UINTs to accomplish what you want effectively (if I understand you).
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help needed with simple code
    By Branka in forum C++ Programming
    Replies: 1
    Last Post: 08-17-2005, 10:25 AM
  2. Help needed w/ line of code..Thanks!
    By aspand in forum C Programming
    Replies: 7
    Last Post: 05-30-2002, 04:12 PM
  3. Help Needed W/ Code..please!!
    By aspand in forum C Programming
    Replies: 3
    Last Post: 05-28-2002, 02:51 PM
  4. Replies: 4
    Last Post: 01-16-2002, 12:04 AM