save as *.cpp,and compile it again
解决方案 »
- 请问CLSCTX_INPROC是什么意思?
- 请教大家一个对话框调图片的问题哈~~~
- 急!!!dll中对话框类中可否调用主线程中的变量,即app里面的变量,怎样调用?
- 局域网 时间同步的代码
- 如何在程序运行时隐藏主窗口?
- 请各位高手传授过英语四级的速成方法!
- 很急的一个问题,怎样屏蔽掉esc键?再线等待,谢谢了!
- MFC和STL区别
- 如何在jv中调用 com Dll, 急! 在线等待!!!
- 为什么我的pButton->SetIcon(m_hIcon)后,Button上的图标背景是黑的?!!!!!!!!!!!!!!!!!!!!!!
- 请问各位大吓:在组播应用中,一台主机能否同时加入两个组,并将同一份数据传给不同的组?
- 我想学VC和VC.net
然后看看你错在那里。
#include <windowsx.h>
#include <windows.h>
//#include <stdafx.h>
#include <stdio.h>
#include <math.h>#define WINDOW_CLASS_NAME "WINCLASS1"
//globals//functions
//--------------------
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{ //系统信息句柄
PAINTSTRUCT ps;
HDC hdc;
//What is the message?
switch(msg)
{
case WM_CREATE:
{
return(0);
}break;
case WM_PAINT:
{
hdc=BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps);
return(0);
}break;
case WM_DESTROY:
{
PostQuitMessage(0); return(0);
}break;
default :{
return (0);
//return RegisterClassEx(&winclass);
//return hwnd;
return DefWindowProc(hwnd, msg, wparam, lparam);
}break;
}
}
//--------------------
//winmain函数int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
//定义WNDCLASSEX类对象;
WNDCLASSEX winclass;
//定义窗口句柄
HWND hwnd;
//定义消息
MSG msg; winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS|CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
//winclass.style=CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
//winclass.hbrBackground=GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName=NULL;
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION); RegisterClassEx(&winclass);
if(!RegisterClassEx(&winclass))
return(0); //if(!(hwnd=// MessageBox(NULL,"there can be only one!!",
// "my first windwos program",
// MB_OK|MB_ICONEXCLAMATION);
// return(0);
//creat the window
// TCHAR szWindowClass[MAX_LOADSTRING]; hwnd=CreateWindowEx(0,//NULL,
//NDOW_CLASS_NAME,
"WINCLASS",
"your basic windwo",
WS_OVERLAPPEDWINDOW,//WS_OVERLAPPEDWINDOW|WS_VISIBLE,
50,50,//x,y
400,400,//width,high
NULL,
NULL,
hinstance,
//winclass,
NULL);
ShowWindow(hwnd,ncmdshow);
UpdateWindow(hwnd);
if(!hwnd)
{
//ShowWindow(hwnd,ncmdshow);
return (0);
}
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
return (msg.wParam);
}
return (0);
}
谢谢!
修改
/subsystem:console 为 /subsystem:windows
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
return (msg.wParam);
^^^^^^^^-^^^^^^^^^^^^
|---------------->程序运行一下子就结束了。
}
改为:
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
RegisterClassEx(&winclass);
一句返回为0;
不知道怎么回事?