// MyWin.cpp : Defines the entry point for the application.
//#include "stdafx.h"//窗口函数说明
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
char lpszClassName[]="窗口";
char lpszTitle[]="手工写的窗口";
//获取屏幕的宽度与高度,让窗口铺满屏幕
int swidthSize=::GetSystemMetrics (SM_CXSCREEN);
int sheightSize=::GetSystemMetrics (SM_CYSCREEN);
//窗口类的定义
WNDCLASS wcts;
wcts.style =CS_VREDRAW | CS_HREDRAW;
wcts.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wcts.hIcon =LoadIcon(NULL,IDI_APPLICATION);
wcts.hCursor =LoadCursor(NULL,IDC_ARROW);
wcts.hInstance =hInstance;
wcts.cbWndExtra =0;
wcts.cbClsExtra =0;
wcts.lpszClassName  =lpszClassName;
wcts.lpszMenuName =NULL;
wcts.lpfnWndProc =(WNDPROC)WndProc; //窗口类的注册
if(!RegisterClass(&wcts))
{
return FALSE;
} //创建窗口
HWND hWnd;
hWnd=CreateWindow(lpszClassName,lpszTitle,WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
0,0,swidthSize,sheightSize,
NULL,NULL,hInstance,NULL);
if(!hWnd)
{
return FALSE;
}

//显示窗口
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);

//消息循环
MSG msg; while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} //返回操作系统
return msg.wParam ;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
    PostQuitMessage(0);  default:
return DefWindowProc(hwnd,message,wParam,lParam); }
return (0);}

解决方案 »

  1.   

    处理窗口的WM_PAINT消息,使用DrawText或TextOut可以写字;
    注册窗口类之前,
    wcts.lpszMenuName =NULL;
    改变上边这一句就可以为窗口配置菜单;
    处理窗口的WM_CREATE消息,使用CreateWindow或CreateWindowEx可以在窗口上创建按钮。给你推荐一本老书Programming Windows:
    http://titilima.nease.net/download/pwchs.zip
      

  2.   

    获取dc然后用
    DrawText可以随便写文本
    菜单,按钮请参阅其他书籍
    up