| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 439 人关注过本帖
标题:一个VC程序,我也调不出错误在哪,希望高手指点!!!
只看楼主 加入收藏
jiyuchonger
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-3-1
收藏
 问题点数:0 回复次数:1 
一个VC程序,我也调不出错误在哪,希望高手指点!!!
#include <windows.h>

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
DWORD WINAPI MyThread(LPVOID lpParameter);

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
    WNDCLASSEX wndclass;
    static char szAppName[] = "Hello Everyone";
    wndclass.cbSize = sizeof(wndclass);
    wndclass.style = CS_HREDRAW|CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
    wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName = NULL;
    wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
    RegisterClassEx(&wndclass);

    DWORD dw;
    HANDLE handle;
    handle = CreateThread(NULL,0,MyThread,(LPVOID)&wndclass,0,&dw);

    CloseHandle(handle);
    ::MyThread(&wndclass);

    return 0;

}

DWORD WINAPI MyThread(LPVOID lpParameter)
{
    HWND hWnd;
    MSG msg;
    WNDCLASSEX * pw = (WNDCLASSEX *) lpParameter;

    hWnd = CreateWindow(pw->lpszClassName,"My Hello Program",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,pw->hInstance,NULL);
    ShowWindow(hWnd,SW_SHOWNORMAL);

    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
    HDC dc;
    PAINTSTRUCT ps;
    RECT rect;

    switch(iMessage)
    {
    case WM_PAINT:
        dc = BeginPaint(hWnd,&ps);
        GetClientRect(hWnd,&rect);
        DrawText(dc,"Hello,Everyone",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
        EndPaint(hWnd,&ps);
        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd,iMessage,wParam,lParam);
    }

    return (0);
}









求指点。
搜索更多相关主题的帖子: include 
2010-09-22 18:39
ml232528
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:367
专家分:879
注 册:2007-7-23
收藏
得分:0 
窗口没名字 加上

wndclass.lpszClassName = szAppName;

-︻┻┳═一 ☆ 悲伤的代价就是让自己明白什么是最重要的和应该珍惜的
2010-09-24 00:01
快速回复:一个VC程序,我也调不出错误在哪,希望高手指点!!!
数据加载中...
 
   



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

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