当前位置:编程学习 > C#/ASP.NET >>

我在vs2008中调试了一个程序 一直不行 希望大家帮帮忙 谢谢了~

代码如下:
#include "stdafx.h"
#include "ch4-1.h"





#define MAX_LOADSTRING 100

// 全局变量:
HINSTANCE hInst; // 当前实例
TCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本
TCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名
TCHAR szContents[100],szText1[4],szText2[4],szText3[4],szText4[4],szText5[4];
RECT m_rect;
int nPosition;
int nTimes;
int nFill;
// 此代码模块中包含的函数的前向声明:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

  // TODO: 在此放置代码。
MSG msg;
HACCEL hAccelTable;

// 初始化全局字符串
LoadString(hInstance,IDS_APP_TITLE,szTitle,MAX_LOADSTRING);
  LoadString(hInstance,IDS_WHERE,szWindowClass,MAX_LOADSTRING);
  LoadString(hInstance,IDS_APP_TITLE,szTitle,MAX_LOADSTRING);
  LoadString(hInstance,IDS_SELF_DISPLAY,szContents,100);
  LoadString(hInstance,IDS_SELF_DISPLAY_WEST,szText1,4);
  LoadString(hInstance,IDS_SELF_DISPLAY_EAST,szText2,4);
  LoadString(hInstance,IDS_SELF_DISPLAY_NORTH,szText3,4);
  LoadString(hInstance,IDS_SELF_DISPLAY_SOUTH,szText4,4);
  LoadString(hInstance,IDS_SELF_DISPLAY_MOVE,szText5,4);
  m_rect.left = 50;
  m_rect.right = 250;
  nPosition = 69;
  nTimes = 1;
  nFill=0;
  MyRegisterClass( hInstance);

// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WHERE));

// 主消息循环:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return (int) msg.wParam;
}



//
//  函数: MyRegisterClass()
//
//  目的: 注册窗口类。
//
//  注释:
//
//    仅当希望
//    此代码与添加到 Windows 95 中的“RegisterClassEx”
//    函数之前的 Win32 系统兼容时,才需要此函数及其用法。调用此函数十分重要,
//    这样应用程序就可以获得关联的
//    “格式正确的”小图标。
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WHERE));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_WHERE);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassEx(&wcex);
}

//
//   函数: InitInstance(HINSTANCE, int)
//
//   目的: 保存实例句柄并创建主窗口
//
//   注释:
//
//        在此函数中,我们在全局变量中保存实例句柄并
//        创建和显示主程序窗口。
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // 将实例句柄存储在全局变量中

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的: 处理主窗口的消息。
//
//  WM_COMMAND - 处理应用程序菜单
//  WM_PAINT - 绘制主窗口
//  WM_DESTROY - 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

switch (message)
{
case WM_COMMAND:
wmId    = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// 分析菜单选择:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: 在此添加任意绘图代码...
 //TODO:在此添加任意绘图代码...//书写必要的提示


 //先定义一个小矩形,在该矩形内按格式输出字符串“Guess where I am->猜猜我在哪儿?”
 //采用格式输出函数DrawText,字符串输出不必创建任何工具,直接用默认的字体字色输出
             RECT   rt;
             rt.bottom=40;    rt.top=20;   rt.left=20;   rt.right=300;
             DrawText(hdc,szContents,-1,&rt,DT_CENTER|DT_SINGLELINE|DT_VCENTER) ;
             //根据为游戏界面所设置的矩形,在其四周分别标示“东”“西”“南”“北”
 //采用按指定位置输出字符的函数TextOut,目的仅仅是为了示意不同函数的用法和效果
 int x,y;
             x=10;       y=(int)(m_rect.bottom-m_rect.top)/2+m_rect.top;
             TextOut(hdc,x,y,(LPCWSTR)szText1,1);
             x=m_rect.right+10;
             TextOut(hdc,x,y,(LPCWSTR)szText2,1);
             //创建画图的笔和刷子
 HPEN   hPen ,hOldPen;
             hPen=CreatePen(PS_INSIDEFRAME,1,RGB(0,0,0));
             LOGBRUSH    logbrush;
             HBRUSH  hBrush ,hOldBrush;
             logbrush.lbStyle=BS_SOLID;
             logbrush.lbColor=RGB(128,128,128);
             logbrush.lbHatch=HS_HORIZONTAL;
             hBrush=CreateBrushIndirect(&logbrush);
             hOldPen=(HPEN)SelectObject(hdc,hPen);
             hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
             Rectangle(hdc,m_rect.left,m_rect.top,m_rect.right,m_rect.bottom);


             int i;
             POINT point1,point2;
             point1.x =m_rect.left+20; point1.y=m_rect.top;
             point2.x =m_rect.left+20; point2.y=m_rect.bottom;
             for(i=1;i<10;i++){
             MoveToEx(hdc,point1.x,point1.y,(LPPOINT)NULL);
             LineTo(hdc,point2.x,point2.y);
             point1.y=m_rect.top;  point1.y=m_rect.bottom;
             point1.x =point1.x + 20; point2.x =point2.x + 20;
}
point1.x =m_rect.left; point1.y=m_rect.top+20;
point2.x =m_rect.right; point2.y=m_rect.top+20;
for(i=1;i<10;i++){
  MoveToEx(hdc,point1.x,point1.y,(LPPOINT)NULL);
  LineTo(hdc,point2.x,point2.y);
  point1.x=m_rect.left;  point2.x=m_rect.right;
  point1.y  =point1.y + 20; point2.y =point2.y + 20;
}
DeleteObject(hPen);
DeleteObject(hBrush);
SelectObject(hdc,hOldPen);
SelectObject(hdc,hOldBrush);
EndPaint(hWnd,&ps);
break;
case WM_DESTROY: PostQuitMessage(0);  break;
default:  return DefWindowProc(hWnd,message,wParam,lParam);
}

 system("pause"); 
return 0;
}

// “关于”框的消息处理程序。
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
一直出现:
“ch4-1.exe”: 已加载“C:\Users\TOSHIBA\Documents\Visual Studio 2008\Projects\Project1\ch4-1\Debug\ch4-1.exe”,已加载符号。
“ch4-1.exe”: 已加载“C:\Windows\System32\ntdll.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\kernel32.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\KernelBase.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\user32.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\gdi32.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\lpk.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\usp10.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\msvcrt.dll”
“ch4-1.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll”,已加载符号。
“ch4-1.exe”: 已加载“C:\Windows\System32\imm32.dll”
“ch4-1.exe”: 已加载“C:\Windows\System32\msctf.dll”
程序“[6524] ch4-1.exe: 本机”已退出,返回值为 0 (0x0)。

--------------------编程问答-------------------- 工程建错了! --------------------编程问答-------------------- 怎么建呢???求助??
补充:.NET技术 ,  VC.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,