| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 283 人关注过本帖
标题:各位大仙帮帮忙吧
取消只看楼主 加入收藏
星辰月
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-11-4
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
各位大仙帮帮忙吧
#include<Windows.h>
#include<stdio.h>
LRESULT CALLBACK WindowProc(          HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
);
int WINAPI WinMain(          HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
    WNDCLASSEX wcex;
    wcex.cbSize=sizeof(WNDCLASSEX);
    wcex.style=WS_HSCROLL|WS_VSCROLL|WS_POPUP;
    wcex.lpfnWndProc=WindowProc;
    wcex.cbClsExtra=0;
    wcex.cbWndExtra=0;
    wcex.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.hCursor=LoadCursor(NULL,IDC_CROSS);
    wcex.hIcon=LoadIcon(NULL,ERROR);
    wcex.hInstance=hInstance;
    wcex.lpszClassName=L"chuanchuan";
    wcex.lpszMenuName=NULL;
    wcex.hIconSm=LoadIcon(wcex.hInstance,MAKEINTRESOURCE(IDI_APPLICATION));
    RegisterClassEx(&wcex);

    HWND hwnd;
    hwnd=CreateWindowEx(WS_EX_ACCEPTFILES,L"WindowProc",L"chuanchuan",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);

    ShowWindow(hwnd,SW_SHOWNORMAL);
    UpdateWindow(hwnd);

    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
LRESULT CALLBACK WindowProc(          HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
    )
{
    switch(uMsg)
    {
        case WM_CHAR:
            MessageBoxEx(hwnd,L"shijietafuza",L"wushouchuan",0,0);
            break;
        case WM_LBUTTONDOWN:
            MessageBoxEx(hwnd,L"shengming",L"wushouchuan",0,0);
            HDC hdc;
            hdc=GetDC(hwnd);
            TextOut(hdc,0,50,L"chuangege",strlen("chuangege"));
            ReleaseDC(hwnd,hdc);
            break;
        case WM_PAINT:
            PAINTSTRUCT ps;
            hdc=BeginPaint(hwnd,&ps);
            TextOut(hdc,0,100,L"aiqing",strlen("aiqing"));
            EndPaint(hwnd,&ps);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        case WM_CLOSE:
            if(IDYES==MessageBoxEx(hwnd,L"shifoutuichu",L"wushouchuan",MB_YESNO,0))
            {
                DestroyWindow(hwnd);
            }
            break;
        default:
            return DefWindowProc(hwnd,uMsg,wParam,lParam);
            break;
    }
    return 0;
}


这个程序可以生成,调试也没错,但是没法显示出来窗口,求各位大仙指教
搜索更多相关主题的帖子: include include 
2012-11-04 23:35
星辰月
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-11-4
收藏
得分:0 
以下是引用newdos在2012-11-5 11:31:32的发言:

WNDCLASSEX wcex;
    ZeroMemory(&wcex, sizeof(wcex));
 
    wcex.cbSize=sizeof(WNDCLASSEX);
    wcex.style= CS_HREDRAW | CS_VREDRAW; //WS_HSCROLL|WS_VSCROLL|WS_POPUP;
    wcex.lpfnWndProc=WindowProc;
    wcex.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.hCursor=LoadCursor(NULL,IDC_CROSS);
    wcex.hIcon=LoadIcon(NULL,ERROR);
    wcex.hInstance=hInstance;
    wcex.lpszClassName=L"chuanchuan";
    wcex.lpszMenuName=NULL;
    wcex.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
    if(!RegisterClassEx(&wcex))
        printf("reg error!\n");
 
    HWND hwnd;
    hwnd=CreateWindowEx(WS_EX_ACCEPTFILES,L"chuanchuan",L"WindowProc",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
    if(!hwnd) printf("error create\n");
3q,3q,3q,,,,
2012-11-05 23:17
快速回复:各位大仙帮帮忙吧
数据加载中...
 
   



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

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