我现在已经把一个鼠坑通过FOR循环,在窗体中央变出了9个来.3行3列.
可是我现在想要把地鼠的小图片随机替换这九个鼠坑的图片.该怎么做啊?
最好有代码参考啊~思路很简单,我现在就是烦该怎么实现.
因为刚学,实在很菜,请大家慷慨帮忙哦!
可是我现在想要把地鼠的小图片随机替换这九个鼠坑的图片.该怎么做啊?
最好有代码参考啊~思路很简单,我现在就是烦该怎么实现.
因为刚学,实在很菜,请大家慷慨帮忙哦!
解决方案 »
- [100分]高分求教,如何能够单步控制TCP的连接?
- 如何获取文件图标并加入到Listview中?
- 请问如何改变基于单文档,其中一个对话框的位置
- 请问一个关于ado调用存储过程返回值的问题
- 批量数据输入问题
- 如何编程序选择其他应用程序的对话框中的SysTreeView32节点?
- 如何用最快速度生成一个指定大小的文件???
- waveOutGetVolume函数问题
- 这样也有错?(熟悉数据库的朋友进来看一下)(高分在线)
- 全国程序员进来整理文档!
- 求救:try{}catch(...){} 在 Release 版本下失效
- LPCSTR --- LPCTSTR ---- CString --- char* ----char[] ---- CHAR ---- ???????????????????
放在内存dc里面
然后等到要画的时候通过bitblt,把图片画到对应的位置上去
对了,那随机数怎么弄,我看过一些代码,可不明白SRAND和RAND,为什么要两个函数?怎么用的?
而且哪个用在哪里?有点晕.
msdn上,照着用就可以了
Example
/* RAND.C: This program seeds the random-number generator
* with the time, then displays 10 random integers.
*/#include <stdlib.h>
#include <stdio.h>
#include <time.h>void main( void )
{
int i; /* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) ); /* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand() );
}Output
6929
8026
21987
30734
20587
6699
22034
25051
7988
10104
我就是不明白.
HDC memdc;
memdc = CreateCompatibleDC(hDC);
HBITMAP hOldMap = SelectObject(memdc ,hBitMap);然后通过BitBlt把memdc的内容考到hDC里面注意一下坐标,以及图片的大小这里,hDC是你窗体的dc 可以通过getdc获得
hBitMap 是你位图的句柄
可以通过LoadImage或者LoadBitmap获得
The srand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point. rand retrieves the pseudorandom numbers that are generated. Calling rand before any call to srand generates the same sequence as calling srand with seed passed as 1.你可以试一下,如果你以一个特定的常量数作为随机种子,那么出来的数都是一样的
……………………
不客气,大家一起学习
学sdk的话,
看看
windows程序设计
这本书很不错,有机会去一定要好好看看