Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1427284
  • 博文数量: 430
  • 博客积分: 9995
  • 博客等级: 中将
  • 技术积分: 4388
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-24 18:04
文章存档

2013年(1)

2008年(2)

2007年(14)

2006年(413)

分类:

2006-06-13 17:29:57

小超 @ 2004-10-25 16:50

#include

#include
#include
#include
#include
#include

#define MY_CTRL_NAME "mycontrol"

static int MyControlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
   HDC hdc;

   switch (message) {
   case MSG_PAINT:
       /* Output hello, world */
       hdc = BeginPaint (hwnd);
       TextOut (hdc, 0, 0, "Hello, world! - from my control.");
       EndPaint (hwnd, hdc);
       return 0;
   }

   return DefaultControlProc (hwnd, message, wParam, lParam);
}

static BOOL RegisterMyControl (void)
{
   WNDCLASS MyClass;

   MyClass.spClassName = MY_CTRL_NAME;
   MyClass.dwStyle     = 0;
   MyClass.hCursor     = GetSystemCursor (IDC_ARROW);
   MyClass.iBkColor    = COLOR_lightwhite;
   MyClass.WinProc     = MyControlProc;

   return RegisterWindowClass (&MyClass);
}

static void UnregisterMyControl (void)
{
   UnregisterWindowClass (MY_CTRL_NAME);
}

static int HelloWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
   switch (message) {
       case MSG_CREATE:
           CreateWindow (MY_CTRL_NAME, "", WS_VISIBLE, IDC_STATIC, 100, 100, 200, 20, hWnd, 0);
           return 0;

       case MSG_DESTROY:
           DestroyAllControls (hWnd);
           return 0;

       case MSG_CLOSE:
           DestroyMainWindow (hWnd);
           PostQuitMessage (hWnd);
           return 0;
   }

   return DefaultMainWinProc(hWnd, message, wParam, lParam);
}

int MiniGUIMain (int argc, const char* argv[])
{
   MSG Msg;
   HWND hMainWnd;
   MAINWINCREATE CreateInfo;

#ifdef _LITE_VERSION
   SetDesktopRect(0, 0, 1024, 768);
#endif

   RegisterMyControl ();

   CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;
   CreateInfo.dwExStyle = WS_EX_NONE;
   CreateInfo.spCaption = "Hello, world";
   CreateInfo.hMenu = 0;
   CreateInfo.hCursor = GetSystemCursor(0);
   CreateInfo.hIcon = 0;
   CreateInfo.MainWindowProc = HelloWinProc;
   CreateInfo.lx = 0;
   CreateInfo.ty = 0;
   CreateInfo.rx = 320;
   CreateInfo.by = 240;
   CreateInfo.iBkColor = COLOR_lightwhite;
   CreateInfo.dwAddData = 0;
   CreateInfo.hHosting = HWND_DESKTOP;

   hMainWnd = CreateMainWindow (&CreateInfo);

   if (hMainWnd == HWND_INVALID)
       return -1;

   ShowWindow(hMainWnd, SW_SHOWNORMAL);

   while (GetMessage(&Msg, hMainWnd)) {
       TranslateMessage(&Msg);
       DispatchMessage(&Msg);
   }

   MainWindowThreadCleanup (hMainWnd);
   UnregisterMyControl ();

   return 0;
}

#ifndef _LITE_VERSION
#include
#endif
阅读(894) | 评论(0) | 转发(0) |
0

上一篇:Controlpanel

下一篇:combobox.c

给主人留下些什么吧!~~