代码改错

来源:百度知道 编辑:UC知道 时间:2024/05/04 22:42:59
#include <windows.h>
#include <string>

string MenuName = "NULL";
string Windowclass = "w32";
string Tit = "jiandan";
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hprevInstance,LPSTR lpCmdLine,int nShowCmd)
{
MSG msg;
WNDCLASS wc;
wc.style =CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)|WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = MenuName;
wc.lpszClassName = WindowClass;
RegisterClass(&wc);
HWND hwnd;
hwnd = GreateWindow(
WindowClass,
Tit,
WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInsta

呵呵,错误非常多啊!有打错字的,比如CreateWindows,把C写成了G;还有漏了“)”,还有一些基本概念的错误……非常非常多……都不知从何说起。
干脆直接把我写的源码给你看吧。注意:和你的程序有多处不同,但大致一个效果:在屏幕上显示一个窗口,上边写着“Hello”,源代码如下,你可以自己对照着我写的,把你的程序改一下:

#include <windows.h>
#include <string.h>
HWND hWnd;
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hprevInstance,LPSTR lpCmdLine,int nShowCmd)
{
MSG msg;
WNDCLASS wc;
wc.style =CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "w32";
RegisterClass(&wc);
hWnd = CreateWindow(
"w32",
"jiandan",
WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,
CW_USEDEFAULT,
CW