VC++ 6.0 API MFC 数独游戏源程序代码

VC++ 6.0 API MFC 数独游戏源程序代码


2024年5月7日发(作者:ps手机破解版下载中文版)

本程序是基于API技术,用VC++ 6.0 MFC开发工具编写的,实现了数独小游戏。

以下为全部源程序代码。

//written by luweikang// : Defines the entry point for the application.

//finished 2010-06-20

#include

#include "stdafx.h"

#include

#include

#define tPaint 2 //重绘定时器的标识(编号)

#define tPaintTime 50 //窗口重绘的时间间隔

#define ROW 9 //方格的行数与列数

#define COL 9 //方格的行数与列数

#define LEN 40 //每个方格大小为40×40像素

#define StartY 3 //

#define StartX 3 //绘制方格地图时的边界起始位置

int CurrentX=0;

int CurrentY=0; //当前操作位置

void InitMap_show( ); //初始化地图

int value[ROW][COL]; //记录每个方格中的数字

void Initvalue( ); //初始化方格中的数字为0

int judge(); //判断当前位置是否能输入用户想要输入的数字

void random(); //实现随机生成整张地图上的数字

int change[9][9]; //用于记录各个位置的数字是否可改变,0不可变,1可变

void Initchange(); //初始化change数组中的值

int IsSuccess(); //判断是否完成

int answer[9][9][9]; //用于保存每个方格可以填入的数字

void Initanswer(); //初始化answer[81][9][9]全部为0

void bauto(int n); //自动求解

void showhelp(); //求辅助数据

bool help=0; //是否显示辅助数据

bool f; //成功标志

int tmp=20; //记录当前地图是哪副

int easy[21][9][9]={ //用于存储初级地图

{

{0,0,0,0,3,0,2,0,8},

{0,2,8,0,4,0,1,3,0},

{0,0,9,5,8,0,0,4,7},

{0,3,1,0,2,0,5,9,0},

{0,0,5,3,9,1,7,0,0},

{0,9,0,4,7,5,8,1,3},

{0,0,0,0,6,0,4,0,2},

{0,0,0,0,0,3,0,6,0},

{0,7,6,2,5,4,0,8,0}

},

{

{0,0,0,0,0,4,0,5,2},

{0,0,5,0,0,7,0,1,4},

{0,0,1,0,0,8,3,0,6},

{0,1,2,0,0,6,4,3,9},

{0,0,9,0,4,1,6,8,5},

{0,0,6,0,3,5,2,7,1},

{0,6,7,0,1,0,0,0,0},

{1,5,0,0,0,3,0,2,8},

{0,2,0,0,5,9,0,6,0}

},

{

{0,7,8,4,0,0,0,3,6},

{4,1,9,0,0,8,2,0,0},

{0,0,6,0,7,0,0,0,9},

{0,9,5,0,6,4,0,7,1},

{1,0,7,5,0,0,0,0,0},

{0,3,4,0,1,7,5,6,8},

{0,8,1,0,0,9,6,2,4},

{0,0,2,0,0,0,0,0,3},

{0,4,0,0,2,0,0,8,5}

},

{

{0,9,0,0,0,8,0,2,0},

{0,8,0,0,9,7,0,4,0},

{0,7,0,5,2,0,9,6,8},

{0,0,7,0,4,0,0,5,3},

{0,2,9,0,3,5,0,0,0},

{0,3,5,2,7,1,6,8,0},

{0,0,1,0,8,0,5,0,0},

{0,0,0,7,0,0,0,9,4},

{0,4,8,0,5,2,1,3,6}

},

{

{0,0,5,0,0,0,1,6,7},

{0,0,7,0,4,0,0,9,0},

{3,0,0,0,0,1,0,0,0},

{0,5,1,0,3,0,0,0,0},

{0,2,3,0,1,8,5,0,0},

{0,8,0,7,9,5,3,0,2},

{1,3,6,0,5,0,2,8,0},

{0,7,0,1,8,3,0,5,6},

{5,9,8,0,6,0,7,0,1}

},

{

{0,1,8,0,0,0,6,2,0},

{0,7,9,0,0,0,5,8,0},

{0,0,6,0,0,5,0,1,0},

{0,5,2,0,3,7,9,0,8},

{0,0,1,5,2,8,4,7,3},

{0,3,7,0,9,6,0,0,1},

{0,0,0,0,7,4,8,3,2},

{0,0,0,0,1,0,0,4,5},

{0,8,0,0,5,0,0,9,6}

},

{ //特殊

{0,0,1,0,0,0,0,0,7},

{0,7,8,5,6,0,3,9,2},

{0,0,9,0,4,0,1,6,0},

{0,2,3,0,0,5,9,0,6},

{0,9,7,3,0,2,0,0,0},

{0,0,0,9,0,6,7,2,3},

{0,4,0,1,2,9,0,7,0},

{7,1,0,0,3,8,0,4,9},

{0,8,0,0,5,0,0,3,0}

},

{ //第八种

{0,1,2,0,0,9,0,5,8},

{0,4,0,0,0,8,6,0,9},

{9,0,8,0,5,0,3,1,2},

{0,0,1,7,9,5,8,0,0},

{0,7,3,0,0,0,0,9,1},

{0,0,9,0,3,2,0,0,7},

{0,5,7,0,2,4,0,6,3},

{0,9,0,0,0,0,0,0,0},

{0,0,6,5,7,1,0,8,4}

},

{

{0,3,6,0,0,9,4,8,5},

{9,4,0,0,0,8,0,7,0},

{0,7,8,0,0,6,0,0,9},

{4,6,0,7,8,0,0,9,0},

{0,0,7,0,0,3,0,4,0},

{0,0,9,0,6,0,7,1,2},

{0,5,3,0,9,0,0,6,4},

{0,9,4,0,0,0,1,5,0},

{0,0,2,6,5,4,0,0,7}

},

{

{0,0,1,8,9,3,5,6,7},

{0,8,7,4,0,1,0,3,0},

{0,3,9,7,5,0,0,1,0},

{4,0,0,0,3,5,0,0,0},

{0,0,8,0,0,4,0,9,1},

{0,0,2,1,8,6,0,5,0},

{0,2,0,5,0,7,0,8,6},

{0,6,0,3,2,0,0,0,0},

{0,7,0,0,0,8,3,4,0}

},

{

{0,3,9,0,4,8,0,2,5},

{6,8,2,0,5,0,0,0,0},

{4,5,7,0,2,0,0,8,0},

{5,1,6,9,0,3,0,0,4},

{9,4,3,0,1,0,0,5,0},

},

{

},

{

},

{

},

{

{2,0,8,4,0,5,1,0,9},

{0,2,0,0,0,0,0,6,3},

{0,0,0,0,0,0,0,9,2},

{0,0,4,2,3,6,0,0,0}

{0,0,8,0,0,0,0,2,0},

{0,3,2,0,4,0,9,0,0},

{5,7,4,0,1,2,3,0,8},

{0,0,7,0,2,6,0,4,0},

{0,0,6,5,0,1,2,7,3},

{0,1,5,0,0,0,0,0,9},

{0,2,1,7,8,0,0,3,5},

{0,4,3,1,0,0,0,0,0},

{7,5,0,0,3,4,8,1,0}

{0,8,0,3,0,0,0,5,9},

{0,4,0,0,0,0,6,1,7},

{0,5,7,0,1,9,0,3,8},

{0,1,8,2,0,0,0,0,3},

{0,2,0,0,7,3,8,0,4},

{0,0,0,8,9,0,0,2,5},

{0,3,2,0,4,5,9,8,0},

{0,0,4,0,3,0,5,0,0},

{7,6,5,9,8,0,0,0,0}

{0,0,0,0,8,9,0,5,6},

{0,8,6,4,0,5,0,2,9},

{0,0,0,0,0,7,0,0,8},

{0,1,8,6,4,2,0,9,3},

{0,6,3,8,0,1,2,0,0},

{0,0,5,0,7,3,0,8,1},

{6,0,0,0,3,0,0,4,0},

{0,0,7,0,9,4,0,6,2},

{0,5,9,0,0,0,0,3,7}

{0,0,0,2,0,0,0,0,9},

{5,2,0,0,0,9,4,0,3},

{0,8,9,0,0,0,0,0,0},

{0,0,0,9,7,6,0,1,4},

{0,9,4,5,2,8,3,7,0},

{0,6,0,3,0,0,9,0,5},

{0,1,3,4,5,2,6,0,0},

{0,0,2,8,0,1,0,0,7},

{0,0,8,6,3,7,2,4,0}

},

{ //第16种

{0,7,9,0,1,4,0,0,6},

{0,1,0,0,2,7,0,0,0},

{0,0,6,0,8,9,0,1,7},

{9,5,0,0,3,2,6,7,0},

{0,6,7,4,9,0,0,0,8},

{0,3,1,0,6,0,0,0,0},

{0,0,5,0,0,1,3,6,2},

{0,0,0,8,7,3,5,4,1},

{0,0,0,0,5,0,0,8,9}

},

{

{0,0,5,0,6,0,0,0,9},

{0,0,0,0,1,8,2,4,5},

{8,9,2,3,0,0,0,7,0},

{0,5,7,0,8,9,0,0,3},

{0,2,1,0,0,6,0,9,0},

{0,6,8,0,3,2,0,0,1},

{0,8,0,0,2,1,0,6,0},

{0,1,4,0,0,0,0,3,7},

{0,0,9,8,4,0,5,1,2}

},

{

{0,5,0,0,9,2,1,3,6},

{0,0,0,0,5,4,0,0,8},

{1,0,0,0,8,3,0,5,9},

{0,8,3,9,2,0,0,1,4},

{7,0,0,5,0,0,0,8,2},

{0,2,0,0,3,0,0,6,0},

{9,3,5,2,0,8,7,0,0},

{0,6,7,4,1,5,8,0,0},

{0,0,0,0,0,0,0,2,5}

},

{

{0,3,7,2,0,9,0,0,4},

{0,8,9,0,0,0,1,0,7},

{0,5,6,7,1,8,0,0,0},

{0,6,0,3,9,0,0,0,0},

{0,0,2,0,7,5,0,4,8},

{0,7,4,0,0,2,0,0,0},

{6,4,0,8,0,1,7,0,2},

{7,0,3,9,4,6,0,8,1},

{0,1,8,0,0,0,0,3,0}

},

{ //第20种

{0,3,5,0,0,9,0,2,7},

{0,2,9,3,5,1,0,6,8},

{0,0,0,0,0,4,0,0,9},

{0,5,0,5,6,0,0,0,3},

{8,7,0,5,0,3,0,0,2},

{0,4,0,0,0,2,0,0,5},

{6,0,4,0,3,7,2,0,0},

{0,1,3,9,2,0,8,7,4},

{0,0,0,0,0,5,0,9,6}

}

,

{ //测试数据

{7,1,2,3,6,9,4,5,8},

{3,4,5,2,1,8,6,7,9},

{9,6,8,4,5,7,3,1,2},

{4,2,1,7,9,5,8,3,6},

{5,7,3,8,4,6,2,9,1},

{6,8,9,1,3,2,5,4,7},

{8,5,7,9,2,4,1,6,3},

{1,9,4,6,8,3,7,2,5},

{2,3,6,5,7,1,0,8,4}

}

};

LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );

int APIENTRY WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPSTR lpCmdLine,

int iCmdShow)

{

// written by luweikang

// TODO: Place code here.

static TCHAR szAppName[ ] = TEXT ("Russion");

HWND hwnd;

MSG msg;

WNDCLASS wndclass;

//窗口处理函数

= CS_HREDRAW | CS_VREDRAW;

dProc = WndProc;

xtra = 0;

xtra = 0;

nce = hInstance;

= LoadIcon( NULL, IDI_APPLICATION );

r = LoadCursor( NULL, IDC_ARROW );

kground = (HBRUSH)GetStockObject( WHITE_BRUSH );

nuName = NULL;

assName = szAppName;

if( !RegisterClass( &wndclass ) )

{

MessageBox( NULL, TEXT ("Program requires Windows NT!" ),

szAppName, MB_ICONERROR );

return 0;

}

hwnd = CreateWindow( szAppName, TEXT ("数独游戏"),

WS_OVERLAPPED | WS_SYSMENU | WS_BORDER,

CW_USEDEFAULT, CW_USEDEFAULT,

(COL + 4) * LEN+2, //窗口宽度

ROW * LEN + 40, //窗口高度(包括标题栏部分29pix)

NULL, NULL, hInstance, NULL );

ShowWindow( hwnd, iCmdShow );

UpdateWindow( hwnd );

while( GetMessage( &msg, NULL, 0, 0 ) )

{

TranslateMessage( &msg );

DispatchMessage( &msg );

}

return ;

}

void Initvalue( ) //初始化地图上的每一个值,使其为零

{

int y, x;

for( y = 0; y < ROW; y++ )

{

for( x = 0; x < COL; x++ )

{

value[y][x] = 0;

}

}

}

void Initchange()

{

int row2,col2;

for(row2=0;row2<9;row2++)

{

for(col2=0;col2<9;col2++)

{

if(value[row2][col2]==0) change[row2][col2]=1;

else change[row2][col2]=0;

}

}

}

void Initanswer()

{

int a,b,c;

for(a=0;a<9;a++)

{

for(b=0;b<9;b++)

{

for(c=0;c<9;c++)

answer[a][b][c]=0;

}

}

}

int IsSuccess()

{

int row4,col4;

int count[]={81,9,9,9,9,9,9,9,9,9};

for(row4=0;row4<9;row4++)

{

for(col4=0;col4<9;col4++)

{

count[value[row4][col4]]--;

}

}

if(count[1]==0&&count[2]==0&&count[3]==0&&count[4]==0&&count[5]==0&&count[6]

==0&&count[7]==0&&count[8]==0&&count[9]==0)

return 1;

else

return 0;

}

int judge(int value1,int row,int col)

{

int down_row,down_col,up_row,up_col;

for(down_row=0;down_row

{

if(value1==value[down_row][col]) return 0;

}

for(up_row=8;up_row>row;up_row--) //判断方格向下的格子

{

if(value1==value[up_row][col]) return 0;

}

for(down_col=0;down_col

{

if(value1==value[row][down_col]) return 0;

}

for(up_col=8;up_col>col;up_col--) //判断方格向右的格子

{

if(value1==value[row][up_col]) return 0;

}

int a_row=row/3,b_row=row%3,a_col=col/3,b_col=col%3;//用于记录当前格子所在的小九

宫格的位置

int mini_row,mini_col;

switch(a_row)

{

case 0://这个大九宫格在最上三行

switch(a_col)

{

case 0://这个大九宫格在最前三列

for(mini_row=0;mini_row<3;mini_row++)

{

for(mini_col=0;mini_col<3;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

case 1://这个大九宫格在中间三列

for(mini_row=0;mini_row<3;mini_row++)

{

for(mini_col=3;mini_col<6;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

case 2://这个大九宫格在最后三列

for(mini_row=0;mini_row<3;mini_row++)

{

for(mini_col=6;mini_col<9;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

}

break;

case 1://这个大九宫格在中间三行

switch(a_col)

{

case 0://这个大九宫格在最前三列

for(mini_row=3;mini_row<6;mini_row++)

{

for(mini_col=0;mini_col<3;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

case 1://这个大九宫格在中间三列

for(mini_row=3;mini_row<6;mini_row++)

{

for(mini_col=3;mini_col<6;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

case 2://这个大九宫格在最后三列

for(mini_row=3;mini_row<6;mini_row++)

{

for(mini_col=6;mini_col<9;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

}

break;

case 2://这个大九宫格在最下三行

switch(a_col)

{

case 0://这个大九宫格在最前三列

for(mini_row=6;mini_row<9;mini_row++)

{

for(mini_col=0;mini_col<3;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

case 1://这个大九宫格在中间三列

for(mini_row=6;mini_row<9;mini_row++)

{

for(mini_col=3;mini_col<6;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

case 2://这个大九宫格在最后三列

for(mini_row=6;mini_row<9;mini_row++)

{

for(mini_col=6;mini_col<9;mini_col++)

if(value1==value[mini_row][mini_col]) return 0;

}

break;

}

break;

}

return 1;

}

void showhelp()

{

Initanswer();

int row8,col8,numbe,i;

for(row8=0;row8<9;row8++)

{

for(col8=0;col8<9;col8++)

{

if(value[row8][col8]==0&&change[row8][col8])

{

i=0;

for(numbe=1;numbe<10;numbe++)

{

if(judge(numbe,row8,col8))

{

answer[row8][col8][i++]=numbe;

}

}

}

}

}

}

void bauto(int n)

{

int row7=n/9,col7=n%9,num;

for(num=1;num<10&&change[row7][col7];num++)

{

if(n<81&&judge(num,row7,col7)&&change[row7][col7])

{

value[row7][col7]=num;

bauto(n+1);

}

}

if(change[row7][col7]&&!f)

value[row7][col7]=0;

if(n<81&&!change[row7][col7])

{

bauto(n+1);

}

if(n==81)

f=1;

}

LRESULT CALLBACK WndProc( HWND hwnd, UINT message, //窗口处理函数

WPARAM wParam, LPARAM lParam )

{

HFONT hfont;

HDC hdc, hdcMem;

int y, x;

PAINTSTRUCT ps;

HBITMAP hBitMap;

HPEN hPen;

HBRUSH hBrush;

int row3,col3,mem,mem_fuzhu;

static int cxClient, cyClient; //窗口客户区宽度和高度

static char *text[]={" ","1","2","3","4","5","6","7","8","9"};

static char *info[]={"F1:生成地图","F2:显示辅助数据","F4:自动求解","F5:重开本局"};

static char *t="success!";

switch( message )

{

case WM_CREATE:

SetTimer( hwnd, tPaint, tPaintTime, NULL );

return 0;

case WM_SIZE:

cxClient = LOWORD( lParam ); //取得窗口客户区宽度和高度

cyClient = HIWORD( lParam );

return 0;

case WM_TIMER:

{

switch( wParam )

{

case tPaint: //重绘定时器

InvalidateRect(hwnd, NULL, FALSE); //强制重绘窗口工作区

break;

}

}//end of case WM_TIMER

case WM_KEYDOWN:

{

switch( wParam )

{

case VK_LEFT: //"向左"方向键

if(CurrentX>0)

CurrentX-=1;

else if(CurrentX==0)

CurrentX=8;

break;

case VK_RIGHT: //"向右"方向键

if(CurrentX<8)

CurrentX+=1;

else if(CurrentX==8)

CurrentX=0;

break;

case VK_UP: //"向上"方向键:

if(CurrentY>0)

CurrentY-=1;

else if(CurrentY==0)

CurrentY=8;

break;

case VK_DOWN: //"向下"方向键:下移一个位置

if(CurrentY<8)

CurrentY+=1;

else if(CurrentY==8)

CurrentY=0;

break;

case 0x30: //响应数字0键

value[CurrentY][CurrentX]=0;

break;

case 0x31:

if(!judge(1,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=1;

showhelp();

break;

case 0x32:

if(!judge(2,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=2;

showhelp();

break;

case 0x33:

if(!judge(3,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=3;

showhelp();

break;

case 0x34:

if(!judge(4,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=4;

showhelp();

break;

case 0x35:

if(!judge(5,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=5;

showhelp();

break;

case 0x36:

if(!judge(6,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=6;

showhelp();

break;

case 0x37:

if(!judge(7,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=7;

showhelp();

break;

case 0x38:

if(!judge(8,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=8;

showhelp();

break;

case 0x39:

if(!judge(9,CurrentY,CurrentX)) break;

value[CurrentY][CurrentX]=9;

showhelp();

break;

case VK_F1:

f=0;

help=0;

mem_fuzhu=10000;

while(1)

{

mem=rand()%20;

if(mem_fuzhu!=mem)

break;

}

tmp=mem;

mem_fuzhu=mem;

for(row3=0;row3<9;row3++)

{

for(col3=0;col3<9;col3++)

value[row3][col3]=easy[mem][row3][col3];

}

Initchange();

break;

case VK_F2:

Initanswer();

showhelp();

help=!help;

break;

case VK_F4:

bauto(0);

break;

case VK_F5:

help=0;

for(row3=0;row3<9;row3++)

{

for(col3=0;col3<9;col3++)

value[row3][col3]=easy[tmp][row3][col3];

}

f=0;

}

}//end of case WM_KEYDOWN

break;

case WM_PAINT: //重绘窗口工作区

{

hdc = BeginPaint( hwnd, &ps );

hdcMem = CreateCompatibleDC( hdc );

hBitMap = CreateCompatibleBitmap( hdc, cxClient, cyClient );

SelectObject( hdcMem, hBitMap );

//画地图最外面的白色矩形

Rectangle( hdcMem, StartX,StartY,StartX + LEN * COL, StartY + LEN *

ROW );

Rectangle( hdcMem, StartX + LEN * COL+ 3, StartY , StartX + LEN * COL + 149,

StartY + LEN * ROW); //画右边的白色文本区域

///*

hPen = CreatePen( PS_SOLID, 1, RGB(180, 180, 180) );

SelectObject( hdcMem, hPen );

hBrush = CreateSolidBrush( RGB(250, 250, 250) );

SelectObject( hdcMem, hBrush );

for( y = 0; y < ROW ; y++ ) //画地图中的每一格

{

for( x = 0; x < COL ; x++ )

{

Rectangle( hdcMem, StartX + LEN * x, StartY + LEN * y,

StartX + LEN * (x + 1), StartY + LEN * (y + 1) );

}

}

hPen = CreatePen( PS_SOLID, 1, RGB(255, 0, 0) );

SelectObject( hdcMem, hPen );

Rectangle( hdcMem, StartX + 119, StartY ,StartX + 121, StartY + 360); //横竖各两

条画红线

Rectangle( hdcMem, StartX + 239, StartY ,StartX + 241, StartY + 360);

Rectangle( hdcMem, StartX , StartY + 119,StartX + 360, StartY + 121);

Rectangle( hdcMem, StartX , StartY + 239,StartX + 360, StartY + 241);

DeleteObject( hPen );

DeleteObject( hBrush );

//画能移动的当前活动的蓝色方格

hPen = CreatePen( PS_SOLID, 1, RGB(0, 0, 255) );

SelectObject( hdcMem, hPen );

hBrush = CreateSolidBrush( RGB(255, 255, 255) );

SelectObject(hdcMem, hBrush);

Rectangle( hdcMem, StartX + LEN * CurrentX, StartY + LEN * CurrentY,StartX

+LEN * (CurrentX + 1), StartY + LEN * (CurrentY + 1) );

Rectangle( hdcMem, StartX + LEN * CurrentX+1, StartY + LEN *

CurrentY+1,StartX +LEN * (CurrentX + 1)-1, StartY + LEN * (CurrentY + 1)-1 );

DeleteObject( hPen );

DeleteObject( hBrush );

DeleteObject( hBitMap );

hfont=CreateFont(

35,

0,

0,

0,

FW_HEAVY,

0,

0,

0,

GB2312_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

DEFAULT_QUALITY,

DEFAULT_PITCH|FF_DONTCARE,

"粗体字"

);

SelectObject(hdcMem,hfont);

for(int ro=0;ro<9;ro++)

{

for(int co=0;co<9;co++)

{

if(change[ro][co]==0)

{

SetTextColor(hdcMem,RGB(0,0,0)); //设置文本颜色为黑色

TextOut(hdcMem,StartX+3+LEN*co,StartY+3+LEN*ro,text[value[ro][co]],strlen(text[value

[ro][co]]));

}

if(change[ro][co]==1)

{

SetTextColor(hdcMem,RGB(255,0 ,0)); //设置文本颜色为红色

TextOut(hdcMem,StartX+3+LEN*co,StartY+3+LEN*ro,text[value[ro][co]],strlen(text[value

[ro][co]]));

}

}

}

if(help)

{

hfont=CreateFont(

13,

0,

0,

0,

FW_HEAVY,

0,

0,

0,

GB2312_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

DEFAULT_QUALITY,

DEFAULT_PITCH|FF_DONTCARE,

"粗体字"

);

SelectObject(hdcMem,hfont);

SetTextColor(hdcMem,RGB(128,128 ,128));

for(int ro=0;ro<9;ro++)

{

for(int co=0;co<9;co++)

{

for(int

numb=0;numb<9&&change[ro][co]&&value[ro][co]==0;numb++)

{

for(int a=numb/3;a<3;a++)

{

for(int b=numb%3;b<3;b++)

{

TextOut(hdcMem,StartX+3+LEN*co+b*11,StartY+3+LEN*ro+a*11,text[answer[ro][co][nu

mb]],strlen(text[answer[ro][co][numb]]));

}

}

}

}

}

}

hfont=CreateFont(

15,

0,

0,

0,

FW_HEAVY,

0,

0,

0,

GB2312_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

DEFAULT_QUALITY,

DEFAULT_PITCH|FF_DONTCARE,

"粗体字"

);

SelectObject(hdcMem,hfont);

SetTextColor(hdcMem,RGB(0,0,0)); //设置文本颜色为黑色

TextOut(hdcMem,StartX + LEN * 9+4, StartY+1,info[0],strlen(info[0]));

TextOut(hdcMem,StartX + LEN * 9+4, StartY+21,info[1],strlen(info[1]));

TextOut(hdcMem,StartX + LEN * 9+4, StartY+41,info[2],strlen(info[2]));

TextOut(hdcMem,StartX + LEN * 9+4, StartY+61,info[3],strlen(info[3]));

if(IsSuccess())

{

hfont=CreateFont(

30,

0,

0,

0,

FW_HEAVY,

0,

0,

0,

GB2312_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

DEFAULT_QUALITY,

DEFAULT_PITCH|FF_DONTCARE,

"粗体字"

);

SelectObject(hdcMem,hfont);

TextOut(hdcMem,StartX+364,StartY+300,t,strlen(t));

}

BitBlt( hdc, 0, 0, cxClient, cyClient, hdcMem, 0, 0, SRCCOPY );

DeleteDC( hdcMem );

EndPaint( hwnd, &ps );

DeleteObject(hfont);

return 0;

}//end of case WM_PAINT

case WM_DESTROY:

PostQuitMessage( 0 );

return 0;

}//end of switch( message )

return DefWindowProc( hwnd, message, wParam, lParam );

}


发布者:admin,转转请注明出处:http://www.yc00.com/xitong/1715032118a2555350.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信