2011-11-08 6 views
1

何らかの理由で、私はAdjustWindowRectまたはGetClientRectを呼び出しようとしています。私はWinAPI関数への呼び出しに関係しない、約30のエラーが発生します。複数のWinAPI関数を呼び出すと約30のエラーが発生する

何が原因でしょうか?例えば

おかげ

次のコード:

case WM_GETMINMAXINFO: 
      { 
       LPMINMAXINFO p_info = (LPMINMAXINFO)lParam; 
       RECT rc = {0,0,d->w,d->h}; 
       DWORD dwStyle = GetWindowLongPtr(hWnd, GWL_STYLE) ; 
       AdjustWindowRect(&rc,dwStyle,FALSE); 
       int total_border_width = 2 * GetSystemMetrics(SM_CXFRAME) + 4; 
       int total_border_height = 2 * GetSystemMetrics(SM_CYFRAME) + 
       GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER) + 5; 
       POINT min,max; 

       min.x = d->min_w > 0 ? d->min_w + total_border_width : p_info->ptMinTrackSize.x; 
       min.y = d->min_h > 0 ? d->min_h + total_border_height : p_info->ptMinTrackSize.y; 
       max.x = d->max_w > 0 ? d->max_w + total_border_width : p_info->ptMaxTrackSize.x; 
       max.y = d->max_h > 0 ? d->max_h + total_border_height : p_info->ptMaxTrackSize.y; 

       p_info->ptMinTrackSize = min; 
       p_info->ptMaxTrackSize = max; 
      } 

が生成されます

Error 6 error C2065: 'max' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 844 
Error 13 error C2065: 'max' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 848 
Error 16 error C2065: 'max' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 849 
Error 21 error C2065: 'max' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 852 
Error 5 error C2065: 'min' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 844 
Error 7 error C2065: 'min' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 846 
Error 10 error C2065: 'min' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 847 
Error 19 error C2065: 'min' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 851 
Error 12 error C2065: 'total_border_height' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 847 
Error 18 error C2065: 'total_border_height' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 849 
Error 9 error C2065: 'total_border_width' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 846 
Error 15 error C2065: 'total_border_width' : undeclared identifier c:\Users\Josh\Documents\AL51\src\win\wwindow.c 848 
Error 1 error C2143: syntax error : missing ';' before 'type' c:\Users\Josh\Documents\AL51\src\win\wwindow.c 841 
Error 2 error C2143: syntax error : missing ';' before 'type' c:\Users\Josh\Documents\AL51\src\win\wwindow.c 842 
Error 4 error C2146: syntax error : missing ';' before identifier 'min' c:\Users\Josh\Documents\AL51\src\win\wwindow.c 844 
Error 8 error C2224: left of '.x' must have struct/union type c:\Users\Josh\Documents\AL51\src\win\wwindow.c 846 
Error 14 error C2224: left of '.x' must have struct/union type c:\Users\Josh\Documents\AL51\src\win\wwindow.c 848 
Error 11 error C2224: left of '.y' must have struct/union type c:\Users\Josh\Documents\AL51\src\win\wwindow.c 847 
Error 17 error C2224: left of '.y' must have struct/union type c:\Users\Josh\Documents\AL51\src\win\wwindow.c 849 
Error 3 error C2275: 'POINT' : illegal use of this type as an expression c:\Users\Josh\Documents\AL51\src\win\wwindow.c 844 
Error 20 error C2440: '=' : cannot convert from 'int' to 'POINT' c:\Users\Josh\Documents\AL51\src\win\wwindow.c 851 
Error 22 error C2440: '=' : cannot convert from 'int' to 'POINT' c:\Users\Josh\Documents\AL51\src\win\wwindow.c 852 
+0

このコードは.cファイルまたは.cppの一部ですか? –

+0

これはcファイルの一部です – jmasterx

+0

次に、James McNellisが以下に示すように、すべての変数宣言をブロックの先頭に移動する必要があります。 –

答えて

2

をビジュアルC++のみC90(ないC99)をサポートしているため、コンパイルするときCプログラムでは、すべての変数宣言をブロックの先頭に置く必要があります。 atements。

min,max,total_border_heightおよびtotal_border_widthの宣言はすべて、ブロック内の少なくとも1つのステートメントの後に来ます。

+0

いいえ、AdjustRectやその他のwinapi関数を単純に削除して魅力的なように構築しましたが、minとmax、no noという名前も付けました。 – jmasterx

関連する問題