[英]Error C2228 using API
我正在制作黑白棋游戲。 幾乎所有內容都已編碼,我需要運行該程序。 但是,有錯誤 C2228。 我不知道為什么會出現這個錯誤。 在我的代碼中,哪一行有問題?
這是 API 代碼。
#include "Basic.h"
#include "Othello.h"
#include "resource.h"
LRESULT CALLBACK WndProc ( HWND , UINT , WPARAM , LPARAM ) ;
HINSTANCE g_hInst ;
LPCWSTR lpszClass = TEXT ( "First" ) ;
//Tile tile () ;
int APIENTRY WinMain ( HINSTANCE hInstance , HINSTANCE hPrevInstance
, LPSTR lpszCmdParam , int nCmdShow )
{
HWND hWnd ;
MSG Message ;
WNDCLASS WndClass ;
g_hInst = hInstance ;
WndClass.cbClsExtra = 0 ;
WndClass.cbWndExtra = 0 ;
WndClass.hbrBackground = ( HBRUSH ) GetStockObject ( WHITE_BRUSH ) ;
WndClass.hCursor = LoadCursor ( NULL , IDC_ARROW ) ;
WndClass.hIcon = LoadIcon ( NULL , IDI_APPLICATION ) ;
WndClass.hInstance = hInstance ;
WndClass.lpfnWndProc = ( WNDPROC)WndProc ;
WndClass.lpszClassName = lpszClass ;
WndClass.lpszMenuName = NULL ;
WndClass.style = CS_HREDRAW | CS_VREDRAW ;
RegisterClass ( &WndClass ) ;
hWnd = CreateWindow ( lpszClass , lpszClass , WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT ,
NULL , ( HMENU ) NULL , hInstance , NULL ) ;
ShowWindow ( hWnd , nCmdShow ) ;
while ( GetMessage ( &Message , 0 , 0 , 0 ) )
{
TranslateMessage ( &Message ) ;
DispatchMessage ( &Message ) ;
}
return Message.wParam ;
}
LRESULT CALLBACK WndProc ( HWND hWnd , UINT iMessage , WPARAM wParam , LPARAM lParam )
{
HDC hdc , hMemdc [ 3 ] ;
PAINTSTRUCT ps ;
HBITMAP hEmpty , hBlack , hGray ;
BITMAP bit ;
Tile tile () ;
switch(iMessage)
{
case WM_LBUTTONDOWN :
break ;
case WM_PAINT :
hdc = BeginPaint ( hWnd , &ps ) ;
for ( int i = 0 ; i < 3 ; ++i )
{
hMemdc [ i ] = CreateCompatibleDC ( hdc ) ;
}
hEmpty = LoadBitmap ( g_hInst , MAKEINTRESOURCE ( IDB_BITMAP1 ) ) ;
hBlack = LoadBitmap ( g_hInst , MAKEINTRESOURCE ( IDB_BITMAP2 ) ) ;
hGray = LoadBitmap ( g_hInst , MAKEINTRESOURCE ( IDB_BITMAP3 ) ) ;
SelectObject ( hMemdc [ 0 ] , hEmpty ) ;
SelectObject ( hMemdc [ 1 ] , hBlack ) ;
SelectObject ( hMemdc [ 2 ] , hGray ) ;
for ( int j = 0 ; j < 10 ; ++j )
{
for ( int i = 0 ; i < 10 ; ++i )
{
BitBlt ( hdc , 50 * i , 50 * j , 50 , 50 , hMemdc [ tile . iTileinfo ( i , j ) ] , 0 , 0 , SRCCOPY ) ;
}
}
BitBlt ( hdc , 550 , 250 , 50 , 50 , hMemdc [ 2 - ( tile . bTurninfo () ) ] , 0 , 0 , SRCCOPY ) ;
DeleteObject ( hEmpty ) ;
DeleteDC ( hMemdc [ 0 ] ) ;
DeleteObject ( hBlack ) ;
DeleteDC ( hMemdc [ 1 ] ) ;
DeleteObject ( hGray ) ;
DeleteDC ( hMemdc [ 2 ] ) ;
EndPaint ( hWnd , &ps ) ;
break ;
case WM_DESTROY :
PostQuitMessage ( 0 ) ;
return 0 ;
}
return ( DefWindowProc ( hWnd , iMessage , wParam , lParam ) ) ;
}
這是班級代碼。
#include "Othello.h"
Tile :: Tile ()
{
aryRemover = new Remover [ 8 ] ;
for ( int i = 0 ; i < 8 ; ++i )
{
aryRemover [ i ] . iDirection = 0 ;
aryRemover [ i ] . iNum = 0 ;
}
for ( int i = 0 ; i < 10 ; ++i )
{
for ( int j = 0 ; j < 10 ; ++j )
{
iAry [ i ] [ j ] = 0 ;
}
}
iAry [ 4 ] [ 4 ] = 1 ;
iAry [ 4 ] [ 5 ] = 2 ;
iAry [ 5 ] [ 4 ] = 2 ;
iAry [ 5 ] [ 5 ] = 1 ;
bTurn = false ;
iCount = 0 ;
}
Tile :: ~ Tile ()
{
delete [] aryRemover ;
}
void Tile :: Possible ( int iX , int iY )
{
if ( bTurn ) // Player 1
{
long code
}
else // Player 2
{
long code
}
}
void Tile :: Change ( int iX , int iY )
{
if ( bTurn ) // Player 1
{
for ( int i = 0 ; i < iCount ; ++i )
{
switch ( aryRemover [ i ] . iDirection )
{
case 0 :
long code
default :
break ;
}
}
bTurn = false ; // Turn Player 2
iCount = 0 ;
}
else // Player 2
{
for ( int i = 0 ; i < iCount ; ++i )
{
switch ( aryRemover [ i ] . iDirection )
{
case 0 :
long code
default :
break ;
}
}
bTurn = true ; // Turn Player 1
iCount = 0 ;
}
}
int Tile :: iTileinfo ( int iX , int iY )
{
return iAry [ iX ] [ iY ] ;
}
bool Tile :: bTurninfo ()
{
if ( bTurn )
return true ;
else
return false ;
}
void Tile :: Routine ( int iX , int iY )
{
Tile :: Possible ( iX , iY ) ;
Tile :: Change ( iX , iY ) ;
}
和錯誤。
錯誤 C2228:“.bTurninfo”的左側必須有類/結構/聯合。
錯誤 C2228:“.iTileinfo”的左側必須有類/結構/聯合。
問題的代碼在 API 代碼中。
在WM_PAINT
部分,使用Bitblt
函數進行Bitblt
。
我等待你的回復。 祝你有美好的一天 :)
Tile tile () ;
聲明一個函數 tile()。
你要
Tile tile;
它創建了一個平鋪對象
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.