| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 481 人关注过本帖
标题:关于窗口问题的
只看楼主 加入收藏
luochao1988
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-10-23
收藏
 问题点数:0 回复次数:0 
关于窗口问题的
先谢谢你咯,回复的“老师”!我这里还有一个关于窗口的问题?谢谢咯,大虾!
  这个程序就这样执行不起,但是把我标注的话出去就行咯(算咯直接复制跟你哈!)嘿嘿

 #include<windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMessage,UINT wParam,LONG lParam)
{
    HDC hdc;
    HBRUSH hBrush;
    HPEN hPen;
    PAINTSTRUCT Pt;
    switch(iMessage)
    {
    case WM_PAINT:
            hdc=BeginPaint(hwnd,&Pt);
            SetMapMode(hdc,MM_ANISOTROPIC);
            hPen=(HPEN)GetStockObject(BLACK_PEN);
            SelectObject(hdc,hPen);
            hBrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
            RoundRect(hdc,50,50,100,150,15,14);
            hBrush=(HBRUSH)GetStockObject(HOLLOW_BRUSH);
            SelectObject(hdc,hBrush);
            Pie(hdc,250,50,300,100,250,50,300,50);
            EndPaint(hwnd,&Pt);
            return 0;
    case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    default:
        return(DefWindowProc(hwnd,iMessage,wParam,lParam));
    }
}

BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
    HWND hwnd;
    hwnd=CreateWindow("winfill","填充示例程序",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
    if(!hwnd)
        return FALSE;
    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);
    return TRUE;
}

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="winfil";
    WndClass.lpszMenuName=NULL;
    WndClass.style=CS_HREDRAW|CS_VREDRAW;
    return RegisterClass(&WndClass);
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,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;
}


/******************************改后的程序*****/
 #include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WinSunProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);

int WINAPI WinMain(
  HINSTANCE hInstance,      // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,          // command line
  int nCmdShow              // show state
)
{
    WNDCLASS wndcls;
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
    wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndProc=WinSunProc;
    wndcls.lpszClassName="Weixin2003";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndcls);

    HWND hwnd;
    hwnd=CreateWindow("Weixin2003","北京心",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 WinSunProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
)
{
    HDC hdc;
    PAINTSTRUCT Pt;
    HPEN hPen;
    HBRUSH hBrush;

    switch(uMsg)
    {
    case WM_CHAR:
        
        break;
    case WM_LBUTTONDOWN:
        
        break;
    case WM_PAINT:


            hdc=BeginPaint(hwnd,&Pt);
            SetMapMode(hdc,MM_ANISOTROPIC);
            hPen=(HPEN)GetStockObject(BLACK_PEN);
            SelectObject(hdc,hPen);
            hBrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
            RoundRect(hdc,50,50,100,150,15,14);
            hBrush=(HBRUSH)GetStockObject(HOLLOW_BRUSH);
            SelectObject(hdc,hBrush);
            Pie(hdc,250,50,300,100,250,50,300,50);
            EndPaint(hwnd,&Pt);
            return 0;


        break;
    case WM_CLOSE:
        if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
        {
            DestroyWindow(hwnd);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }
    return 0;
}
搜索更多相关主题的帖子: 窗口 
2008-10-23 23:34
快速回复:关于窗口问题的
数据加载中...
 
   



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

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