Home | History | Annotate | Line # | Download | only in menu
rootwindow.cpp revision 1.4.24.3
      1  1.4.24.3  skrll /* -*-C++-*-	$NetBSD: rootwindow.cpp,v 1.4.24.3 2004/08/25 06:57:18 skrll Exp $	*/
      2       1.1    uch 
      3       1.1    uch /*-
      4  1.4.24.3  skrll  * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
      5       1.1    uch  * All rights reserved.
      6       1.1    uch  *
      7       1.1    uch  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1    uch  * by UCHIYAMA Yasushi.
      9       1.1    uch  *
     10       1.1    uch  * Redistribution and use in source and binary forms, with or without
     11       1.1    uch  * modification, are permitted provided that the following conditions
     12       1.1    uch  * are met:
     13       1.1    uch  * 1. Redistributions of source code must retain the above copyright
     14       1.1    uch  *    notice, this list of conditions and the following disclaimer.
     15       1.1    uch  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1    uch  *    notice, this list of conditions and the following disclaimer in the
     17       1.1    uch  *    documentation and/or other materials provided with the distribution.
     18       1.1    uch  * 3. All advertising materials mentioning features or use of this software
     19       1.1    uch  *    must display the following acknowledgement:
     20       1.1    uch  *        This product includes software developed by the NetBSD
     21       1.1    uch  *        Foundation, Inc. and its contributors.
     22       1.1    uch  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1    uch  *    contributors may be used to endorse or promote products derived
     24       1.1    uch  *    from this software without specific prior written permission.
     25       1.1    uch  *
     26       1.1    uch  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1    uch  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1    uch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.1    uch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.1    uch  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1    uch  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1    uch  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1    uch  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1    uch  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1    uch  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1    uch  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1    uch  */
     38       1.1    uch 
     39       1.1    uch #include <hpcmenu.h>
     40       1.1    uch #include <menu/window.h>
     41       1.1    uch #include <menu/tabwindow.h>
     42       1.1    uch #include <menu/rootwindow.h>
     43       1.1    uch #include <res/resource.h>
     44       1.4    uch #include "../binary/build_number.h"
     45  1.4.24.2  skrll #include <console.h>
     46       1.1    uch 
     47       1.1    uch //
     48       1.1    uch // root window
     49       1.1    uch //
     50       1.1    uch RootWindow::RootWindow(HpcBootApp &app)
     51       1.1    uch 	: Window(app)
     52       1.1    uch {
     53       1.1    uch 	_boot_button	= 0;
     54       1.1    uch 	_base		= 0;
     55       1.1    uch 	_main		= 0;
     56       1.1    uch 	_option	= 0;
     57       1.1    uch 	_console	= 0;
     58       1.1    uch }
     59       1.1    uch 
     60       1.1    uch RootWindow::~RootWindow()
     61       1.1    uch {
     62       1.1    uch 	if (_boot_button)
     63       1.1    uch 		delete _boot_button;
     64       1.1    uch 	if (_cancel_button)
     65       1.1    uch 		delete _cancel_button;
     66       1.1    uch 	if (_progress_bar)
     67       1.1    uch 		delete _progress_bar;
     68       1.1    uch 	if (_main)
     69       1.1    uch 		delete _main;
     70       1.1    uch 	if (_option)
     71       1.1    uch 		delete _option;
     72       1.1    uch 	if (_console)
     73       1.1    uch 		delete _console;
     74       1.1    uch 	if (_base)
     75       1.1    uch 		delete _base;
     76       1.1    uch }
     77       1.1    uch 
     78       1.1    uch BOOL
     79       1.1    uch RootWindow::create(LPCREATESTRUCT aux)
     80       1.1    uch {
     81       1.4    uch 	TCHAR app_name[32];
     82       1.1    uch 	// Root window's create don't called by Window Procedure.
     83       1.1    uch 	// so aux is NULL
     84       1.1    uch 	HINSTANCE inst = _app._instance;
     85       1.1    uch 	TCHAR *wc_name = reinterpret_cast <TCHAR *>
     86       1.3    uch 	    (LoadString(inst, IDS_HPCMENU, 0, 0));
     87       1.4    uch 	wsprintf(app_name, TEXT("%s Build %d"), wc_name, HPCBOOT_BUILD_NUMBER);
     88  1.4.24.1  skrll 
     89       1.4    uch 	_window = CreateWindow(wc_name, app_name, WS_VISIBLE,
     90       1.3    uch 	    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
     91       1.3    uch 	    0, 0, inst, this);
     92       1.1    uch 	if (!_window)
     93       1.1    uch 		return FALSE;
     94       1.1    uch 
     95       1.1    uch 	HpcMenuInterface &menu = HpcMenuInterface::Instance();
     96       1.1    uch 	if (menu._pref.auto_boot > 0)
     97       1.1    uch 		SetTimer(_window, IDD_TIMER, menu._pref.auto_boot * 1000, 0);
     98       1.1    uch 
     99       1.1    uch 	ShowWindow(_window, SW_SHOW);
    100       1.1    uch 	UpdateWindow(_window);
    101       1.1    uch 
    102       1.1    uch 	return TRUE;
    103       1.1    uch }
    104       1.1    uch 
    105       1.1    uch BOOL
    106       1.1    uch RootWindow::proc(HWND w, UINT msg, WPARAM wparam, LPARAM lparam)
    107       1.1    uch {
    108       1.1    uch 	LPCREATESTRUCT aux = reinterpret_cast <LPCREATESTRUCT>(lparam);
    109       1.1    uch 	HpcMenuInterface &menu = HpcMenuInterface::Instance();
    110       1.1    uch 
    111       1.1    uch 	switch(msg) {
    112       1.1    uch 	default: // message can't handle.
    113       1.1    uch 		return FALSE;
    114       1.1    uch 	case WM_CREATE:
    115       1.1    uch 		WMCreate(w, aux);
    116       1.1    uch 		break;
    117       1.1    uch 	case WM_PAINT:
    118       1.1    uch 		WMPaint(w, aux);
    119       1.1    uch 		break;
    120  1.4.24.1  skrll 	case WM_ENTERMENULOOP:
    121  1.4.24.1  skrll 		SaveFocus();
    122  1.4.24.1  skrll 		break;
    123  1.4.24.1  skrll 	case WM_EXITMENULOOP:
    124  1.4.24.1  skrll 		RestoreFocus();
    125  1.4.24.1  skrll 		break;
    126  1.4.24.1  skrll 	case WM_ACTIVATE:
    127  1.4.24.1  skrll 		if ((UINT)LOWORD(wparam) == WA_INACTIVE)
    128  1.4.24.1  skrll 			SaveFocus();
    129  1.4.24.1  skrll 		else
    130  1.4.24.1  skrll 			RestoreFocus();
    131  1.4.24.1  skrll 		break;
    132       1.1    uch 	case WM_NOTIFY:
    133       1.1    uch 	{
    134       1.1    uch 		NMHDR *notify = reinterpret_cast <NMHDR *>(lparam);
    135       1.1    uch 		// get current selected tab id
    136       1.1    uch 		int tab_id = TabCtrl_GetCurSel(_base->_window);
    137       1.1    uch 		// get context
    138       1.1    uch 		TC_ITEM tc_item;
    139       1.1    uch 		tc_item.mask = TCIF_PARAM;
    140       1.1    uch 		TabCtrl_GetItem(_base->_window, tab_id, &tc_item);
    141       1.1    uch 		TabWindow *tab = reinterpret_cast <TabWindow *>
    142       1.3    uch 		    (tc_item.lParam);
    143       1.1    uch 		switch(notify->code) {
    144       1.1    uch 		case TCN_SELCHANGING:
    145       1.1    uch 			tab->hide();
    146       1.1    uch 			break;
    147       1.1    uch 		case TCN_SELCHANGE:
    148       1.1    uch 			tab->show();
    149       1.1    uch 			break;
    150  1.4.24.1  skrll 		case TCN_KEYDOWN: {
    151  1.4.24.1  skrll 			NMTCKEYDOWN *key = reinterpret_cast
    152  1.4.24.1  skrll 				<NMTCKEYDOWN *>(lparam);
    153  1.4.24.1  skrll 			return _base->focusManagerHook(key->wVKey, key->flags,
    154  1.4.24.1  skrll 						_cancel_button->_window);
    155  1.4.24.1  skrll 		    }
    156       1.1    uch 		}
    157       1.1    uch 	}
    158       1.1    uch 	break;
    159       1.1    uch 	case WM_TIMER:
    160       1.1    uch 		disableTimer();
    161       1.1    uch 		goto boot;
    162       1.1    uch 	case WM_COMMAND:
    163       1.1    uch 		switch(wparam)
    164       1.1    uch 		{
    165       1.1    uch 		case IDC_BOOTBUTTON:
    166       1.1    uch 			// inquire current options.
    167       1.1    uch 			menu.get_options();
    168       1.1    uch 			if (menu._pref.safety_message) {
    169  1.4.24.1  skrll 				UINT mb_icon = menu._pref.pause_before_boot ?
    170  1.4.24.1  skrll 					MB_ICONQUESTION : MB_ICONWARNING;
    171       1.3    uch 				if (MessageBox(_window,
    172  1.4.24.1  skrll 				    TEXT("Data in memory will be lost.\nAre you sure?"),
    173  1.4.24.1  skrll 				    TEXT("WARNING"),
    174  1.4.24.1  skrll 				    mb_icon | MB_YESNO) != IDYES)
    175       1.1    uch 					break;
    176  1.4.24.1  skrll 				UpdateWindow(_window);
    177       1.1    uch 			}
    178       1.1    uch 		boot:
    179       1.2    uch 			SendMessage(_progress_bar->_window, PBM_SETPOS, 0, 0);
    180       1.1    uch 			menu.print(TEXT("BOOT START\n"));
    181       1.1    uch 			// inquire current options.
    182       1.1    uch 			menu.get_options();
    183       1.1    uch 			// save options to `hpcboot.cnf'
    184       1.1    uch 			menu.save();
    185  1.4.24.1  skrll 			// start boot sequence.
    186       1.1    uch 			menu.boot();
    187       1.1    uch 			// NOTREACHED
    188       1.1    uch 			break;
    189       1.1    uch 		case IDC_PROGRESSBAR:
    190       1.1    uch 			break;
    191       1.1    uch 		case IDC_CANCELBUTTON:
    192       1.1    uch 			PostQuitMessage(0);
    193       1.1    uch 			break;
    194       1.1    uch 		}
    195       1.1    uch 		break;
    196       1.1    uch 	case WM_DESTROY:
    197       1.1    uch 		PostQuitMessage(0);
    198       1.1    uch 		break;
    199       1.1    uch 	}
    200       1.1    uch 	return TRUE;
    201       1.1    uch }
    202       1.1    uch 
    203       1.1    uch void
    204  1.4.24.1  skrll RootWindow::SaveFocus() {
    205  1.4.24.1  skrll 	_saved_focus = GetFocus();
    206  1.4.24.1  skrll }
    207  1.4.24.1  skrll 
    208  1.4.24.1  skrll void
    209  1.4.24.1  skrll RootWindow::RestoreFocus() {
    210  1.4.24.1  skrll 	SetFocus(IsWindowEnabled(_saved_focus) ?
    211  1.4.24.1  skrll 		 _saved_focus : _boot_button->_window);
    212  1.4.24.1  skrll }
    213  1.4.24.1  skrll 
    214  1.4.24.1  skrll void
    215       1.1    uch RootWindow::WMPaint(HWND w, LPCREATESTRUCT aux)
    216  1.4.24.1  skrll {
    217       1.1    uch 	PAINTSTRUCT ps;
    218       1.1    uch 	BeginPaint(w, &ps);
    219       1.1    uch 	EndPaint(w, &ps);
    220       1.1    uch }
    221       1.1    uch 
    222       1.1    uch void
    223       1.1    uch RootWindow::WMCreate(HWND w, LPCREATESTRUCT aux)
    224       1.1    uch {
    225       1.1    uch 	int cmdbar_height;
    226       1.1    uch 
    227       1.1    uch 	_window = w;
    228       1.1    uch 	// Command bar.
    229       1.1    uch 	_app._cmdbar = CommandBar_Create(aux->hInstance, w, IDC_CMDBAR);
    230       1.1    uch 	CommandBar_AddAdornments(_app._cmdbar, 0, 0);
    231       1.1    uch 	cmdbar_height = CommandBar_Height(_app._cmdbar);
    232  1.4.24.1  skrll 
    233       1.1    uch 	_button_height = cmdbar_height;
    234  1.4.24.1  skrll 	_button_width = BOOT_BUTTON_WIDTH;
    235  1.4.24.1  skrll 
    236  1.4.24.1  skrll 	HDC hdc = GetDC(0);
    237  1.4.24.1  skrll 	if (GetDeviceCaps(hdc, HORZRES) > 320)
    238  1.4.24.1  skrll 	    _button_width += _button_width/2;
    239  1.4.24.1  skrll 	ReleaseDC(0, hdc);
    240  1.4.24.1  skrll 
    241       1.1    uch 	RECT rect;
    242       1.1    uch 	GetClientRect(w, &rect);
    243       1.1    uch 	rect.top += cmdbar_height;
    244       1.1    uch 
    245       1.1    uch 	// BOOT button.
    246       1.1    uch 	_boot_button = new BootButton(_app, *this, rect);
    247       1.1    uch 	_boot_button->create(aux);
    248       1.1    uch 	// CANCEL button.
    249       1.1    uch 	_cancel_button = new CancelButton(_app, *this, rect);
    250       1.1    uch 	_cancel_button->create(aux);
    251       1.1    uch 	// Progress bar
    252       1.1    uch 	_progress_bar = new ProgressBar(_app, *this, rect);
    253       1.1    uch 	_progress_bar->create(aux);
    254       1.1    uch 
    255       1.1    uch  	// regsiter myself to menu
    256       1.1    uch 	HpcMenuInterface::Instance()._root = this;
    257       1.1    uch 
    258  1.4.24.1  skrll 	rect.top += _button_height;
    259       1.1    uch 	// Tab control.
    260       1.1    uch 	_base =  new TabWindowBase(_app, w, rect, IDC_BASE);
    261       1.1    uch 	_base->create(aux);
    262       1.1    uch 	// main/option/console dialog.(register to Menu)
    263       1.1    uch 	_main = _base->boot(IDC_BASE_MAIN);
    264       1.1    uch 	_option = _base->boot(IDC_BASE_OPTION);
    265       1.1    uch 	_console = _base->boot(IDC_BASE_CONSOLE);
    266  1.4.24.1  skrll 
    267       1.1    uch 	_main->show();
    268  1.4.24.1  skrll 	SetFocus(_boot_button->_window);
    269       1.1    uch 
    270       1.1    uch 	return;
    271       1.1    uch }
    272       1.1    uch 
    273       1.1    uch void
    274       1.1    uch RootWindow::disableTimer()
    275  1.4.24.1  skrll {
    276       1.1    uch 	KillTimer(_window, IDD_TIMER);
    277       1.1    uch }
    278       1.1    uch 
    279       1.1    uch BOOL
    280       1.1    uch RootWindow::isDialogMessage(MSG &msg)
    281       1.1    uch {
    282  1.4.24.1  skrll 	HWND tab_window;
    283  1.4.24.1  skrll 
    284       1.1    uch 	if (_main && IsWindowVisible(_main->_window))
    285  1.4.24.1  skrll 		tab_window = _main->_window;
    286  1.4.24.1  skrll 	else if (_option && IsWindowVisible(_option->_window))
    287  1.4.24.1  skrll 		tab_window = _option->_window;
    288  1.4.24.1  skrll 	else if (_console && IsWindowVisible(_console->_window))
    289  1.4.24.1  skrll 		tab_window = _console->_window;
    290  1.4.24.1  skrll 
    291  1.4.24.1  skrll 	if (focusManagerHook(msg, tab_window))
    292  1.4.24.1  skrll 		return TRUE;
    293  1.4.24.1  skrll 
    294  1.4.24.1  skrll 	return IsDialogMessage(tab_window, &msg);
    295  1.4.24.1  skrll }
    296  1.4.24.1  skrll 
    297  1.4.24.1  skrll //
    298  1.4.24.1  skrll // XXX !!! XXX !!! XXX !!! XXX !!!
    299  1.4.24.1  skrll //
    300  1.4.24.1  skrll // WinCE 2.11 doesn't support keyboard focus traversal for nested
    301  1.4.24.1  skrll // dialogs, so implement poor man focus manager for our root window.
    302  1.4.24.1  skrll // This function handles focus transition from boot/cancel buttons.
    303  1.4.24.1  skrll // Transition from the tab-control is done on WM_NOTIFY/TCN_KEYDOWN
    304  1.4.24.1  skrll // above.
    305  1.4.24.1  skrll //
    306  1.4.24.1  skrll // XXX: This is a very smplistic implementation that doesn't handle
    307  1.4.24.1  skrll // <TAB> auto-repeat count in LOWORD(msg.lParam), WS_GROUP, etc...
    308  1.4.24.1  skrll //
    309  1.4.24.1  skrll BOOL
    310  1.4.24.1  skrll RootWindow::focusManagerHook(MSG &msg, HWND tab_window)
    311  1.4.24.1  skrll {
    312  1.4.24.1  skrll 	HWND next, prev;
    313  1.4.24.1  skrll 	HWND dst = 0;
    314  1.4.24.1  skrll 	LRESULT dlgcode = 0;
    315  1.4.24.1  skrll 
    316  1.4.24.1  skrll 	if (msg.message != WM_KEYDOWN)
    317  1.4.24.1  skrll 		return FALSE;
    318  1.4.24.1  skrll 
    319  1.4.24.1  skrll 	if (msg.hwnd == _boot_button->_window) {
    320  1.4.24.1  skrll 		next = _cancel_button->_window;
    321  1.4.24.1  skrll 		prev = _base->_window;
    322  1.4.24.1  skrll 	} else if (msg.hwnd == _cancel_button->_window) {
    323  1.4.24.1  skrll 		next = _base->_window;
    324  1.4.24.1  skrll 		prev = _boot_button->_window;
    325  1.4.24.1  skrll 	} else if (tab_window == 0) {
    326  1.4.24.1  skrll 		return FALSE;
    327  1.4.24.1  skrll 	} else {
    328  1.4.24.1  skrll 		// last focusable control in the tab_window (XXX: WS_GROUP?)
    329  1.4.24.1  skrll 		HWND last = GetNextDlgTabItem(tab_window, NULL, TRUE);
    330  1.4.24.1  skrll 		if (last == NULL ||
    331  1.4.24.1  skrll 		    !(last == msg.hwnd || IsChild(last, msg.hwnd)))
    332  1.4.24.1  skrll 			return FALSE;
    333  1.4.24.1  skrll 		dlgcode = SendMessage(last, WM_GETDLGCODE, NULL, (LPARAM)&msg);
    334  1.4.24.1  skrll 		next = _base->_window; // out of the tab window
    335  1.4.24.1  skrll 		prev = 0;	// let IsDialogMessage handle it
    336  1.4.24.1  skrll 	}
    337  1.4.24.2  skrll 
    338  1.4.24.1  skrll #if 0 // XXX: breaks tabbing out of the console window
    339  1.4.24.1  skrll 	if (dlgcode & DLGC_WANTALLKEYS)
    340  1.4.24.1  skrll 		return FALSE;
    341  1.4.24.1  skrll #endif
    342  1.4.24.1  skrll 	switch (msg.wParam) {
    343  1.4.24.1  skrll 	case VK_RIGHT:
    344  1.4.24.1  skrll 	case VK_DOWN:
    345  1.4.24.1  skrll 		if (dlgcode & DLGC_WANTARROWS)
    346  1.4.24.1  skrll 			return FALSE;
    347  1.4.24.1  skrll 		dst = next;
    348  1.4.24.1  skrll 		break;
    349  1.4.24.1  skrll 
    350  1.4.24.1  skrll 	case VK_LEFT:
    351  1.4.24.1  skrll 	case VK_UP:
    352  1.4.24.1  skrll 		if (dlgcode & DLGC_WANTARROWS)
    353  1.4.24.1  skrll 			return FALSE;
    354  1.4.24.1  skrll 		dst = prev;
    355  1.4.24.1  skrll 		break;
    356  1.4.24.1  skrll 
    357  1.4.24.1  skrll 	case VK_TAB:
    358  1.4.24.1  skrll 		if (dlgcode & DLGC_WANTTAB)
    359  1.4.24.1  skrll 			return FALSE;
    360  1.4.24.1  skrll 		if (GetKeyState(VK_SHIFT) & 0x8000) // Shift-Tab
    361  1.4.24.1  skrll 			dst = prev;
    362  1.4.24.1  skrll 		else
    363  1.4.24.1  skrll 			dst = next;
    364  1.4.24.1  skrll 		break;
    365  1.4.24.1  skrll 	}
    366  1.4.24.1  skrll 
    367  1.4.24.1  skrll 	if (dst == 0)
    368  1.4.24.1  skrll 		return FALSE;
    369  1.4.24.1  skrll 
    370  1.4.24.1  skrll 	SetFocus(dst);
    371  1.4.24.1  skrll 	return TRUE;
    372  1.4.24.1  skrll }
    373  1.4.24.1  skrll 
    374  1.4.24.1  skrll void
    375  1.4.24.2  skrll RootWindow::progress(const char *msg)
    376  1.4.24.1  skrll {
    377  1.4.24.2  skrll 
    378  1.4.24.2  skrll 	if (msg)
    379  1.4.24.3  skrll 		Console::Instance()->print(TEXT("[progress] %S\n"), msg);
    380  1.4.24.2  skrll 
    381  1.4.24.1  skrll 	SendMessage(_progress_bar->_window, PBM_STEPIT, 0, 0);
    382  1.4.24.1  skrll }
    383  1.4.24.1  skrll 
    384  1.4.24.1  skrll void
    385  1.4.24.1  skrll RootWindow::unprogress()
    386  1.4.24.1  skrll {
    387  1.4.24.1  skrll 	SendMessage(_progress_bar->_window, PBM_SETPOS, 0, 0);
    388       1.1    uch }
    389       1.1    uch 
    390       1.1    uch //
    391       1.1    uch // BOOT button
    392       1.1    uch //
    393       1.1    uch BOOL
    394       1.1    uch BootButton::create(LPCREATESTRUCT aux)
    395       1.1    uch {
    396  1.4.24.1  skrll 	int cx = _root._button_width;
    397       1.1    uch 	int cy = _root._button_height;
    398       1.1    uch 
    399  1.4.24.1  skrll 	_window = CreateWindow(TEXT("BUTTON"), TEXT("Boot"),
    400       1.3    uch 	    BS_PUSHBUTTON | BS_NOTIFY |
    401       1.3    uch 	    WS_VISIBLE | WS_CHILD | WS_TABSTOP,
    402       1.3    uch 	    _rect.left, _rect.top, cx, cy, _parent_window,
    403       1.3    uch 	    reinterpret_cast <HMENU>(IDC_BOOTBUTTON),
    404       1.3    uch 	    aux->hInstance,
    405       1.3    uch 	    NULL);
    406       1.1    uch 
    407       1.1    uch 	return IsWindow(_window) ? TRUE : FALSE;
    408       1.1    uch }
    409       1.1    uch 
    410       1.1    uch //
    411       1.1    uch // CANCEL button
    412       1.1    uch //
    413       1.1    uch BOOL
    414       1.1    uch CancelButton::create(LPCREATESTRUCT aux)
    415       1.1    uch {
    416  1.4.24.1  skrll 	int cx = _root._button_width;
    417       1.1    uch 	int cy = _root._button_height;
    418  1.4.24.1  skrll 	int x = _rect.right - _root._button_width;
    419       1.1    uch 
    420  1.4.24.1  skrll 	_window = CreateWindow(TEXT("BUTTON"), TEXT("Cancel"),
    421       1.3    uch 	    BS_PUSHBUTTON | BS_NOTIFY | WS_TABSTOP |
    422       1.3    uch 	    WS_VISIBLE | WS_CHILD,
    423       1.3    uch 	    x, _rect.top, cx, cy, _parent_window,
    424       1.3    uch 	    reinterpret_cast <HMENU>(IDC_CANCELBUTTON),
    425       1.3    uch 	    aux->hInstance,
    426       1.3    uch 	    NULL);
    427  1.4.24.1  skrll 
    428       1.1    uch 	return IsWindow(_window) ? TRUE : FALSE;
    429       1.1    uch }
    430       1.1    uch 
    431       1.1    uch //
    432       1.1    uch // PROGRESS BAR
    433       1.1    uch //
    434       1.1    uch BOOL
    435       1.1    uch ProgressBar::create(LPCREATESTRUCT aux)
    436       1.1    uch {
    437  1.4.24.1  skrll 	int cx = _rect.right - _rect.left - _root._button_width * 2;
    438       1.1    uch 	int cy = _root._button_height;
    439  1.4.24.1  skrll 	int x = _rect.left + _root._button_width;
    440  1.4.24.1  skrll 	_window = CreateWindowEx(WS_EX_CLIENTEDGE,
    441  1.4.24.1  skrll 	    PROGRESS_CLASS, TEXT(""),
    442  1.4.24.1  skrll 	    PBS_SMOOTH | WS_VISIBLE | WS_CHILD,
    443       1.3    uch 	    x, _rect.top, cx, cy, _parent_window,
    444       1.3    uch 	    reinterpret_cast <HMENU>(IDC_PROGRESSBAR),
    445       1.3    uch 	    aux->hInstance, NULL);
    446  1.4.24.1  skrll 	SendMessage(_window, PBM_SETRANGE, 0, MAKELPARAM(0, 11));
    447  1.4.24.1  skrll 	SendMessage(_window, PBM_SETSTEP, 1, 0);
    448  1.4.24.1  skrll 	SendMessage(_window, PBM_SETPOS, 0, 0);
    449       1.1    uch 
    450       1.1    uch 	return IsWindow(_window) ? TRUE : FALSE;
    451       1.1    uch }
    452