用api啊
是不是做sdk程序?

解决方案 »

  1.   

    // simpwin.cpp : Defines the entry point for the application.
    //
    //  #include "simwin.h"
    #include "menu.h"
    #include <string.h>
    #include <windows.h>
    LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM);
    BOOL InitApplication(HINSTANCE);
    BOOL InitInstance(HINSTANCE,int);
    char *hello="窗口外的世界很精彩,窗口外的的天地也很奇妙";HINSTANCE hInst;
    HWND hWndMain;
    int APIENTRY WinMain(
     HINSTANCE hInstance,
     HINSTANCE hPrevInstance,
     LPSTR     lpCmdLine,
     int       nCmdShow)
    {
    MSG msg;
    InitApplication(hInstance);//定义窗口
    // return (TRUE);
    // if (!InitInstance(hInstance,nCmdShow))
    InitInstance(hInstance,nCmdShow);//创建窗口
    // return (FALSE);
    while(GetMessage(&msg,
    NULL,
    0,
    0))
    {
     TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return (msg.wParam );
    }
    BOOL InitApplication(HINSTANCE hInstance)//定义窗口
    {
    WNDCLASS wc;
    wc.style =CS_DBLCLKS;
      wc.lpfnWndProc =(WNDPROC)MainWndProc;
    wc.cbClsExtra =0;
    wc.cbWndExtra =0;
    wc.hInstance =hInstance;
    wc.hIcon =LoadIcon(NULL,IDI_ASTERISK);
    wc.hCursor =LoadCursor(NULL,IDC_ARROW);
    wc.hbrBackground =(HBRUSH)GetStockObject(GRAY_BRUSH);
    wc.lpszMenuName ="MENUAPPMENU";
    wc.lpszClassName ="WC";//SimpwinWclass";
    return (RegisterClass(&wc));
    }
    BOOL InitInstance(
      HINSTANCE hInstance,
      int nCmdShow)
    {
    hInst=hInstance;
    hWndMain=CreateWindow("WC",
    "我的窗口",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
    NULL,NULL,hInstance,NULL);
    if(!hWndMain)
    return(FALSE);
    ShowWindow(hWndMain,nCmdShow);
    UpdateWindow(hWndMain);
    return (TRUE);
    }
    LRESULT CALLBACK MainWndProc(
     HWND hWnd,
     UINT message,
     WPARAM wParam,
     LPARAM lParam)
    {
      HDC hdc;
      PAINTSTRUCT ps;
      switch (message)
    {
      case WM_PAINT:
        hdc=BeginPaint(hWnd,&ps);
      TextOut(hdc,20,10,hello,lstrlen(hello));
      EndPaint(hWnd,&ps);
      break;
      case WM_DESTROY:
       PostQuitMessage(0);
    break;
    case IDM_EXIT :
    PostQuitMessage(0);
      break;  
    case IDM_EDITUNDO:
    hdc=BeginPaint(hWnd,&ps);
      TextOut(hdc,40,30,hello,lstrlen(hello));
      EndPaint(hWnd,&ps);
    break;
     default:
      return (DefWindowProc(hWnd,message,wParam,lParam));
    }
    return (0);
    }
      

  2.   

    用createwindow函数,或者从cwnd,cview等派生一个类,调用create函数
    具体的参数参见msdn