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

2013年(1)

2008年(2)

2007年(14)

2006年(413)

分类:

2006-06-13 17:28:20

小超 @ 2004-11-12 16:06

#include
#include
#include

#include
#include
#include
#include
#include

#define IDC_BUTTON          100
#define IDC_CHECKBOX        200
#define IDC_RADIOBUTTON     300

static HWND hMainWnd = HWND_INVALID;

#if _MINIGUI_VERSION_CODE >= _VERSION_CODE (1, 2, 6)
static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
   printf ("From my_notif_proc: ID: %d, Code %d\n", id, nc);
}

#endif

static int ControlTestWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
   HWND hwnd;
   switch (message) {
       case MSG_CREATE:
           CreateWindow (CTRL_BUTTON,
                         "Push Button",
                         WS_CHILD | BS_PUSHBUTTON | BS_CHECKED | WS_VISIBLE,
                         IDC_BUTTON,
                         10, 10, 80, 30, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Multiple Lines Push Button",
                         WS_CHILD | BS_PUSHBUTTON | BS_MULTLINE | WS_VISIBLE,
                         IDC_BUTTON + 1,
                         100, 10, 80, 40, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Normal check box",
                         WS_CHILD | BS_CHECKBOX | BS_CHECKED | WS_VISIBLE,
                         IDC_BUTTON + 2,
                         190, 10, 150, 30, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Normal radio button",
                         WS_CHILD | BS_RADIOBUTTON | WS_VISIBLE,
                         IDC_BUTTON + 3,
                         350, 10, 150, 30, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Auto 3-state check box",
                         WS_CHILD | BS_AUTO3STATE | WS_VISIBLE,
                         IDC_CHECKBOX,
                         10, 60, 150, 30, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Auto check box on left",
                         WS_CHILD | BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_RIGHT | WS_VISIBLE,
                         IDC_CHECKBOX + 1,
                         170, 60, 150, 30, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Push-like check box",
                         WS_CHILD | BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_VISIBLE,
                         IDC_CHECKBOX + 2,
                         330, 60, 100, 20, hWnd, 0);

           CreateWindow (CTRL_STATIC,
                         "A Group Box",
                         WS_CHILD | SS_GROUPBOX | WS_VISIBLE,
                         IDC_STATIC,
                         10, 100, 150, 140, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Auto Radio Button 1",
                         WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_GROUP,
                         IDC_RADIOBUTTON,
                         20, 120, 130, 30, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Auto Radio Button 2",
                         WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE,
                         IDC_RADIOBUTTON + 1,
                         20, 160, 130, 30, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Auto Radio Button 3",
                         WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE,
                         IDC_RADIOBUTTON + 2,
                         20, 200, 130, 30, hWnd, 0);

           CreateWindow (CTRL_STATIC,
                         "A Group Box",
                         WS_CHILD | SS_GROUPBOX | WS_VISIBLE,
                         IDC_STATIC,
                         170, 100, 170, 140, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Auto Radio Button 1",
                         WS_CHILD | BS_AUTORADIOBUTTON | BS_LEFTTEXT | BS_RIGHT | WS_VISIBLE | WS_GROUP,
                         IDC_RADIOBUTTON + 3,
                         180, 120, 140, 30, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Auto Radio Button 2",
                         WS_CHILD | BS_AUTORADIOBUTTON | BS_LEFTTEXT | BS_RIGHT | WS_VISIBLE,
                         IDC_RADIOBUTTON + 4,
                         180, 160, 140, 30, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Auto Radio Button 3",
                         WS_CHILD | BS_AUTORADIOBUTTON | BS_LEFTTEXT | BS_RIGHT | WS_VISIBLE,
                         IDC_RADIOBUTTON + 5,
                         180, 200, 140, 30, hWnd, 0);

           CreateWindow (CTRL_BUTTON,
                         "Push-like Radio 1",
                         WS_CHILD | BS_AUTORADIOBUTTON | BS_PUSHLIKE | WS_VISIBLE | WS_GROUP,
                         IDC_RADIOBUTTON + 3,
                         10, 260, 100, 30, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Push-like Radio 2",
                         WS_CHILD | BS_AUTORADIOBUTTON | BS_PUSHLIKE | WS_VISIBLE,
                         IDC_RADIOBUTTON + 4,
                         120, 260, 100, 30, hWnd, 0);
           CreateWindow (CTRL_BUTTON,
                         "Push-like Radio 3",
                         WS_CHILD | BS_AUTORADIOBUTTON | BS_PUSHLIKE | WS_VISIBLE,
                         IDC_RADIOBUTTON + 5,
                         230, 260, 100, 30, hWnd, 0);

           hwnd = CreateWindow (CTRL_BUTTON,
                         "Close",
                         WS_CHILD | BS_PUSHBUTTON | BS_ICON |BS_REALSIZEIMAGE | BS_NOTIFY | WS_VISIBLE,
                         IDC_BUTTON + 4,
                         10, 300, 60, 30, hWnd, (DWORD) GetLargeSystemIcon (IDI_APPLICATION));

           CreateWindow (CTRL_BUTTON,
                         "Close",
                         WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
                         IDCANCEL,
                         410, 300, 60, 30, hWnd, 0);


#if _MINIGUI_VERSION_CODE >= _VERSION_CODE (1, 2, 6)
           SetNotificationCallback (hwnd, my_notif_proc);
#endif

       break;

       case MSG_COMMAND:
       {
           int id   = LOWORD(wParam);
           int code = HIWORD(wParam);
           printf ("Notification from buttons: ID: %d, Code: %x\n", id, code);

           if (wParam == IDCANCEL) {
               PostMessage (hWnd, MSG_CLOSE, 0, 0);
           }
       }
       break;

       case MSG_DESTROY:
           DestroyAllControls (hWnd);
           hMainWnd = HWND_INVALID;
       return 0;

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

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

static void InitCreateInfo(PMAINWINCREATE pCreateInfo)
{
   pCreateInfo->dwStyle = WS_CAPTION | WS_BORDER | WS_VISIBLE;
   pCreateInfo->dwExStyle = WS_EX_NONE;
   pCreateInfo->spCaption = "Button controls";
   pCreateInfo->hMenu = 0;
   pCreateInfo->hCursor = GetSystemCursor(1);
   pCreateInfo->hIcon = 0;
   pCreateInfo->MainWindowProc = ControlTestWinProc;
   pCreateInfo->lx = 0;
   pCreateInfo->ty = 0;
   pCreateInfo->rx = 480;
   pCreateInfo->by = 380;
   pCreateInfo->iBkColor = GetWindowElementColor (BKC_CONTROL_DEF);
   pCreateInfo->dwAddData = 0;
   pCreateInfo->hHosting = HWND_DESKTOP;
}

void button_demo (HWND hwnd)
{
   MAINWINCREATE CreateInfo;

   if (hMainWnd != HWND_INVALID) {
       ShowWindow (hMainWnd, SW_SHOWNORMAL);
       return;
   }

   InitCreateInfo (&CreateInfo);
   CreateInfo.hHosting = hwnd;

   hMainWnd = CreateMainWindow (&CreateInfo);
}
阅读(1382) | 评论(0) | 转发(0) |
0

上一篇:终于把alsa装了进去

下一篇:Controlpanel

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