http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

win32 question



Hi,
    I'v learned WIN32 API programming for 3 days,now i meet with a question,wish somebody can give me a hand.
    When I wirte some code in message procedure(or something like this),just like following:
switch(message){
    case WM_ABC:...
    case WM_DEF:...
    .
    .
    .
}
why can't I declar varibles such as: TCHAR * lpStr=TEXT("abc") under these cases,just like following:
switch(message){
    case WM_ABC:TCHAR * lpStr=TEXT("abc"); /* error line */
                hdc=GetDC(hwnd);
                TextOut(hdc,0,0,lpStr,lstrlen(lpStr));
                ReleaseDC(hwnd,hdc);
                return 0;
    case WM_CDE:...
    .
    .
    .
}
if I do this code,compiler will occur errors,BUT when I move /* error line */up,just below LRESULT CALLBACK WndProc(...){
the program works well.But why?Can somebody tell me.THX
 
chris tj