大家帮帮我完成这个东西 谢谢了

yunlerini 2008-04-16 02:21:53
我要写个代码 用cards.dll 要求是 画4列牌 各13张 1-K
大体框架我写好了 就是绘制图片我不会 请大家帮我加上 谢谢了 我写的框架:
#include <windows.h>
#include "cards.h"


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


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,

PSTR szCmdLine, int iCmdShow)

{

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

HWND hwnd ;

MSG msg ;

WNDCLASS wndclass ;


wndclass.style = CS_HREDRAW | CS_VREDRAW ;

wndclass.lpfnWndProc = WndProc ;

wndclass.cbClsExtra = 0 ;

wndclass.cbWndExtra = 0 ;

wndclass.hInstance = hInstance ;

wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;

wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;

wndclass.hbrBackground= CreateSolidBrush ( RGB(0,0x7a,0) ) ;

wndclass.lpszMenuName = NULL ;

wndclass.lpszClassName= szAppName ;


RegisterClass (&wndclass);

hwnd = CreateWindow( szAppName,

TEXT ("cards"),

WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

NULL,

NULL,

hInstance,

NULL) ;



ShowWindow (hwnd, iCmdShow) ;

UpdateWindow (hwnd) ;



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

{

TranslateMessage (&msg) ;

DispatchMessage (&msg) ;

}

return msg.wParam ;

}


LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

HDC hdc ;
PAINTSTRUCT ps ;



switch (message)

{

case WM_CREATE:



return 0 ;


case WM_PAINT:

hdc = BeginPaint (hwnd, &ps) ;


EndPaint (hwnd, &ps) ;

return 0 ;



case WM_DESTROY:

PostQuitMessage (0) ;

return 0 ;

}

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

}


cards.h文件:

#define mdFace 0 /* Draw card face up, card to draw specified by cd */
#define mdBackground 1 /* Draw card face down, back specified by cd (cdBackgroundFirst..cdBackgroundLast) */
#define mdHilite 2 /* Same as FaceUp except drawn with NOTSRCCOPY mode */
#define mdGhost 3 /* Draw a ghost card -- for ace piles */
#define mdRemove 4 /* draw background specified by rgbBgnd */
#define mdInvisibleGhost 5 /* ? */
#define mdDeckX 6 /* Draw X */
#define mdDeckO 7 /* Draw O */`


#define cdAClubs 0
#define cd2Clubs 4
#define cd3Clubs 8
#define cd4Clubs 12
#define cd5Clubs 16
#define cd6Clubs 20
#define cd7Clubs 24
#define cd8Clubs 28
#define cd9Clubs 32
#define cdTClubs 36
#define cdJClubs 40
#define cdQClubs 44
#define cdKClubs 48
#define cdADiamonds 1
#define cd2Diamonds 5
#define cd3Diamonds 9
#define cd4Diamonds 13
#define cd5Diamonds 17
#define cd6Diamonds 21
#define cd7Diamonds 25
#define cd8Diamonds 29
#define cd9Diamonds 33
#define cdTDiamonds 37
#define cdJDiamonds 41
#define cdQDiamonds 45
#define cdKDiamonds 49
#define cdAHearts 2
#define cd2Hearts 6
#define cd3Hearts 10
#define cd4Hearts 14
#define cd5Hearts 18
#define cd6Hearts 22
#define cd7Hearts 26
#define cd8Hearts 30
#define cd9Hearts 34
#define cdTHearts 38
#define cdJHearts 42
#define cdQHearts 46
#define cdKHearts 50
#define cdASpades 3
#define cd2Spades 7
#define cd3Spades 11
#define cd4Spades 15
#define cd5Spades 19
#define cd6Spades 23
#define cd7Spades 27
#define cd8Spades 31
#define cd9Spades 35
#define cdTSpades 39
#define cdJSpades 43
#define cdQSpades 47
#define cdKSpades 51


#define cdBackground1 54
#define cdBackground2 55
#define cdBackground3 56
#define cdBackground4 57
#define cdBackground5 58
#define cdBackground6 59
#define cdBackground7 60
#define cdBackground8 61
#define cdBackground9 62
#define cdBackground10 63
#define cdBackground11 64
#define cdBackground12 65
#define cdBackgroundFirst cdBackground1
#define cdBackgroundLast cdBackground12




BOOL WINAPI cdtInit(int FAR *pdxCard, int FAR *pdyCard);

BOOL WINAPI cdtDraw(HDC hdc, int x, int y, int cd, int md, DWORD rgbBgnd);

BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy,
int cd, int md, DWORD rgbBgnd);
BOOL WINAPI cdtAnimate(HDC hdc, int cd, int x, int y, int ispr);

VOID WINAPI cdtTerm(VOID);
...全文
115 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
呵呵 自己搞好了 不过还是谢谢给我回帖的兄弟!!!
#include <windows.h>
#include "cards.h"

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,

PSTR szCmdLine, int iCmdShow)

{

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

HWND hwnd ;

MSG msg ;

WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;

wndclass.lpfnWndProc = WndProc ;

wndclass.cbClsExtra = 0 ;

wndclass.cbWndExtra = 0 ;

wndclass.hInstance = hInstance ;

wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;

wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;

wndclass.hbrBackground= CreateSolidBrush ( RGB(0,0x7a,0) ) ;

wndclass.lpszMenuName = NULL ;

wndclass.lpszClassName= szAppName ;

RegisterClass (&wndclass);

hwnd = CreateWindow( szAppName,

TEXT ("cards"),

WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

NULL,

NULL,

hInstance,

NULL) ;



ShowWindow (hwnd, iCmdShow) ;

UpdateWindow (hwnd) ;



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

{

TranslateMessage (&msg) ;

DispatchMessage (&msg) ;

}

return msg.wParam ;

}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

HDC hdc ;
PAINTSTRUCT ps ;



switch (message)

{

case WM_CREATE:

cdtInit(&nCardWidth, &nCardHeight);

return 0 ;

case WM_PAINT:


hdc = BeginPaint (hwnd, &ps) ;
{ int i;

for(i = 0; i <= 12; i++) {
cdtDraw(hdc , 0, 0x12* (i + 1) , 4 * i, mdFace, 0x7d00); /* 十三张梅花牌 */
}
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 20+ nCardWidth, 0x12* (i + 1) , 4 * i + 1, mdFace, 0x7d00); /* 十三张方块牌 */
}
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 2 * (20 + nCardWidth), 0x12* (i + 1) , 4 * i + 2, mdFace, 0x7d00); /* 十三张红桃牌 */
}
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 3 * (20 + nCardWidth), 0x12* (i + 1), 4 * i + 3, mdFace, 0x7d00); /* 十三张黑桃牌 */
}
}
EndPaint (hwnd, &ps) ;

return 0 ;



case WM_DESTROY:
cdtTerm();

PostQuitMessage (0) ;

return 0 ;

}

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

}
这样就好了
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
#include <windows.h>
#include "cards.h"

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,

PSTR szCmdLine, int iCmdShow)

{

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

HWND hwnd ;

MSG msg ;

WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;

wndclass.lpfnWndProc = WndProc ;

wndclass.cbClsExtra = 0 ;

wndclass.cbWndExtra = 0 ;

wndclass.hInstance = hInstance ;

wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;

wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;

wndclass.hbrBackground= CreateSolidBrush ( RGB(0,0x7a,0) ) ;

wndclass.lpszMenuName = NULL ;

wndclass.lpszClassName= szAppName ;

RegisterClass (&wndclass);

hwnd = CreateWindow( szAppName,

TEXT ("cards"),

WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

NULL,

NULL,

hInstance,

NULL) ;



ShowWindow (hwnd, iCmdShow) ;

UpdateWindow (hwnd) ;



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

{

TranslateMessage (&msg) ;

DispatchMessage (&msg) ;

}

return msg.wParam ;

}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

HDC hdc ;
PAINTSTRUCT ps ;



switch (message)

{

case WM_CREATE:

cdtInit(&nCardWidth, &nCardHeight);

return 0 ;

case WM_PAINT:

hdc = BeginPaint (hwnd, &ps) ;
int i = 0;
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 10, 0x12 * (i + 1), 4 * i, 0, 0x7d00); /* rgbBground 定成 0x7d00, 绿色; 十三张梅花牌 */
}
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 10 + nCardWidth, 0x12 * (i + 1), 4 * i + 1, 0, 0x7d00); /* 十三张方块牌 */
}
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 2 * (10 + nCardWidth), 0x12 * (i + 1), 4 * i + 2, 0, 0x7d00); /* 十三张红桃牌 */
}
for(i = 0; i <= 12; i++) {
cdtDraw(hdc, 3 * (10 + nCardWidth), 0x12 * (i + 1), 4 * i + 3, 0, 0x7d00); /* 十三张黑桃牌 */
}

EndPaint (hwnd, &ps) ;

return 0 ;



case WM_DESTROY:
cdtTerm();

PostQuitMessage (0) ;

return 0 ;

}

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

}

--------------------Configuration: hellowin - Win32 Debug--------------------
Compiling...
hehe.c
C:\Documents and Settings\WangYue\桌面\hellowin\hehe.c(108) : error C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\WangYue\桌面\hellowin\hehe.c(109) : error C2065: 'i' : undeclared identifier
Error executing cl.exe.
Creating browse info file...

hellowin.exe - 2 error(s), 0 warning(s)


我又改了下 这回的错误是:
erdgzw 2008-04-16
  • 打赏
  • 举报
回复
我现在用的机器没装VS,没办法为你上机调试。
你定义的是全局变量吗?把错误贴上来。
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
呵呵 谢谢你 不过能不能帮我把这段代码写好?谢谢了 我 自己又写了写 不过好多报错啊:
#include <windows.h>
#include "cards.h"


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


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,

PSTR szCmdLine, int iCmdShow)

{

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

HWND hwnd ;

MSG msg ;

WNDCLASS wndclass ;


wndclass.style = CS_HREDRAW | CS_VREDRAW ;

wndclass.lpfnWndProc = WndProc ;

wndclass.cbClsExtra = 0 ;

wndclass.cbWndExtra = 0 ;

wndclass.hInstance = hInstance ;

wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;

wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;

wndclass.hbrBackground= CreateSolidBrush ( RGB(0,0x7a,0) ) ;

wndclass.lpszMenuName = NULL ;

wndclass.lpszClassName= szAppName ;


RegisterClass (&wndclass);

hwnd = CreateWindow( szAppName,

TEXT ("cards"),

WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

NULL,

NULL,

hInstance,

NULL) ;



ShowWindow (hwnd, iCmdShow) ;

UpdateWindow (hwnd) ;



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

{

TranslateMessage (&msg) ;

DispatchMessage (&msg) ;

}

return msg.wParam ;

}


LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

HDC hdc ;
PAINTSTRUCT ps ;



switch (message)

{

case WM_CREATE:

cdtInit(&nCardWidth, &nCardHeight);

return 0 ;


case WM_PAINT:

hdc = BeginPaint (hwnd, &ps) ;

for(int i = 0; i <= 12; i++) {
cdtDraw(hDC, 10, 0x12 * (i + 1), 4 * i, mdFace, 0x7d00); // 十三张梅花牌
}

for(int i = 0; i <= 12; i++) {
cdtDraw(hDC, 10 + nCardWidth, 0x12 * (i + 1), 4 * i + 1, mdFace, 0x7d00); // 十三张方块牌
}

for(int i = 0; i <= 12; i++) {
cdtDraw(hDC, 2 * (10 + nCardWidth), 0x12 * (i + 1), 4 * i + 2, mdFace, 0x7d00); // 十三张红桃牌
}

for(int i = 0; i <= 12; i++) {
cdtDraw(hDC, 3 * (10 + nCardWidth), 0x12 * (i + 1), 4 * i + 3, mdFace, 0x7d00); // 十三张黑桃牌
}

EndPaint (hwnd, &ps) ;

return 0 ;



case WM_DESTROY:

cdtTerm();

PostQuitMessage (0) ;

return 0 ;

}

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

}



我在cards.h里面添加了呃int nCardWidth, nCardHeight; 不过还是编译不过去
erdgzw 2008-04-16
  • 打赏
  • 举报
回复
源码挺简单的啊!
你要是认为难,那么你就要再学学Windows编程了。
不要想一步登天,先把基础打好了再说。
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
erdgzw 这个空当接龙的源码我又啊 这个框架就是照那个做的 但是 这个太复杂了 我还接受不了...我想一步步来 来人帮我下吧
erdgzw 2008-04-16
  • 打赏
  • 举报
回复
给你个示例:
http://www.zhongts.net/MyCode/ZtsCards_SRC.zip
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
唉 来人帮下吧 崩溃了要
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
来人帮忙啊
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
沉的真快啊 自己顶下吧...
yunlerini 2008-04-16
  • 打赏
  • 举报
回复
高手来帮忙 谢谢啦~~Orz

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧