标题:在下面的代码中怎么加菜单和按钮?
只看楼主
xlykpj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-3-5
 问题点数:0 回复次数:0 
在下面的代码中怎么加菜单和按钮?
在下面的代码中怎么加菜单和按钮?
#include <windows.h>
#include <stdio.h>


LRESULT CALLBACK WinaaProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
);


int WINAPI WinMain(           
  HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR lpCmdLine,
  int nShowCmd
   )
{
    WNDCLASS wndcls;
    
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);
    wndcls.hIcon=LoadIcon(NULL,IDI_WINLOGO);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndProc=WinaaProc;
    wndcls.lpszClassName="sa";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    
     RegisterClass(&wndcls);
    
     HWND hwnd;
        
     hwnd=CreateWindow("sa","每日一做",WS_SYSMENU,300,20,
         300,500,NULL,NULL,hInstance,NULL);
    

     ShowWindow(hwnd,SW_SHOWNORMAL);

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

LRESULT CALLBACK WinaaProc(
  HWND hwnd,   
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
)
{
    HDC hdc;
    PAINTSTRUCT ps;
    switch(uMsg)
    {
    case WM_PAINT:
         hdc=BeginPaint(hwnd,&ps);
         EndPaint(hwnd,&ps);
    break;
    case WM_CLOSE:
            if (IDOK==MessageBox(hwnd,"你是否要退出?","每日一做",MB_OK))
            {
                DestroyWindow(hwnd);
            };
    break;
    case WM_DESTROY:  
            PostQuitMessage(0);
    break;
            
        default:
            return DefWindowProc(hwnd,uMsg,wParam,lParam);

    }
    return 0;
}
搜索更多相关主题的帖子: 代码中 按钮 菜单 wndcls BRUSH 
2008-07-26 23:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-225389-1-1.html




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

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