VC++新手请教简单问题
怎么显示出x,y的值#include <windows.h>
#include<stdio.h>
#include<dshow.h>
#include<wingdi.h>
//#include "resource.h
BYTE *fdata1;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
HWND hWnd2;
HINSTANCE hs2;
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 = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox ( NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow( szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
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 ;
RECT rect ;
//int Gray;
float Gray1;
BYTE Gray;
int R,G,B;
FILE *fp9;
int i,j,x,y,m;
int sum1=0;
int sum2=0;
m=1;
//COLORREF rgb;
fdata1=(BYTE*)malloc(460827*2);
if ((fp9=fopen("StillCap.bmp","r"))==NULL)
{
printf("cannot open the file.\n");
exit(1);
}
fread(fdata1,640*480*3+54,1,fp9);
printf("fdata1=%d\n",fdata1);
fclose(fp9);
for(i=0;i<325;i++)
{
for(j=480;j>0;j--)
{
B= (int)(*(fdata1+54+640*(480-j)*3));
G = (int)(*(fdata1+54+640*(480-j)*3+1));
R= (int)(*(fdata1+54+640*(480-j)*3+2));
Gray1=0.299*R+0.587*G+0.114*B;//使用浮点计算
if(Gray1>=120)
{
sum1+=i;
sum2+=j;
m++;
}
}
}
x=sum1/m;
y=sum2/m;
switch (message)
{
case WM_CREATE:
return x,y;
//return 0 ;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
SetDIBitsToDevice (
hdc, // device context handle
0, // x destination coordinate
0, // y destination coordinate
640, // source rectangle width
480, // source rectangle height
0, // x source coordinate
0, // y source coordinate
0, // first scan line to draw
480, // number of scan lines to draw
fdata1+54, // pointer to DIB pixel bits
(BITMAPINFO*)(fdata1+14), // pointer to DIB information
DIB_RGB_COLORS) ; // color use flag
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}