| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 543 人关注过本帖
标题:vc应用程序提示错误
只看楼主 加入收藏
windcloud
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-4-18
收藏
 问题点数:0 回复次数:2 
vc应用程序提示错误
我的所有windows应用程序在运行时都会有一个ERROR,不知道是什么原因。
那它应该在哪里运行?
搜索更多相关主题的帖子: 应用程序 windows 提示 运行 
2007-04-27 21:52
windcloud
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-4-18
收藏
得分:0 
#include <windows.h>
#include <string.h>
#include <stdio.h>
LRESULT CALLLBACK WndProc(HWND hWnd,UNIT iMessage,UNIT wParam,LONG lParam);
BOOL InitWindowsClass(HINATANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,
int nCmdShow)
{
MSG Message;
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,UNIT wParam,LONG lParam)
{
static long nXChar,nCaps,nYChar;
HDC hdc;
short x;
TEXTMETRIC tm;
short LnCount=6;
PAINTSTRUCT PtStr;
static char *textbuf[]=
{
"This is the first line",
"This is the second line",
"This is the third line",
"This is the fourth line",
"This is the fifth line",
"This is the sixth line"
};
switch(iMessage)
{
case WM_CREATE:
hDC=GetDC(hWnd);
GetTextMetrics(hDC,&tm);
nXChar=tm.tmAveCharWidth;
nYChar=tm.tmHeight+tm.tmExternalLeading;
ReleaseDC(hWnd,hDC);
return 0;
case WM_PAINT:
hDC=BeginPaint(hWnd,&PtSr);
for(x=0;x<LnCount;x=x+1)
TextOut(hDC,nXChar,nYChar*(1+x),textbuf[x],lstrlen(textbuf[x]));
EndPaint(hWnd,&PtStr);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BTUSH));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"END");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName="WinText";
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREADRAW|CS_VREDRAW;
return RegisterClass(&WndClass);
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd=CreateWindow("WinText",
"文本显示示例程序",
WS_OVERLAPPENDWINDOWM,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}

各位大哥大姐,能否教教,偶愚昧。

2007-04-28 22:10
Janlex
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:303
专家分:0
注 册:2006-9-12
收藏
得分:0 

#include <windows.h>
#include <string.h>
#include <stdio.h>

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,
int nCmdShow)
{
MSG Message;
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam)
{
static long nXChar,nCaps,nYChar;
HDC hdc;
short x;
TEXTMETRIC tm;
short LnCount=6;
PAINTSTRUCT PtStr;
static char *textbuf[]=
{
"This is the first line",
"This is the second line",
"This is the third line",
"This is the fourth line",
"This is the fifth line",
"This is the sixth line"
};
switch(iMessage)
{
case WM_CREATE:
hdc=GetDC(hWnd);
GetTextMetrics(hdc,&tm);
nXChar=tm.tmAveCharWidth;
nYChar=tm.tmHeight+tm.tmExternalLeading;
ReleaseDC(hWnd,hdc);
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd,&PtStr);
for(x=0;x<LnCount;x=x+1)
TextOut(hdc,nXChar,nYChar*(1+x),textbuf[x],lstrlen(textbuf[x]));
EndPaint(hWnd,&PtStr);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"END");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName="WinText";
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW|CS_VREDRAW;
return RegisterClass(&WndClass);
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd=CreateWindow("WinText",
"文本显示示例程序",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}


★★★★★欢迎光临我的博客 ★★★★★
http://www.
2007-04-28 22:23
快速回复:vc应用程序提示错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022952 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved