源代码:
#include "Include.h"
/*============================================================================*/
const U32 __HeapSize =4096;
const U32 __StackSize =1024;
const U32 __Priority =200;
const char __Name[32] ="FFT 测试";
const U32 __Icon =0;
const char __IconPath[32] ="0.bmp";
const char __Version[8] ="V1.0";
const char __Date[16] =__DATE__;
const char __Time[16] =__TIME__;
const char __Desc[32] ="Copyright:Liuwei";
/*============================================================================*/
/*============================================================================*/
/*============================================================================*/
//定义做FFT的点数
#define LENGTH 512
#define bL 9
#define IN_TYPE S16
#define OUT_TYPE S32
#define LEN_TYPE S32
#define PI 3.1415926535897932384626433832795
void FFT_Init(void);
void FFT_Input(IN_TYPE *pIn);
void FFT_Output(IN_TYPE *pIn, OUT_TYPE *pRe, OUT_TYPE *pIm);
LEN_TYPE BitRev[LENGTH]; //保存位倒置的值
//定义该宏将对结果进行归一化处理,否则不进行归一化处理,但是结果可能会溢出
//#define UNITARY 1
//定义该宏将使用查表法求正、余弦
#define USE_TABLE
//如果使用查表法求正、余弦,则定义表格
#ifdef USE_TABLE
#if LENGTH==32
//计算余弦用的表,放大了1024倍(32点FFT时用)
const short int COS_TABLE[LENGTH/2]=
{
1024,1004,946,851,724,569,392,200,0,-200,
-392,-569,-724,-851,-946
};
//计算正弦用的表,放大了1024倍(32点FFT时用)
const short int SIN_TABLE[LENGTH/2]=
{
0,200,392,569,724,851,946,1004,1024,1004,
946,851,724,569,392
};
#endif
#if LENGTH==64
//计算余弦用的表,放大了1024倍(64点FFT时用)
const short int COS_TABLE[LENGTH/2]=
{
1024,1019,1004,980,946,903,851,792,724,650,
569,483,392,297,200,100,0,-100,-200,-297,
-392,-483,-569,-650,-724,-792,-851,-903,-946,-980,
-1004,-1019
};
//计算正弦用的表,放大了1024倍(64点FFT时用)
const short int SIN_TABLE[LENGTH/2]=
{
0,100,200,297,392,483,569,650,724,792,
851,903,946,980,1004,1019,1024,1019,1004,980,
946,903,851,792,724,650,569,483,392,297,
200,100
};
#endif
#if LENGTH==128
//计算余弦用的表,放大了1024倍(128点FFT时用)
const short int COS_TABLE[LENGTH/2]=
{
1024,1023,1019,1013,1004,993,980,964,946,926,
903,878,851,822,792,759,724,688,650,610,
569,526,483,438,392,345,297,249,200,150,
100,50,0,-50,-100,-150,-200,-249,-297,-345,
-392,-438,-483,-526,-569,-610,-650,-688,-724,-759,
-792,-822,-851,-878,-903,-926,-946,-964,-980,-993,
-1004,-1013,-1019,-1023
};
//计算正弦用的表,放大了1024倍(128点FFT时用)
const short int SIN_TABLE[LENGTH/2]=
{
0,50,100,150,200,249,297,345,392,438,
483,526,569,610,650,688,724,759,792,822,
851,878,903,926,946,964,980,993,1004,1013,
1019,1023,1024,1023,1019,1013,1004,993,980,964,
946,926,903,878,851,822,792,759,724,688,
650,610,569,526,483,438,392,345,297,249,
200,150,100,50
};
#endif
#if LENGTH==256
//计算余弦用的表,放大了1024倍(256点FFT时用)
const short int COS_TABLE[LENGTH/2]=
{
1024,1024,1023,1021,1019,1016,1013,1009,1004,999,
993,987,980,972,964,955,946,936,926,915,
903,891,878,865,851,837,822,807,792,775,
759,742,724,706,688,669,650,630,610,590,
569,548,526,505,483,460,438,415,392,369,
345,321,297,273,249,224,200,175,150,125,
100,75,50,25,0,-25,-50,-75,-100,-125,
-150,-175,-200,-224,-249,-273,-297,-321,-345,-369,
-392,-415,-438,-460,-483,-505,-526,-548,-569,-590,
-610,-630,-650,-669,-688,-706,-724,-742,-759,-775,
-792,-807,-822,-837,-851,-865,-878,-891,-903,-915,
-926,-936,-946,-955,-964,-972,-980,-987,-993,-999,
-1004,-1009,-1013,-1016,-1019,-1021,-1023,-1024
};
//计算正弦用的表,放大了1024倍(256点FFT时用)
const short int SIN_TABLE[LENGTH/2]=
{
0,25,50,75,100,125,150,175,200,224,
249,273,297,321,345,369,392,415,438,460,
483,505,526,548,569,590,610,630,650,669,
688,706,724,742,759,775,792,807,822,837,
851,865,878,891,903,915,926,936,946,955,
964,972,980,987,993,999,1004,1009,1013,1016,
1019,1021,1023,1024,1024,1024,1023,1021,1019,1016,
1013,1009,1004,999,993,987,980,972,964,955,
946,936,926,915,903,891,878,865,851,837,
822,807,792,775,759,742,724,706,688,669,
650,630,610,590,569,548,526,505,483,460,
438,415,392,369,345,321,297,273,249,224,
200,175,150,125,100,75,50,25
};
#endif
#if LENGTH==512
//计算余弦用的表,放大了1024倍(512点FFT时用)
const short int COS_TABLE[LENGTH/2]=
{
1024,1024,1024,1023,1023,1022,1021,1020,1019,1018,
1016,1015,1013,1011,1009,1007,1004,1002,999,996,
993,990,987,983,980,976,972,968,964,960,
955,951,946,941,936,931,926,920,915,909,
903,897,891,885,878,872,865,858,851,844,
837,830,822,815,807,799,792,784,775,767,
759,750,742,733,724,715,706,697,688,678,
669,659,650,640,630,620,610,600,590,579,
569,558,548,537,526,516,505,494,483,472,
460,449,438,426,415,403,392,380,369,357,
345,333,321,309,297,285,273,261,249,237,
224,212,200,187,175,163,150,138,125,113,
100,88,75,63,50,38,25,13,0,-13,
-25,-38,-50,-63,-75,-88,-100,-113,-125,-138,
-150,-163,-175,-187,-200,-212,-224,-237,-249,-261,
-273,-285,-297,-309,-321,-333,-345,-357,-369,-380,
-392,-403,-415,-426,-438,-449,-460,-472,-483,-494,
-505,-516,-526,-537,-548,-558,-569,-579,-590,-600,
-610,-620,-630,-640,-650,-659,-669,-678,-688,-697,
-706,-715,-724,-733,-742,-750,-759,-767,-775,-784,
-792,-799,-807,-815,-822,-830,-837,-844,-851,-858,
-865,-872,-878,-885,-891,-897,-903,-909,-915,-920,
-926,-931,-936,-941,-946,-951,-955,-960,-964,-968,
-972,-976,-980,-983,-987,-990,-993,-996,-999,-1002,
-1004,-1007,-1009,-1011,-1013,-1015,-1016,-1018,-1019,-1020,
-1021,-1022,-1023,-1023,-1024,-1024
};
//计算正弦用的表,放大了1024倍(512点FFT时用)
const short int SIN_TABLE[LENGTH/2]=
{
0,13,25,38,50,63,75,88,100,113,
125,138,150,163,175,187,200,212,224,237,
249,261,273,285,297,309,321,333,345,357,
369,380,392,403,415,426,438,449,460,472,
483,494,505,516,526,537,548,558,569,579,
590,600,610,620,630,640,650,659,669,678,
688,697,706,715,724,733,742,750,759,767,
775,784,792,799,807,815,822,830,837,844,
851,858,865,872,878,885,891,897,903,909,
915,920,926,931,936,941,946,951,955,960,
964,968,972,976,980,983,987,990,993,996,
999,1002,1004,1007,1009,1011,1013,1015,1016,1018,
1019,1020,1021,1022,1023,1023,1024,1024,1024,1024,
1024,1023,1023,1022,1021,1020,1019,1018,1016,1015,
1013,1011,1009,1007,1004,1002,999,996,993,990,
987,983,980,976,972,968,964,960,955,951,
946,941,936,931,926,920,915,909,903,897,
891,885,878,872,865,858,851,844,837,830,
822,815,807,799,792,784,775,767,759,750,
742,733,724,715,706,697,688,678,669,659,
650,640,630,620,610,600,590,579,569,558,
548,537,526,516,505,494,483,472,460,449,
438,426,415,403,392,380,369,357,345,333,
321,309,297,285,273,261,249,237,224,212,
200,187,175,163,150,138,125,113,100,88,
75,63,50,38,25,13
};
#endif
#if LENGTH==1024
//计算余弦用的表,放大了1024倍(1024点FFT时用)
const short int COS_TABLE[LENGTH/2]=
{
1024,1024,1024,1024,1024,1024,1023,1023,1023,1022,
1022,1022,1021,1021,1020,1020,1019,1018,1018,1017,
1016,1016,1015,1014,1013,1012,1011,1010,1009,1008,
1007,1006,1004,1003,1002,1000,999,998,996,995,
993,992,990,989,987,985,983,982,980,978,
976,974,972,970,968,966,964,962,960,958,
955,953,951,948,946,944,941,939,936,934,
931,928,926,923,920,917,915,912,909,906,
903,900,897,894,891,888,885,882,878,875,
872,868,865,862,858,855,851,848,844,841,
837,834,830,826,822,819,815,811,807,803,
799,796,792,788,784,779,775,771,767,763,
759,755,750,746,742,737,733,729,724,720,
715,711,706,702,697,692,688,683,678,674,
669,664,659,654,650,645,640,635,630,625,
620,615,610,605,600,595,590,584,579,574,
569,564,558,553,548,543,537,532,526,521,
516,510,505,499,494,488,483,477,472,466,
460,455,449,443,438,432,426,421,415,409,
403,398,392,386,380,374,369,363,357,351,
345,339,333,327,321,315,309,303,297,291,
285,279,273,267,261,255,249,243,237,230,
224,218,212,206,200,194,187,181,175,169,
163,156,150,144,138,132,125,119,113,107,
100,94,88,82,75,69,63,57,50,44,
38,31,25,19,13,6,0,-6,-13,-19,
-25,-31,-38,-44,-50,-57,-63,-69,-75,-82,
-88,-94,-100,-107,-113,-119,-125,-132,-138,-144,
-150,-156,-163,-169,-175,-181,-187,-194,-200,-206,
-212,-218,-224,-230,-237,-243,-249,-255,-261,-267,
-273,-279,-285,-291,-297,-303,-309,-315,-321,-327,
-333,-339,-345,-351,-357,-363,-369,-374,-380,-386,
-392,-398,-403,-409,-415,-421,-426,-432,-438,-443,
-449,-455,-460,-466,-472,-477,-483,-488,-494,-499,
-505,-510,-516,-521,-526,-532,-537,-543,-548,-553,
-558,-564,-569,-574,-579,-584,-590,-595,-600,-605,
-610,-615,-620,-625,-630,-635,-640,-645,-650,-654,
-659,-664,-669,-674,-678,-683,-688,-692,-697,-702,
-706,-711,-715,-720,-724,-729,-733,-737,-742,-746,
-750,-755,-759,-763,-767,-771,-775,-779,-784,-788,
-792,-796,-799,-803,-807,-811,-815,-819,-822,-826,
-830,-834,-837,-841,-844,-848,-851,-855,-858,-862,
-865,-868,-872,-875,-878,-882,-885,-888,-891,-894,
-897,-900,-903,-906,-909,-912,-915,-917,-920,-923,
-926,-928,-931,-934,-936,-939,-941,-944,-946,-948,
-951,-953,-955,-958,-960,-962,-964,-966,-968,-970,
-972,-974,-976,-978,-980,-982,-983,-985,-987,-989,
-990,-992,-993,-995,-996,-998,-999,-1000,-1002,-1003,
-1004,-1006,-1007,-1008,-1009,-1010,-1011,-1012,-1013,-1014,
-1015,-1016,-1016,-1017,-1018,-1018,-1019,-1020,-1020,-1021,
-1021,-1022,-1022,-1022,-1023,-1023,-1023,-1024,-1024,-1024,
-1024,-1024
};
//计算正弦用的表,放大了1024倍(1024点FFT时用)
const short int SIN_TABLE[LENGTH/2]=
{
0,6,13,19,25,31,38,44,50,57,
63,69,75,82,88,94,100,107,113,119,
125,132,138,144,150,156,163,169,175,181,
187,194,200,206,212,218,224,230,237,243,
249,255,261,267,273,279,285,291,297,303,
309,315,321,327,333,339,345,351,357,363,
369,374,380,386,392,398,403,409,415,421,
426,432,438,443,449,455,460,466,472,477,
483,488,494,499,505,510,516,521,526,532,
537,543,548,553,558,564,569,574,579,584,
590,595,600,605,610,615,620,625,630,635,
640,645,650,654,659,664,669,674,678,683,
688,692,697,702,706,711,715,720,724,729,
733,737,742,746,750,755,759,763,767,771,
775,779,784,788,792,796,799,803,807,811,
815,819,822,826,830,834,837,841,844,848,
851,855,858,862,865,868,872,875,878,882,
885,888,891,894,897,900,903,906,909,912,
915,917,920,923,926,928,931,934,936,939,
941,944,946,948,951,953,955,958,960,962,
964,966,968,970,972,974,976,978,980,982,
983,985,987,989,990,992,993,995,996,998,
999,1000,1002,1003,1004,1006,1007,1008,1009,1010,
1011,1012,1013,1014,1015,1016,1016,1017,1018,1018,
1019,1020,1020,1021,1021,1022,1022,1022,1023,1023,
1023,1024,1024,1024,1024,1024,1024,1024,1024,1024,
1024,1024,1023,1023,1023,1022,1022,1022,1021,1021,
1020,1020,1019,1018,1018,1017,1016,1016,1015,1014,
1013,1012,1011,1010,1009,1008,1007,1006,1004,1003,
1002,1000,999,998,996,995,993,992,990,989,
987,985,983,982,980,978,976,974,972,970,
968,966,964,962,960,958,955,953,951,948,
946,944,941,939,936,934,931,928,926,923,
920,917,915,912,909,906,903,900,897,894,
891,888,885,882,878,875,872,868,865,862,
858,855,851,848,844,841,837,834,830,826,
822,819,815,811,807,803,799,796,792,788,
784,779,775,771,767,763,759,755,750,746,
742,737,733,729,724,720,715,711,706,702,
697,692,688,683,678,674,669,664,659,654,
650,645,640,635,630,625,620,615,610,605,
600,595,590,584,579,574,569,564,558,553,
548,543,537,532,526,521,516,510,505,499,
494,488,483,477,472,466,460,455,449,443,
438,432,426,421,415,409,403,398,392,386,
380,374,369,363,357,351,345,339,333,327,
321,315,309,303,297,291,285,279,273,267,
261,255,249,243,237,230,224,218,212,206,
200,194,187,181,175,169,163,156,150,144,
138,132,125,119,113,107,100,94,88,82,
75,69,63,57,50,44,38,31,25,19,
13,6
};
#endif
#endif
/********************************************************************
函数功能:对指定长度的二进制数求对应的位倒置值。
入口参数:N:要求倒序的值。L:bit数。
返 回:N的位倒置值。
备 注:无。
********************************************************************/
LEN_TYPE DoBitRev(LEN_TYPE N, LEN_TYPE L)
{
LEN_TYPE Temp1,Temp2;
LEN_TYPE i;
for(i=0;i<L/2;i++)
{
Temp1=0;
Temp2=0;
if(N&(1<<i))
Temp1=1;
if(N&(1<<(L-1-i)))
Temp2=1;
N&=~(1<<i);
N&=~(1<<(L-1-i));
N|=(Temp2<<i);
N|=(Temp1<<(L-1-i));
}
return N;
}
/////////////////////////End of function/////////////////////////////
/********************************************************************
函数功能:初始化位倒置值数组,供FFT运算时查表用。
入口参数:无。
返 回:无。
备 注:结果保存在全局变量BitRev数组中。
********************************************************************/
void FFT_Init(void)
{
LEN_TYPE i;
for(i=0;i<LENGTH;i++) //求位反转
{
BitRev[i]=DoBitRev(i,bL);
}
}
/////////////////////////End of function/////////////////////////////
/********************************************************************
函数功能:对输入数据进行倒序处理。
入口参数:pIn:要处理的数据缓冲区地址。
返 回:无。
备 注:在调用FFT_Output之前应该调用该函数对数据进行倒序处理。
********************************************************************/
void FFT_Input(IN_TYPE *pIn)
{
LEN_TYPE i;
IN_TYPE Temp;
for(i=0;i<LENGTH;i++)
{
if(BitRev[i]>i) //如果倒位序比原序大,则交换
{
Temp=pIn[i];
pIn[i]=pIn[BitRev[i]];
pIn[BitRev[i]]=Temp;
}
}
}
/////////////////////////End of function/////////////////////////////
/********************************************************************
函数功能 FFT输出。
入口参数:pIn:输入数据的缓冲区;pRe:保存实部的缓冲区;pIm:保存虚部的缓冲区。
返 回:无。
备 注:在调用该函数之前应该调用FFT_Input函数对数据进行倒序处理。
********************************************************************/
void FFT_Output(IN_TYPE *pIn, OUT_TYPE *pRe, OUT_TYPE *pIm)
{
LEN_TYPE i,j;
LEN_TYPE BlockSize;
OUT_TYPE tr,ti;
LEN_TYPE OffSet1,OffSet2;
#ifdef USE_TABLE
LEN_TYPE OffSet0;
#endif
long c,s;
//先计算2点的
for(j=0;j<LENGTH;j+=2)
{
tr=pIn[j+1];
pRe[j+1]=(pIn[j]-tr);
pIm[j+1]=0;
pRe[j]=(pIn[j]+tr);
pIm[j]=0;
}
for(BlockSize=4;BlockSize<=LENGTH;BlockSize<<=1) //再一层层计算
{
for(j=0;j<LENGTH;j+=BlockSize)
{
for(i=0;i<BlockSize/2;i++)
{
#ifndef USE_TABLE
c=(long)(1024*cos(2*PI*i/BlockSize));
s=(long)(1024*sin(2*PI*i/BlockSize));
#else
OffSet0=LENGTH/BlockSize*i;
c=COS_TABLE[OffSet0];
s=SIN_TABLE[OffSet0];
#endif
OffSet1=i+j;
OffSet2=OffSet1+BlockSize/2;
tr=(OUT_TYPE)((c*pRe[OffSet2]+s*pIm[OffSet2])/1024);
ti=(OUT_TYPE)((c*pIm[OffSet2]-s*pRe[OffSet2])/1024);
#ifdef UNITARY //如果要对结果归一化处理,则每次运算要除以2
pRe[OffSet2]=(pRe[OffSet1]-tr)/2;
pIm[OffSet2]=(pIm[OffSet1]-ti)/2;
pRe[OffSet1]=(pRe[OffSet1]+tr)/2;
pIm[OffSet1]=(pIm[OffSet1]+ti)/2;
#else
pRe[OffSet2]=(pRe[OffSet1]-tr);
pIm[OffSet2]=(pIm[OffSet1]-ti);
pRe[OffSet1]=(pRe[OffSet1]+tr);
pIm[OffSet1]=(pIm[OffSet1]+ti);
#endif
}
}
}
#ifdef UNITARY
pRe[0]/=2;
pIm[0]/=2;
#endif
}
/////////////////////////End of function/////////////////////////////
IN_TYPE InBuffer[LENGTH];
OUT_TYPE Re[LENGTH];
OUT_TYPE Im[LENGTH];
unsigned char Peak[64];
unsigned char PeakTime[64];
#define HOLD_TIME 5
/*============================================================================*/
/********************************************************************
函数功能:对需要显示的峰值进行处理。
入口参数:x:横坐标;y:纵坐标值。
返 回:无。
备 注:无。
********************************************************************/
void ProcPeak(int x, int y)
{
if(PeakTime[x]>0)
{
PeakTime[x]--;
}
else
{
if(Peak[x]>0)
{
Peak[x]--;
}
}
if(y>Peak[x])
{
Peak[x] =y; //修改峰值
PeakTime[x] =HOLD_TIME; //保持
}
}
/*============================================================================*/
void FFT_Show(HDC hdc,int x0,int y0,int dy,COLORREF pk_color,COLORREF fr_color,COLORREF bk_color)
{
int i,x,y,j,p;
////
FillRectangle(hdc,x0,y0,64,dy,bk_color);
x=x0;
y=((dy)-(Re[0]*dy/LENGTH)/1024);
y=MAX(y0,MIN(y+y0,dy+y0-1));
VLine(hdc,x,y,dy+y0,fr_color);
ProcPeak(0,y0+dy-y);
for(i=1;i<64;i++)
{
x++;
y=sqrt(Re[i]*Re[i]+Im[i]*Im[i]);
y/=10;
y=sqrt(y);
y=dy-y;
y=MAX(y0,MIN(y+y0,dy+y0-1));
VLine(hdc,x,y,dy+y0,fr_color);
ProcPeak(i,y0+dy-y);
}
for(i=0;i<64;i++)
{
y=MAX(y0,MIN(dy-Peak[i]+y0,dy+y0-1));
PutPixel(hdc,i+x0,y,pk_color);
}
}
/*============================================================================*/
#define IDC_ADC0 0x1000
#define IDC_ADC1 0x1001
#define IDC_ADC2 0x1002
#define IDC_ADC3 0x1003
#define IDC_TIMER 0x2000
/*============================================================================*/
HDC hdc_fft;
int adc_ch;
static RESULT WinProc(HWND hwnd,U32 msg,WPARAM wParam,LPARAM lParam)
{
int i,j;
HDC hdc;
RECT rc,m_rc[4];
switch(msg)
{
case MSG_CREATE:
GetClientRect(hwnd,&rc);
GetMatrixRectangle(m_rc,0,rc.dy-20,rc.dx,16,4,1,4,2);
CreateWindow("radiobutton",hwnd,m_rc[0].x,m_rc[0].y,m_rc[0].dx,m_rc[0].dy,0,IDC_ADC0,"ADC0");
CreateWindow("radiobutton",hwnd,m_rc[1].x,m_rc[1].y,m_rc[1].dx,m_rc[1].dy,0,IDC_ADC1,"ADC1");
CreateWindow("radiobutton",hwnd,m_rc[2].x,m_rc[2].y,m_rc[2].dx,m_rc[2].dy,0,IDC_ADC2,"ADC2");
CreateWindow("radiobutton",hwnd,m_rc[3].x,m_rc[3].y,m_rc[3].dx,m_rc[3].dy,0,IDC_ADC3,"ADC3");
SendMessage(GetWindowItem(hwnd,IDC_ADC0),MSG_SETVALUE,1,0);
FFT_Init();
adc_ch =0;
hdc_fft =CreateMemDC(64,48);
ClrScreen(hdc_fft,RGB(0,0,0));
SetTimer(hwnd,IDC_TIMER,100,0);
break;
////////
case MSG_COMMAND:
{
U16 code,id;
code =HIWORD(wParam);
id =LOWORD(wParam);
switch(id)
{
case IDC_ADC0:
adc_ch=0;
break;
////
case IDC_ADC1:
adc_ch=1;
break;
////
case IDC_ADC2:
adc_ch=2;
break;
////
case IDC_ADC3:
adc_ch=3;
break;
}
}
break;
////////
case MSG_TIMER:
for(i=0;i<LENGTH;i++)
{
InBuffer[i]=GetAddata(adc_ch);
for(j=1000;j>0;j--);
}
FFT_Input(InBuffer);
FFT_Output(InBuffer,Re,Im);
FFT_Show(hdc_fft,0,0,48,RGB(0,255,255),RGB(255,40,40),RGB(0,0,0));
InvalidateRect(hwnd,0,0);
break;
////////
case MSG_PAINT:
hdc =BeginPaint(hwnd);
if(hdc)
{
GetClientRect(hwnd,&rc);
StretchBlt(hdc,0,0,rc.dx,rc.dy-24,hdc_fft,0,0,64,48,SRCCOPY);
}
EndPaint(hwnd,hdc);
break;
////////
case MSG_CLOSE:
ReleaseDC(hdc_fft);
KillTimer(hwnd,IDC_TIMER);
DestroyWindow(hwnd);
break;
////////
default:
return DefaultWindowProc(hwnd,msg,wParam,lParam);
}
}
/*============================================================================*/
/*============================================================================*/
int WinMain(HANDLE handle,void *argv)
{
HWND hwnd;
MSG msg;
WNDCLASS wcls;
////
wcls.Name =(char*)__Name;
wcls.Style =WS_CAPTION|WS_BORDER_DUAL;
wcls.ExStyle =0;
wcls.ExData =0;
wcls.hCursor =0;
wcls.BkColor =RGB(160,160,160);
wcls.Proc =WinProc;
hwnd =CreateMainWindow(&wcls, 20,30,240,160);
ShowWindow(hwnd,SW_SHOW);
while(GetMessage(&msg,hwnd))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} |