Esempio n. 1
1
LRESULT menu_extension::on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
{
	switch (msg) 
	{
		case WM_CREATE:
		{
			initialised = true;

			mainmenu_root_group::g_get_root_items(m_buttons);
			t_size button_count = m_buttons.get_count();

			pfc::array_t<TBBUTTON> tbb;
			tbb.set_size(button_count);
			memset(tbb.get_ptr(), 0, tbb.get_size() * sizeof(TBBUTTON));

			wnd_menu = CreateWindowEx(/*TBSTYLE_EX_MIXEDBUTTONS|*/WS_EX_TOOLWINDOW, TOOLBARCLASSNAME, NULL,
				WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER,
				0, 0, 0, 25, wnd, (HMENU)ID_MENU, core_api::get_my_instance(), NULL);

			if (wnd_menu)
			{
				SetWindowLongPtr(wnd_menu, GWLP_USERDATA, (LPARAM)(this));

				SendMessage(wnd_menu, TB_SETBITMAPSIZE, (WPARAM)0, MAKELONG(0, 0));
				SendMessage(wnd_menu, TB_SETBUTTONSIZE, (WPARAM)0, MAKELONG(0,/*GetSystemMetrics(SM_CYMENUSIZE)*/0));

				SendMessage(wnd_menu, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);

				unsigned n, count = tbb.get_size();
				for (n = 0; n < count; n++)
				{
					tbb[n].iBitmap = I_IMAGECALLBACK;
					tbb[n].idCommand = n + 1;
					tbb[n].fsState = TBSTATE_ENABLED;
					tbb[n].fsStyle = BTNS_DROPDOWN | BTNS_AUTOSIZE;
					tbb[n].dwData = 0;
					tbb[n].iString = (int)m_buttons[n].m_name_with_accelerators.get_ptr();
				}

				SendMessage(wnd_menu, TB_ADDBUTTONS, (WPARAM)tbb.get_size(), (LPARAM)(LPTBBUTTON)tbb.get_ptr());

				//			SendMessage(wnd_menu, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);

				//			SendMessage(wnd_menu, TB_AUTOSIZE, 0, 0); 

							//if (is_win2k_or_newer())
				{
					BOOL a = true;
					SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0);
					SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(a ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0);
				}

				//			SendMessage(wnd_menu, TB_SETPARENT, (WPARAM) (HWND)wnd_host, 0);
				menuproc = (WNDPROC)SetWindowLongPtr(wnd_menu, GWLP_WNDPROC, (LPARAM)main_hook);
			}


			break;
		}
		case WM_WINDOWPOSCHANGED:
		{
			LPWINDOWPOS lpwp = (LPWINDOWPOS)lp;
			if (!(lpwp->flags & SWP_NOSIZE))
			{
				//SIZE sz = {0,0};
				//SendMessage(wnd_menu, TB_GETMAXSIZE, NULL, (LPARAM)&sz);

				RECT rc = { 0,0,0,0 };
				t_size count = m_buttons.get_count();
				int cx = lpwp->cx;
				int cy = lpwp->cy;
				int extra = 0;
				if (count && (BOOL)SendMessage(wnd_menu, TB_GETITEMRECT, count - 1, (LPARAM)(&rc)))
				{
					cx = min(cx, rc.right);
					cy = min(cy, rc.bottom);
					extra = (lpwp->cy - rc.bottom) / 2;
				}
				SetWindowPos(wnd_menu, 0, 0, extra, cx, cy, SWP_NOZORDER);
				RedrawWindow(wnd, 0, 0, RDW_ERASE | RDW_INVALIDATE);
			}
			break;
		}

		case WM_NOTIFY:
		{
			if (((LPNMHDR)lp)->idFrom == ID_MENU) {
				switch (((LPNMHDR)lp)->code)
				{
				case TBN_HOTITEMCHANGE:
				{
					if (!(((LPNMTBHOTITEM)lp)->dwFlags & HICF_LEAVING) && (((LPNMTBHOTITEM)lp)->dwFlags & HICF_MOUSE || ((LPNMTBHOTITEM)lp)->dwFlags & HICF_LMOUSE))
						redrop = true;
					break;
				}
				case TBN_DROPDOWN:
				{
					if (redrop)
						PostMessage(wnd, MSG_CREATE_MENU, ((LPNMTOOLBAR)lp)->iItem, 0);
					else
						redrop = true;

					return TBDDRET_DEFAULT;
				}
				}
			}
			break;
		}
		case MSG_HIDE_MENUACC:
		{
			//if (is_win2k_or_newer())
			{
				BOOL a = true;
				SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0);
				if ((SendMessage(wnd_menu, WM_QUERYUISTATE, 0, 0) & UISF_HIDEACCEL) != !a)
					SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(a ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0);
			}
			break;
		}
		case MSG_SHOW_MENUACC:
		{
			//if (is_win2k_or_newer())
			{
				SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEACCEL), 0);
			}
			break;
		}
		case MSG_CREATE_MENU:
		{
			if (lp) SetFocus(wnd_menu);
			active_item = wp;

			make_menu(wp);
			break;
		}
		case WM_MENUSELECT:
		{
			if (HIWORD(wp) & MF_POPUP)
			{
				is_submenu = true;
				m_status_override.release();
			}
			else
			{
				is_submenu = false;
				if (p_manager.is_valid())
				{
					unsigned id = LOWORD(wp);

					bool set = false;

					pfc::string8 blah;

					set = p_manager->get_description(id - 1, blah);

					service_ptr_t<ui_status_text_override> p_status_override;

					if (set)
					{
						get_host()->override_status_text_create(p_status_override);

						if (p_status_override.is_valid())
						{
							p_status_override->override_text(blah);
						}
					}
					m_status_override = p_status_override;
				}
			}
			break;
		}
		case WM_INITMENUPOPUP:
		{
			sub_menu_ref_count++;
			break;
		}
		case WM_UNINITMENUPOPUP:
		{
			sub_menu_ref_count--;
			break;
		}
		case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO mmi = LPMINMAXINFO(lp);

			RECT rc = { 0,0,0,0 };
			SendMessage(wnd_menu, TB_GETITEMRECT, m_buttons.get_count() - 1, (LPARAM)(&rc));

			//SIZE sz = {0,0};
			//SendMessage(wnd_menu, TB_GETMAXSIZE, NULL, (LPARAM)&sz);
			//console::formatter() << sz.cx << sz.cy;

			mmi->ptMinTrackSize.x = rc.right;
			mmi->ptMinTrackSize.y = rc.bottom;
			mmi->ptMaxTrackSize.y = rc.bottom;
			return 0;
		}
		case WM_SETTINGCHANGE:
		{
			if (wp == SPI_SETNONCLIENTMETRICS)
			{
				PostMessage(wnd, MSG_SIZE_LIMIT_CHANGE, 0, 0);
			}
			break;
		}
		case SPI_GETKEYBOARDCUES:
		{
			BOOL a = TRUE;
			SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0);
			SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM((a || GetFocus() == wnd_menu) ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0);
			break;
		}
		case MSG_SIZE_LIMIT_CHANGE:
		{
			get_host()->on_size_limit_change(wnd, uie::size_limit_minimum_height | uie::size_limit_maximum_height | uie::size_limit_minimum_width);
			break;
		}
		case WM_DESTROY:
		{
			DestroyWindow(wnd_menu);
			wnd_menu = NULL;
			m_buttons.remove_all();
			initialised = false;
			break;
		}
	}
	return DefWindowProc(wnd, msg, wp, lp);
}
Esempio n. 2
0
LRESULT seek_bar_extension::on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
{
	
	if(msg == WM_CREATE)
	{
		windows.add_item(this);

		initialised = true;

		m_child.set_callback(&m_track_bar_host);
		m_child.set_show_tooltips(true);
		m_child.set_scroll_step(3);

		wnd_seekbar = m_child.create(wnd);

		if (wnd_seekbar)
		{
			update_seek();
				
			update_seek_timer();
		}

		seek_bar_extension::update_seek_timer();
		ShowWindow(wnd_seekbar, SW_SHOWNORMAL);
		
	}
	else if (msg == WM_WINDOWPOSCHANGED)
	{
		LPWINDOWPOS lpwp = (LPWINDOWPOS)lp;
		if (!(lpwp->flags & SWP_NOSIZE))
		{
			SetWindowPos(wnd_seekbar, 0, 0, 0, lpwp->cx, lpwp->cy, SWP_NOZORDER);
		}
	}
	else if (msg == WM_GETMINMAXINFO)
	{
		LPMINMAXINFO mmi = LPMINMAXINFO(lp);

		mmi->ptMinTrackSize.y = MulDiv(21, QueryScreenDPI(), 96);
		//mmi->ptMaxTrackSize.y = 20;

		return 0;
	}

	else if (msg == WM_DESTROY)
	{
		if (initialised)
		{
			m_child.destroy();
			windows.remove_item(this);
			initialised=false;
		}
	}
	return uDefWindowProc(wnd, msg, wp, lp);
}
Esempio n. 3
0
LRESULT uie_albumart::on_message(HWND wnd1,UINT msg,WPARAM wp,LPARAM lp)
{
    switch(msg)
    {
    case WM_CREATE:
        {
            GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

            m_sources_control.register_foo_callbacks();
            m_sources_control.register_sources_control_callback(this);
            m_sources_control.setup_sources_control(m_config, m_sources);

            m_wheel_accum = 0;
        }
        break;

    case WM_DESTROY:
        {
            m_sources_control.unregister_sources_control_callback(this);
            m_sources_control.unregister_foo_callbacks();

            m_bufold.release();
            m_bufnew.release();
            m_bufanim.release();

            m_bmpnew.release();
            m_bmp.release();

            GdiplusShutdown(gdiplusToken);
        }
        break;

    case WM_LBUTTONDOWN:
        {
            POINTS pts = MAKEPOINTS(lp);
            POINT pt;
            POINTSTOPOINT(pt, pts);
            if (m_panning_enabled)
            {
                m_dragging = true;
                SetCursor(LoadCursor(NULL, IDC_SIZEALL));
                SetCapture(wnd1);

                m_drag_start = pt;
                m_orig_dx = m_pan_dx;
                m_orig_dy = m_pan_dy;
            }
        }
        break;
    case WM_MOUSEMOVE:
        {
            if (m_dragging)
            {
                POINTS pts = MAKEPOINTS(lp);
                m_pan_dx = m_orig_dx + pts.x - m_drag_start.x;
                m_pan_dy = m_orig_dy + pts.y - m_drag_start.y;
                redraw();
            }
        }
        break;
    case WM_CANCELMODE:
        if (m_dragging)
        {
            ReleaseCapture();
            SetCursor(LoadCursor(NULL, IDC_ARROW));
            m_dragging = false;
        }
        break;

    case WM_LBUTTONDBLCLK:
        click_func(m_config.dblclickfunc);
        b_dblclick = true;
        break;
    case WM_LBUTTONUP:
        if (m_dragging)
        {
            ReleaseCapture();
            SetCursor(LoadCursor(NULL, IDC_ARROW));
            m_dragging = false;

            // if the mouse didn't move much, it probably wasn't
            // a drag, so trigger the mouse action
            POINTS pts = MAKEPOINTS(lp);
            POINT pt;
            POINTSTOPOINT(pt, pts);

            int cxdrag = GetSystemMetrics(SM_CXDRAG);
            int cydrag = GetSystemMetrics(SM_CYDRAG);

            RECT rect;
            SetRect(&rect, -1*cxdrag/2, -1*cydrag/2, cxdrag/2, cydrag/2);
            OffsetRect(&rect, m_drag_start.x, m_drag_start.y);

            if (PtInRect(&rect, pt)) click_func(m_config.lftclickfunc);
        }
        else if (!b_dblclick)
        {
            click_func(m_config.lftclickfunc);
        }
        b_dblclick = false;
        break;
    case WM_MBUTTONUP:
        click_func(m_config.mdlclickfunc);
        break;

    case WM_MOUSEWHEEL:
        {
            short delta = GET_WHEEL_DELTA_WPARAM(wp);
            m_wheel_accum += delta;
            while (m_wheel_accum <= -WHEEL_DELTA)
            {
                m_wheel_accum += WHEEL_DELTA;
                func_NextSource(true);
            }
            while (m_wheel_accum >= WHEEL_DELTA)
            {
                m_wheel_accum -= WHEEL_DELTA;
                func_PreviousSource();
            }
        }
        break;

    case WM_PAINT:
        {
            HDC hdc;
            PAINTSTRUCT ps;
            hdc = BeginPaint(m_hWnd, &ps);
            paint(hdc);
            EndPaint(m_hWnd, &ps);
            return 0;
        }
        break;
    case WM_TIMER:
        switch (wp)
        {
        case animation_timer_id:
            KillTimer(m_hWnd, animation_timer_id);
            redraw();
            return 0;
            break;
        case cycle_timer_id:
            if (static_api_ptr_t<ui_control>()->is_visible())
            {
                func_NextSource(false);
            }
            else
            {
                start_cycle_timer();
            }
            return 0;
            break;
        }
        break;
    case WM_GETMINMAXINFO:
        {
            LPMINMAXINFO mmi = LPMINMAXINFO(lp);
            mmi->ptMinTrackSize.y = m_config.minheight;
            mmi->ptMinTrackSize.x = m_config.minwidth;
        }
        break;
    }
    return uDefWindowProc(wnd1, msg, wp, lp);
}
Esempio n. 4
0
int CALLBACK MainWindowProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	static HWND hWndStart;
	static HWND hWndClearObjs;
	static HWND hWndDiscAll;
	static HWND hWndDBTYPE;
	static HWND hWndDBIP;
	static HWND hWndDBNAME;
	static HWND hWndDBUSER;
	static HWND hWndDBPASSWORD;
	static HWND hWndCONFIG;
	static HWND hWndACCESSFILE;
	static HWND hWndPrivate;
	static HWND hWndUpdate;

	static HWND hWndSettings[30];
	static BOOL fExit = FALSE;
	static HWND hWndExit;
	static UINT s_uTaskbarRestart;
	static BOOL fMinimized = FALSE;

	switch ( msg )
	{	
		case WM_INITDIALOG:
		{
			HICON hIcon;
			hIcon = LoadIcon( g_hInstance, MAKEINTRESOURCE( IDI_ICON ) );
			SendMessage( hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon );
			SendMessage( hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon );
			DeleteObject( hIcon );

			s_uTaskbarRestart = RegisterWindowMessage( TEXT( "TaskbarCreated" ) );

			g_hWndConsole	= GetDlgItem( hWnd, IDC_CONSOLE );
			g_hWndHelpTitle	= GetDlgItem( hWnd, IDC_HELP_TITLE );
			g_hWndHelp		= GetDlgItem( hWnd, IDC_HELP_TEXT );
			hWndDBTYPE		= GetDlgItem( hWnd, IDC_DBTYPE );
			hWndDBIP		= GetDlgItem( hWnd, IDC_DBIP );
			hWndDBNAME		= GetDlgItem( hWnd, IDC_DBNAME );
			hWndDBUSER		= GetDlgItem( hWnd, IDC_DBUSER );
			hWndDBPASSWORD	= GetDlgItem( hWnd, IDC_DBPASSWORD );
			hWndACCESSFILE	= GetDlgItem( hWnd, IDC_ACCESS_FILE );
			hWndCONFIG		= GetDlgItem( hWnd, IDC_CONFIG );
			hWndPrivate		= GetDlgItem( hWnd, IDC_SERVER );
			hWndUpdate		= GetDlgItem( hWnd, IDC_BTN_UPDATE );

			hWndSettings[0]	= GetDlgItem( hWnd, IDC_STATIP );
			hWndSettings[1]	= GetDlgItem( hWnd, IDC_STATCP );
			hWndSettings[2]	= GetDlgItem( hWnd, IDC_STATWP );
			hWndSettings[3]	= GetDlgItem( hWnd, IDC_STATDBIP );
			hWndSettings[4]	= GetDlgItem( hWnd, IDC_STATDBN );
			hWndSettings[5]	= GetDlgItem( hWnd, IDC_STATDBU );
			hWndSettings[6]	= GetDlgItem( hWnd, IDC_STATDBPASS );
			hWndSettings[7]	= GetDlgItem( hWnd, IDC_LOCALIP );
			hWndSettings[8]	= GetDlgItem( hWnd, IDC_CHARPORT );
			hWndSettings[9]	= GetDlgItem( hWnd, IDC_WORLDPORT );
			hWndSettings[10]	= GetDlgItem( hWnd, IDC_MYSQL_DB );
			hWndSettings[11]	= GetDlgItem( hWnd, IDC_MSSQL_DB );
			hWndSettings[12]	= GetDlgItem( hWnd, IDC_ACCESS_DB );
			hWndSettings[13]	= GetDlgItem( hWnd, IDC_SETTING_FRAME );
			hWndSettings[14]	= GetDlgItem( hWnd, IDC_FRAME_DB );
			hWndSettings[15]	= GetDlgItem( hWnd, IDC_STAT_MAXUSERS );
			hWndSettings[16]	= GetDlgItem( hWnd, IDC_MAX_USERS );
			hWndSettings[17]	= GetDlgItem( hWnd, IDC_STAT_SNAME );
			hWndSettings[18]	= GetDlgItem( hWnd, IDC_ED_SNAME );
							
			WSADATA		wsaData;
			struct hostent *host;
			USHORT		wVersionRequested = 0x0202;
 
			UpdateConsole( " Initializing Winsock 2.0 ... ", !WSAStartup( wVersionRequested, &wsaData ) );
			
			host = NULL;
/*
			////////// Read in Data
			FILE *pcStatConfig = fopen( "status.ini","rt" );

			if ( pcStatConfig )
			{
				char line[100];

				while ( !feof( pcStatConfig ) )
				{
					fgets( line, 100, pcStatConfig );
					char temp[100];
					char strData[50];
					char value[50];

					memcpy(temp,line,sizeof(line));
					char* pszSepTemp = strchr(temp, (int)'=');

					if(pszSepTemp == NULL)
					{
					}
					else
					{
						*pszSepTemp = '\0';
						sprintf(strData,"%s",temp);
					}

					char* pszSep = strchr(line, (int)'=');	

					if(pszSep == NULL)
					{
						// No data
					}
					else
					{
						*pszSep = '\0';
						++pszSep;
						char* pszValue = strchr(pszSep, (int)';');
						if(pszValue == NULL){
						}
						else
						{
							*pszValue = '\0';
						}
					
						sprintf(value,"%s",pszSep);
						
						if (lstrcmpi(strData,"Server") == 0)
							{
								if( lstrcmpi(value,"Private") == 0)
								{
									UpdateConsole(" Server: Private\r\n");
									cMasterServer::cStatus->m_fPrivate = 1;
								}
								else
								{
									UpdateConsole(" Server: Public\r\n");
									cMasterServer::cStatus->m_fPrivate = 0;
								}
							}
						else if(lstrcmpi(strData,"Host") == 0)
							{
								if(isalpha(value[0]))
								{
									//Do DNS Lookup for IP
									host = gethostbyname(value);
									memcpy(cMasterServer::cStatus->m_strHost,inet_ntoa(*(struct in_addr *) host->h_addr_list[0]),16);
								}
								else
								{
									memcpy(cMasterServer::cStatus->m_strHost,value,sizeof(value));
								}	
							}
						else if(lstrcmpi(strData,"Port") == 0)
							{
								cMasterServer::cStatus->m_sPort = atoi(value);
							}
						else if(lstrcmpi(strData,"Path") == 0)
							{
								memcpy(cMasterServer::cStatus->m_strHTTP,value,sizeof(value));
							}					
						else if(lstrcmpi(strData,"ID") == 0)
							{
								cMasterServer::cStatus->m_sID = atol(value);
							}
						else if(lstrcmpi(strData,"Serial") == 0)
							{
								memcpy(cMasterServer::cStatus->m_sSer,value,sizeof(value));
							}
						else if(lstrcmpi(strData,"Key") == 0)
							{
								memcpy(cMasterServer::cStatus->m_sKey,value,sizeof(value));
							}
						else if(lstrcmpi(strData,"Client") == 0)
							{
								memcpy(cMasterServer::cStatus->m_cVersion,value,sizeof(value));
							}
						else if(lstrcmpi(strData,"MaxUsers") == 0)
							{
								cMasterServer::cStatus->m_dwMax = atol(value);
							}
						else
							{
							//	UpdateConsole("Error in status.ini   %s\r\n", strData);
							}
					}
				}
				fclose( pcStatConfig );
			}
			else
			{
				cMasterServer::cStatus->m_fPrivate = true;

			}
*/
			cMasterServer::cStatus->m_fPrivate = true;

			//////////////////
			SetDlgItemText( hWnd, IDC_VERSIONTEXT, SERVERVERSION);
			SetDlgItemText( hWnd, IDC_VERSIONTEXT2, STRFILEVER);

			DWORD dwLength;
			DWORD dwType = REG_SZ;
			char szTemp[5];
			char szDBType[2];
			char szStatusTemp[20];
			char szHostTemp[64];

			HKEY hKey;
			RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\UAS", NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL );
		
			////////////////////////
			// Server Status Settings
			dwLength = sizeof( szStatusTemp );
			if ( ( RegQueryValueEx( hKey, "Private", NULL, &dwType, (BYTE*)&szStatusTemp, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				cMasterServer::cStatus->m_fPrivate = atoi(szStatusTemp);
				CheckDlgButton( hWnd, IDC_SERVER, cMasterServer::cStatus->m_fPrivate );
			}
			else
			{
				CheckDlgButton( hWnd, IDC_SERVER, 1 );
				cMasterServer::cStatus->m_fPrivate = 1;
			}
			
			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "Status Host", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				if(isalpha(szHostTemp[0]))
				{
					//Do DNS Lookup for IP
					host = gethostbyname(szHostTemp);
					memcpy(cMasterServer::cStatus->m_strHost,inet_ntoa(*(struct in_addr *) host->h_addr_list[0]),16);
					SetDlgItemText( hWnd, IDC_ED_HOST, szHostTemp );
				}
				else
				{
					memcpy(cMasterServer::cStatus->m_strHost,szHostTemp,sizeof(szHostTemp));
					SetDlgItemText( hWnd, IDC_ED_HOST, szHostTemp );
				}
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_HOST, "127.0.0.1" );
				memcpy(cMasterServer::cStatus->m_strHost,"127.0.0.1",10);
			}
						
			dwLength = sizeof( szTemp );
			if ( ( RegQueryValueEx( hKey, "HTTP Port", NULL, &dwType, (BYTE*)&szTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ED_PORT, szTemp );
				cMasterServer::cStatus->m_sPort = atoi(szTemp);
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_PORT, "80" );
				cMasterServer::cStatus->m_sPort = 80;
			}

			dwLength = sizeof( szTemp );
			if ( ( RegQueryValueEx( hKey, "Server ID", NULL, &dwType, (BYTE*)&szTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ED_ID, szTemp );
				cMasterServer::cStatus->m_sID = atol(szTemp);
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_ID, "0" );
				cMasterServer::cStatus->m_sID = 0;
			}

			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "Server Serial", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ED_SERIAL, szHostTemp );
				memcpy(cMasterServer::cStatus->m_sSer,szHostTemp,sizeof(szHostTemp));
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_SERIAL, "0" );
				memcpy(cMasterServer::cStatus->m_sSer,"0",2);
			}
			
			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "Server Key", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ED_KEY, szHostTemp );
				memcpy(cMasterServer::cStatus->m_sKey,szHostTemp,sizeof(szHostTemp));
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_KEY, "000000" );
				memcpy(cMasterServer::cStatus->m_sKey,"000000",7);
			}

			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "Client Support", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ED_CLIENT, szHostTemp );
				memcpy(cMasterServer::cStatus->m_cVersion,szHostTemp,sizeof(szHostTemp));
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_CLIENT, "53" );
				memcpy(cMasterServer::cStatus->m_cVersion,"53",3);
			}
						
			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "HTTP Path", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ED_URL, szHostTemp );
				memcpy(cMasterServer::cStatus->m_strHTTP,szHostTemp,sizeof(szHostTemp));
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_URL, "/" );
				memcpy(cMasterServer::cStatus->m_strHTTP,"/",2);
			}
			
			////////////////////////
			// Server Settings
			// Server Name
			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "Server Name", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_STAT_NAME, szHostTemp );
				SetDlgItemText( hWnd, IDC_ED_SNAME, szHostTemp );
				memcpy(cMasterServer::m_szServerName,szHostTemp,sizeof(szHostTemp));
			}
			else
			{
				SetDlgItemText( hWnd, IDC_ED_SNAME, "World Name" );
				SetDlgItemText( hWnd, IDC_STAT_NAME, "World Name" );
				sprintf(cMasterServer::m_szServerName,"World Name" );
			}

			dwLength = sizeof( szHostTemp );
			if ( ( RegQueryValueEx( hKey, "Max Clients", NULL, &dwType, (BYTE*)&szHostTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_MAX_USERS, szHostTemp );
				cMasterServer::cStatus->m_dwMax = atol(szHostTemp);
			}
			else
			{
				SetDlgItemText( hWnd, IDC_MAX_USERS, "0" );
				cMasterServer::cStatus->m_dwMax = 0x0L;
			}

			//Character Server Port
			dwLength = sizeof( szTemp );
			if ( ( RegQueryValueEx( hKey, "CharPort", NULL, &dwType, (BYTE*)&szTemp, &dwLength) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_CHARPORT, szTemp );
			else
				SetDlgItemText( hWnd, IDC_CHARPORT, "9002" );

			// World Server Port
			dwLength = sizeof( szTemp );
			if ( ( RegQueryValueEx( hKey, "WorldPort", NULL, &dwType, (BYTE*)&szTemp, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_WORLDPORT, szTemp );
			else
				SetDlgItemText( hWnd, IDC_WORLDPORT, "9004" );
			
			/////////////
			// Database Settings
	
			dwLength = sizeof( szDBType );
			if ( ( RegQueryValueEx( hKey, "DBType", NULL, &dwType, (BYTE*)&szDBType, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{	// Set Radio button depending on Value
				SetDlgItemText( hWnd, IDC_DBTYPE, szDBType );
				g_DBType = szDBType[0] - 0x30;
				switch(g_DBType)
				{
					case 1:
					{
						CheckDlgButton( hWnd, IDC_ACCESS_DB, 1 );
						CheckDlgButton( hWnd, IDC_MSSQL_DB, 0 );
						CheckDlgButton( hWnd, IDC_MYSQL_DB, 0 );
									
						// Disable dialog boxes
						EnableWindow( hWndDBIP, FALSE );
						EnableWindow( hWndDBNAME, FALSE );
						EnableWindow( hWndDBUSER, FALSE );
						EnableWindow( hWndDBPASSWORD, FALSE );
						break;
					}
					case 2:
					{					
						CheckDlgButton( hWnd, IDC_ACCESS_DB, 0 );
						CheckDlgButton( hWnd, IDC_MSSQL_DB, 1 );
						CheckDlgButton( hWnd, IDC_MYSQL_DB, 0 );
						
						// Enable dialog boxes
						EnableWindow( hWndDBIP, TRUE );
						EnableWindow( hWndDBNAME, TRUE );
						EnableWindow( hWndDBUSER, TRUE );
						EnableWindow( hWndDBPASSWORD, TRUE );
						break;
					}
					case 3:
					{
						CheckDlgButton( hWnd, IDC_ACCESS_DB, 0 );
						CheckDlgButton( hWnd, IDC_MSSQL_DB, 0 );
						CheckDlgButton( hWnd, IDC_MYSQL_DB, 1 );
						
						// Enable dialog boxes
						EnableWindow( hWndDBIP, TRUE );
						EnableWindow( hWndDBNAME, TRUE );
						EnableWindow( hWndDBUSER, TRUE );
						EnableWindow( hWndDBPASSWORD, TRUE );
						break;
					}

					default:
					{
						CheckDlgButton( hWnd, IDC_ACCESS_DB, 0 );
						CheckDlgButton( hWnd, IDC_MSSQL_DB, 0 );
						CheckDlgButton( hWnd, IDC_MYSQL_DB, 1 );
									
						// Enable dialog boxes
						EnableWindow( hWndDBIP, TRUE );
						EnableWindow( hWndDBNAME, TRUE );
						EnableWindow( hWndDBUSER, TRUE );
						EnableWindow( hWndDBPASSWORD, TRUE );
						break;
					}
				}
			}
			else
			{
				// DBType = Default -- MySQL db
				CheckDlgButton( hWnd, IDC_ACCESS_DB, 0 );
				CheckDlgButton( hWnd, IDC_MSSQL_DB, 0 );
				CheckDlgButton( hWnd, IDC_MYSQL_DB, 1 );
			}

			dwLength = sizeof( g_szDBIP );
			if ( ( RegQueryValueEx( hKey, "DBIP", NULL, &dwType, (BYTE*)&g_szDBIP, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_DBIP, g_szDBIP );
			else
				SetDlgItemText( hWnd, IDC_DBIP, "0.0.0.0" );
			
			dwLength = sizeof( g_szDBNAME );
			if ( ( RegQueryValueEx( hKey, "DBNAME", NULL, &dwType, (BYTE*)&g_szDBNAME, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_DBNAME, g_szDBNAME );
			else
				SetDlgItemText( hWnd, IDC_DBNAME, "uas2" );
			
			dwLength = sizeof( g_szDBUSER );
			if ( ( RegQueryValueEx( hKey, "DBUSER", NULL, &dwType, (BYTE*)&g_szDBUSER, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_DBUSER, g_szDBUSER );
			else
				SetDlgItemText( hWnd, IDC_DBUSER, "uas2" );
			
			dwLength = sizeof( g_szDBPASSWORD );
			if ( ( RegQueryValueEx( hKey, "DBPASSWORD", NULL, &dwType, (BYTE*)&g_szDBPASSWORD, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_DBPASSWORD, g_szDBPASSWORD );
			else
				SetDlgItemText( hWnd, IDC_DBPASSWORD, "" );
//////////////////////////////////////////////////////////////////

			// Local IP
			dwLength = sizeof( g_szLocalIP );
			if ( ( RegQueryValueEx( hKey, "LocalIP", NULL, &dwType, (BYTE*)&g_szLocalIP, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
				SetDlgItemText( hWnd, IDC_LOCALIP, g_szLocalIP );
			else
			{
				char szLocalHostName[80];
				DWORD dwSize = sizeof( szLocalHostName );
				if ( GetLocalAddress( szLocalHostName, &dwSize ) == 0 )
					SetDlgItemText( hWnd, IDC_LOCALIP, szLocalHostName );
				else
					SetDlgItemText( hWnd, IDC_LOCALIP, "127.0.0.1" );
			}
	
			// Access Database 
			char	szDirBuff[MAX_PATH+1];
			dwLength = sizeof( cWorldManager::g_szAccessFile );
			if ( ( RegQueryValueEx( hKey, "ACCESSMDB", NULL, &dwType, (BYTE*)&cWorldManager::g_szAccessFile, &dwLength ) == ERROR_SUCCESS ) && ( dwLength > 0 ) )
			{
				SetDlgItemText( hWnd, IDC_ACCESS_FILE, cWorldManager::g_szAccessFile );
			}
			else
			{
				int index = GetCurrentDirectory(MAX_PATH, szDirBuff);
				sprintf(cWorldManager::g_szAccessFile,"%s\\UAS2.mdb", szDirBuff );
				SetDlgItemText( hWnd, IDC_ACCESS_FILE,cWorldManager::g_szAccessFile );
			}

			RegCloseKey( hKey );

			hWndStart = GetDlgItem( hWnd, IDB_START );
			hWndClearObjs = GetDlgItem( hWnd, IDB_CLEAROBJECTS );
			hWndDiscAll = GetDlgItem( hWnd, IDB_DISC_ALL );
			hWndExit = GetDlgItem( hWnd, IDB_EXIT );

			/////// Server Status Data ///////////////////////////////////////////////
			char szPort[5];
			char szTempIP[16];
			SOCKADDR_IN	saServer;

			GetDlgItemText( hWnd, IDC_LOCALIP, szTempIP, sizeof( szTempIP ) );
			saServer.sin_addr.s_addr	= inet_addr( szTempIP );
		
			cMasterServer::cStatus->m_bServer[0] = saServer.sin_addr.S_un.S_un_b.s_b1;
			cMasterServer::cStatus->m_bServer[1] = saServer.sin_addr.S_un.S_un_b.s_b2;
			cMasterServer::cStatus->m_bServer[2] = saServer.sin_addr.S_un.S_un_b.s_b3;
			cMasterServer::cStatus->m_bServer[3] = saServer.sin_addr.S_un.S_un_b.s_b4;

			GetDlgItemText( hWnd, IDC_CHARPORT, szPort, sizeof( szPort ) );
			cMasterServer::cStatus->m_ServerPort = atoi( szPort );
			///////////////////////////////////////////////////////////////////////////
			MoveWindow( hWnd,0 , 0 , CONSOLE_WIDTH_NORM ,CONSOLE_HEIGHT_NORM , TRUE );

			cMasterServer::cStatus->ServerLoad();

			break;	// case WM_INITDIALOG
		}

		case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO( lParam )->ptMinTrackSize.x = 340;
			LPMINMAXINFO( lParam )->ptMinTrackSize.y = CONSOLE_HEIGHT_NORM;//150
			break;	// case WM_GETMINMAXINFO
		}

		case WM_SIZE:
		{
			MoveWindow( g_hWndConsole, 8, 95, LOWORD( lParam ) - 15, HIWORD( lParam ) - 100, TRUE );

			if( wParam == SIZE_MINIMIZED )
			{
				SystrayAdd( hWnd );
				ShowWindow( hWnd, SW_HIDE );
				fMinimized = TRUE;
			}
			else if( wParam == SIZE_RESTORED )
			{
				SystrayDelete( hWnd );
				fMinimized = FALSE;	
			}

			break;	// case WM_SIZE
		}

		case WM_NOTIFY:
		{
			break;	// case WM_NOTIFY
		}

		case WM_COMMAND:
		{	
			switch ( GET_WM_COMMAND_ID( wParam, lParam ) )
			{
				case IDC_LOCALIP:
					{
						UpdateHelpTitle( "Local IP:\r\n");
						UpdateHelp( "The IP address or DNS name of the hosting server. The default value is the IP address 127.0.0.1 (the loopback IP address).\r\n");
						break;
					}
				case IDC_SERVER:
					{
						UpdateHelpTitle( "Private Server Checkbox:\r\n");
						UpdateHelp( "When checked, server will not send updates to the status website. The option does not affect how the server operates.\r\n");
						break;
					}
				case IDC_CHARPORT:
					{
						UpdateHelpTitle( "Character Server Port:\r\n");
						UpdateHelp( "The number of the TCP or UDP port used to connect to the Character Server. The default value is 9002.\r\n");
						break;
					}
				case IDC_MAX_USERS:
					{
						UpdateHelpTitle( "Maximum Clients:\r\n");
						UpdateHelp( "The maximum number of clients the server allows. Not implemented.\r\n");
						break;
					}
				case IDC_WORLDPORT:
					{
						UpdateHelpTitle( "World Server Port:\r\n");
						UpdateHelp( "The number of the TCP or UDP port used to connect to the World Server. The default value is 9004.\r\n");
						break;
					}
				case IDC_ED_SNAME:
					{
						UpdateHelpTitle( "World Name:\r\n");
						UpdateHelp( "The name used to identify the world hosted by this server. Appears in the MOTD during login process.\r\n");
						break;
					}

				case IDC_ACCESS_FILE:
					{
						UpdateHelpTitle( "Microsoft Access File:\r\n");
						UpdateHelp( "The full path to the UAS2 Microsoft Access (.mdb) database file. The default path is the working directory.\r\n");
						break;
					}
				case IDC_DBIP:
					{
						UpdateHelpTitle( "Database IP:\r\n");
						UpdateHelp( "The IP address of the database server.  The value must be an IP address and not a DNS name.\r\n");
						break;
					}
				case IDC_DBNAME:
					{
						UpdateHelpTitle( "Database Name:\r\n");
						UpdateHelp( "The name of the UAS2 database.\r\n");
						break;
					}
				case IDC_DBUSER:
					{
						UpdateHelpTitle( "Database User:\r\n");
						UpdateHelp( "A username with permission to access the database.\r\n");
						break;
					}
				case IDC_DBPASSWORD:
					{
						UpdateHelpTitle( "Database Password:\r\n");
						UpdateHelp( "The password for the corresponding username.\r\n");
						break;
					}

				case IDC_ED_HOST:
					{
						UpdateHelpTitle( "State Website Host:\r\n");
						UpdateHelp( "The IP address or DNS name of the website hosting the server status pages.\r\n");
						break;
					}
				case IDC_ED_URL:
					{
						UpdateHelpTitle( "URL Path:\r\n");
						UpdateHelp( "The URL path to the server status webpage. Must start with '/' and end with '/'.\r\n");
						break;
					}
				case IDC_ED_PORT:
					{
						UpdateHelpTitle( "Access Port:\r\n");
						UpdateHelp( "The number of the TCP or UDP port used to access the server status website. The default port number is 80 (HTTP).\r\n");
						break;
					}
				case IDC_ED_ID:
					{
						UpdateHelpTitle( "Server ID:\r\n");
						UpdateHelp( "The server ID for the server status listing. Supplied by the host website during registration.\r\n");
						break;
					}
				case IDC_ED_KEY:
					{
						UpdateHelpTitle( "Key ID:\r\n");
						UpdateHelp( "The key ID for the server status listing. Supplied by the host website during registration.\r\n");
						break;
					}
				case IDC_ED_CLIENT:
					{
						UpdateHelpTitle( "Client Version:\r\n");
						UpdateHelp( "Specifies which client(s) are supported with this server. Supplied by the host website during registration.\r\n");
						break;
					}
				case IDC_ED_SERIAL:
					{
						UpdateHelpTitle( "Serial Code:\r\n");
						UpdateHelp( "The serial code for your server to use when connecting to the server status host website. Supplied by the host website during registration.\r\n");
						break;
					}

				case IDC_WBBOX:
					{
						UpdateHelpTitle( "World Broadcast:\r\n");
						UpdateHelp( "A message that may be sent to all users presently connected to the world.\r\n");
						break;
					}

				case IDB_EXIT:
					{
						UpdateConsole( "\r\n Exiting server. Please wait ...\r\n" );
						cMasterServer::cStatus->ServerOffline();
						PostMessage( hWnd, WM_CLOSE, 0, 0 );
						EnableWindow( hWndExit, FALSE );
						break;	// case IDB_EXIT
					}

				case IDB_CLEAROBJECTS:
					if ( g_fStarted )
					{
						cMasterServer::ClearAllObjects( );
						UpdateConsole( " All spawned objects cleared!\r\n" );
						break;
					}
					break;

				case IDB_DISC_ALL:
				{
					if( g_fStarted )
					{
						cMasterServer::DisconnectAllClients( );
						UpdateConsole( " All clients disconnected!\r\n" );
						break;
					}
					break;
				}

				//Karki
				case IDC_WB:
					if ( g_fStarted )
					{
						UpdateConsole( " World broadcast sent!\r\n" );
						char szWBTemp[255];
						GetDlgItemText( hWnd, IDC_WBBOX, szWBTemp, sizeof( szWBTemp ) );
						cMasterServer::ServerMessage( ColorGreen, NULL, "%s", szWBTemp );
					}
					break;

				case IDB_START:
				{
					if ( g_fStarted )
					{					
						EnableWindow( hWndStart, FALSE );
						EnableWindow( hWndClearObjs, FALSE );
						EnableWindow( hWndDiscAll, FALSE );
						
						g_fStarted = !cMasterServer::Unload( );

						if( ( fExit ) && ( !g_fStarted ) )
						{
							SystrayDelete( hWnd );
							DestroyWindow( hWnd );
							PostQuitMessage( 0 );
						}
						
						SetWindowText( hWndStart, "&Start Server" );
						EnableWindow( hWndStart, TRUE );
					}
					else
					{
						g_fStarted = TRUE;

						char szTemp[5];

						GetDlgItemText( hWnd, IDC_LOCALIP, g_szLocalIP, sizeof( g_szLocalIP ) );
						GetDlgItemText( hWnd, IDC_DBTYPE, szTemp, sizeof( szTemp ) );
						g_DBType = szTemp[0] - 0x30;
						GetDlgItemText( hWnd, IDC_DBIP, g_szDBIP, sizeof( g_szDBIP ) );
						GetDlgItemText( hWnd, IDC_DBNAME, g_szDBNAME, sizeof( g_szDBNAME ) );
						GetDlgItemText( hWnd, IDC_DBUSER, g_szDBUSER, sizeof( g_szDBUSER ) );
						GetDlgItemText( hWnd, IDC_DBPASSWORD, g_szDBPASSWORD, sizeof( g_szDBPASSWORD ) );
						GetDlgItemText( hWnd, IDC_ACCESS_FILE, cWorldManager::g_szAccessFile, sizeof( cWorldManager::g_szAccessFile ) );

						SetDlgItemText( hWnd, IDB_START, "&Stop Server");
							
						GetDlgItemText( hWnd, IDC_CHARPORT, szTemp, sizeof( szTemp ) );
						g_nCharPort = atoi( szTemp );

						GetDlgItemText( hWnd, IDC_WORLDPORT, szTemp, sizeof( szTemp ) );
						g_nWorldPort = atoi( szTemp );

						cDatabase::SetupDB(g_DBType,g_szDBIP,g_szDBNAME,g_szDBUSER,g_szDBPASSWORD);

						cMasterServer::Load( );

						EnableWindow( hWndClearObjs, TRUE );
						EnableWindow( hWndDiscAll, TRUE );
					}
					break;	// case IDB_START
				}

				case ID_SYSTRAY_ACE:
				{
					ShowWindow( hWnd, SW_RESTORE );
					SetForegroundWindow( hWnd );
					SendMessage( hWnd, WM_ACTIVATEAPP, ( WPARAM )TRUE, ( LPARAM )NULL );
					break;
				}

				case ID_SYSTRAY_EXIT:
				{
					PostMessage( hWnd, WM_CLOSE, 0, 0 );
					break;
				}

				case IDC_CONFIG:
				{
					if(g_fConfig == FALSE)
					{
						UpdateHelpTitle("Configuration Settings:\r\n");
						UpdateHelp("Changes will not take effect until the server program is restarted.\r\n");
						MoveWindow( hWnd,0 , 0 , CONSOLE_WIDTH_OPT ,CONSOLE_HEIGHT_OPT , TRUE );
						ShowWindow( hWndDBIP, SW_SHOW );
						ShowWindow( hWndDBNAME, SW_SHOW );
						ShowWindow( hWndDBUSER, SW_SHOW );
						ShowWindow( hWndDBPASSWORD, SW_SHOW );
						ShowWindow( hWndACCESSFILE, SW_SHOW );
						ShowWindow( hWndPrivate, SW_SHOW );
						SetWindowText( hWndCONFIG, "Status" );
						for(int i = 0; i< 30;i++)
						{
							ShowWindow( hWndSettings[i], SW_SHOW );
						}
						ShowWindow( g_hWndConsole, SW_HIDE );
						g_fConfig = TRUE;
					}
					else
					{
						MoveWindow( hWnd,0 , 0 , CONSOLE_WIDTH_NORM ,CONSOLE_HEIGHT_NORM , TRUE );						
						ShowWindow( hWndDBIP, SW_HIDE );
						ShowWindow( hWndDBNAME, SW_HIDE );
						ShowWindow( hWndDBUSER, SW_HIDE );
						ShowWindow( hWndDBPASSWORD, SW_HIDE );
						ShowWindow( hWndACCESSFILE, SW_HIDE );
						ShowWindow( hWndPrivate, SW_HIDE );
						SetWindowText( hWndCONFIG, "Settings" );
						for(int i = 0; i< 30;i++)
						{
							ShowWindow( hWndSettings[i], SW_HIDE );
						}
						ShowWindow( g_hWndConsole, SW_SHOW );
						g_fConfig = FALSE;
					}

					break;
				}

				case IDC_ACCESS_DB:
				{
					// Disable Dialog boxes
					EnableWindow( hWndDBIP, FALSE );
					EnableWindow( hWndDBNAME, FALSE );
					EnableWindow( hWndDBUSER, FALSE );
					EnableWindow( hWndDBPASSWORD, FALSE );
					EnableWindow( hWndACCESSFILE, TRUE );

					CheckDlgButton( hWnd, IDC_ACCESS_DB, 1 );
					CheckDlgButton( hWnd, IDC_MSSQL_DB, 0 );
					CheckDlgButton( hWnd, IDC_MYSQL_DB, 0 );

					SetDlgItemText( hWnd, IDC_DBTYPE, "1" );

					UpdateHelpTitle( "Microsoft Access:\r\n");
					UpdateHelp( "A relational database management system supported by the server. Requires the use of a Microsoft Access (.mdb) database file.\r\n");

					break;
				}

				case IDC_MSSQL_DB:
				{
					// Enable Dialog boxes
					EnableWindow( hWndDBIP, TRUE );
					EnableWindow( hWndDBNAME, TRUE );
					EnableWindow( hWndDBUSER, TRUE );
					EnableWindow( hWndDBPASSWORD, TRUE );
					EnableWindow( hWndACCESSFILE, FALSE );
					
					CheckDlgButton( hWnd, IDC_ACCESS_DB, 0 );
					CheckDlgButton( hWnd, IDC_MSSQL_DB, 1 );
					CheckDlgButton( hWnd, IDC_MYSQL_DB, 0 );

					SetDlgItemText( hWnd, IDC_DBTYPE, "2" );
					
					UpdateHelpTitle( "MS SQL:\r\n");
					UpdateHelp( "A relational database management system supported by the server. Requires access to an MS SQL database.\r\n");
						
					break;
				}

				case IDC_MYSQL_DB:
				{
					// Enable Dialog boxes
					EnableWindow( hWndDBIP, TRUE );
					EnableWindow( hWndDBNAME, TRUE );
					EnableWindow( hWndDBUSER, TRUE );
					EnableWindow( hWndDBPASSWORD, TRUE );
					EnableWindow( hWndACCESSFILE, FALSE );
					
					CheckDlgButton( hWnd, IDC_ACCESS_DB, 0 );
					CheckDlgButton( hWnd, IDC_MSSQL_DB, 0 );
					CheckDlgButton( hWnd, IDC_MYSQL_DB, 1 );

					SetDlgItemText( hWnd, IDC_DBTYPE, "3" );
					
					UpdateHelpTitle( "MySQL:\r\n");
					UpdateHelp( "A relational database management system supported by the server. Requires access to a MySQL database.\r\n");

					break;
				}

				case IDC_BTN_UPDATE:
				{
					char szTemp[5];
					char szDBType[2];
					char szDBTemp[20];

					HKEY hKey;
					RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\UAS", NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
					
					GetDlgItemText( hWnd, IDC_LOCALIP, g_szLocalIP, sizeof( g_szLocalIP ) );
					RegSetValueEx( hKey, "LocalIP", NULL, REG_SZ, (BYTE*)g_szLocalIP, lstrlen( g_szLocalIP ) );
					
					GetDlgItemText( hWnd, IDC_CHARPORT, szTemp, sizeof( szTemp ) );
					RegSetValueEx( hKey, "CharPort", NULL, REG_SZ, (BYTE*)szTemp, lstrlen( szTemp ) );

					GetDlgItemText( hWnd, IDC_WORLDPORT, szTemp, sizeof( szTemp ) );
					RegSetValueEx( hKey, "WorldPort", NULL, REG_SZ, (BYTE*)szTemp, lstrlen( szTemp ) );

					// Database Settings //////////////////////////////////////////////////////////////
					GetDlgItemText( hWnd, IDC_DBTYPE, szDBType, sizeof( szDBType ) );
					RegSetValueEx( hKey, "DBTYPE", NULL, REG_SZ, (BYTE*)szDBType, lstrlen( szDBType ) );

					GetDlgItemText( hWnd, IDC_DBIP, szDBTemp, sizeof( szDBTemp ) );
					RegSetValueEx( hKey, "DBIP", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
					
					GetDlgItemText( hWnd, IDC_DBNAME, szDBTemp, sizeof( szDBTemp ) );
					RegSetValueEx( hKey, "DBNAME", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
					
					GetDlgItemText( hWnd, IDC_DBUSER, szDBTemp, sizeof( szDBTemp ) );
					RegSetValueEx( hKey, "DBUSER", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
					
					GetDlgItemText( hWnd, IDC_DBPASSWORD, szDBTemp, sizeof( szDBTemp ) );
					RegSetValueEx( hKey, "DBPASSWORD", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
					
					char szAccessTemp[MAX_PATH+20];
					GetDlgItemText( hWnd, IDC_ACCESS_FILE, szAccessTemp, sizeof( szAccessTemp ) );
					RegSetValueEx( hKey, "ACCESSMDB", NULL, REG_SZ, (BYTE*)szAccessTemp, lstrlen( szAccessTemp ) );

					///////////////////////////////////////////////////////////////////////////////////
					// Status Server Settings
					char szHostTemp[64];

					int nState;
					nState = IsDlgButtonChecked( hWnd, IDC_SERVER);
					sprintf(szDBTemp,"%d",nState);
					RegSetValueEx( hKey, "Private", NULL, REG_SZ, (BYTE*)szDBTemp, sizeof(szDBTemp) );

					GetDlgItemText( hWnd, IDC_ED_HOST, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "Status Host", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
								
					GetDlgItemText( hWnd, IDC_ED_PORT, szDBTemp, sizeof( szDBTemp ) );
					RegSetValueEx( hKey, "HTTP Port", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
											
					GetDlgItemText( hWnd, IDC_ED_ID, szDBTemp, sizeof( szDBTemp ) );
					RegSetValueEx( hKey, "Server ID", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
														
					GetDlgItemText( hWnd, IDC_ED_SNAME, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "Server Name", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
					memcpy(cMasterServer::m_szServerName,szHostTemp,sizeof(szHostTemp));
																	
					GetDlgItemText( hWnd, IDC_ED_SERIAL, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "Server Serial", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
																	
					GetDlgItemText( hWnd, IDC_ED_KEY, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "Server Key", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
																	
					GetDlgItemText( hWnd, IDC_ED_URL, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "HTTP Path", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
																				
					GetDlgItemText( hWnd, IDC_ED_CLIENT, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "Client Support", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
																				
					GetDlgItemText( hWnd, IDC_MAX_USERS, szHostTemp, sizeof( szHostTemp ) );
					RegSetValueEx( hKey, "Max Clients", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
					/////////////////////////////////////////////////////////////////////////////////////
					
					RegCloseKey( hKey );
					break;
				}
				default:
					break;	// case default
			}
			break;	// case WM_COMMAND
		}

		case MYWM_NOTIFYICON:
		{
			switch (lParam)
			{
				case WM_LBUTTONDOWN:
				{
					ShowWindow( hWnd, SW_RESTORE );
					SetForegroundWindow( hWnd );
					SendMessage( hWnd, WM_ACTIVATEAPP, ( WPARAM )TRUE, ( LPARAM )NULL );
					break;
				}

				case WM_RBUTTONUP:
				{
					HMENU hTrayMenu;
					HMENU hMenu;
					POINT point;

					SetForegroundWindow( hWnd );

					hTrayMenu = LoadMenu( g_hInstance, MAKEINTRESOURCE( ID_SYSTRAY ) );
					hMenu = GetSubMenu( hTrayMenu, 0 );
					GetCursorPos( &point );

					TrackPopupMenu( hMenu, TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL );
					DestroyMenu( hMenu );
					DestroyMenu( hTrayMenu );

					PostMessage( hWnd, WM_NULL, 0, 0 ); 

					break;
				}
			}
			break;
		}
		case WM_CLOSE:
		{
			char szTemp[5];
			
			HKEY hKey;
			RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\UAS", NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
			
			GetDlgItemText( hWnd, IDC_LOCALIP, g_szLocalIP, sizeof( g_szLocalIP ) );
			RegSetValueEx( hKey, "LocalIP", NULL, REG_SZ, (BYTE*)g_szLocalIP, lstrlen( g_szLocalIP ) );
			
			GetDlgItemText( hWnd, IDC_CHARPORT, szTemp, sizeof( szTemp ) );
			RegSetValueEx( hKey, "CharPort", NULL, REG_SZ, (BYTE*)szTemp, lstrlen( szTemp ) );

			GetDlgItemText( hWnd, IDC_WORLDPORT, szTemp, sizeof( szTemp ) );
			RegSetValueEx( hKey, "WorldPort", NULL, REG_SZ, (BYTE*)szTemp, lstrlen( szTemp ) );

			// Database Settings //////////////////////////////////////////////////////////////
			char szDBType[2];
			char szDBTemp[20];

			GetDlgItemText( hWnd, IDC_DBTYPE, szDBType, sizeof( szDBType ) );
			RegSetValueEx( hKey, "DBTYPE", NULL, REG_SZ, (BYTE*)szDBType, lstrlen( szDBType ) );

			GetDlgItemText( hWnd, IDC_DBIP, szDBTemp, sizeof( szDBTemp ) );
			RegSetValueEx( hKey, "DBIP", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
			
			GetDlgItemText( hWnd, IDC_DBNAME, szDBTemp, sizeof( szDBTemp ) );
			RegSetValueEx( hKey, "DBNAME", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
			
			GetDlgItemText( hWnd, IDC_DBUSER, szDBTemp, sizeof( szDBTemp ) );
			RegSetValueEx( hKey, "DBUSER", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
			
			GetDlgItemText( hWnd, IDC_DBPASSWORD, szDBTemp, sizeof( szDBTemp ) );
			RegSetValueEx( hKey, "DBPASSWORD", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
			
			char szAccessTemp[MAX_PATH+20];
			GetDlgItemText( hWnd, IDC_ACCESS_FILE, szAccessTemp, sizeof( szAccessTemp ) );
			RegSetValueEx( hKey, "ACCESSMDB", NULL, REG_SZ, (BYTE*)szAccessTemp, lstrlen( szAccessTemp ) );
			///////////////////////////////////////////////////////////////////////////////////
			// Status Server Settings
			char szHostTemp[64];

			int nState;
			nState = IsDlgButtonChecked( hWnd, IDC_SERVER);
			sprintf(szDBTemp,"%d",nState);
			RegSetValueEx( hKey, "Private", NULL, REG_SZ, (BYTE*)szDBTemp, sizeof(szDBTemp) );

			GetDlgItemText( hWnd, IDC_ED_HOST, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "Status Host", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
						
			GetDlgItemText( hWnd, IDC_ED_PORT, szDBTemp, sizeof( szDBTemp ) );
			RegSetValueEx( hKey, "HTTP Port", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
									
			GetDlgItemText( hWnd, IDC_ED_ID, szDBTemp, sizeof( szDBTemp ) );
			RegSetValueEx( hKey, "Server ID", NULL, REG_SZ, (BYTE*)szDBTemp, lstrlen( szDBTemp ) );
												
			GetDlgItemText( hWnd, IDC_ED_SNAME, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "Server Name", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
															
			GetDlgItemText( hWnd, IDC_ED_SERIAL, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "Server Serial", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
															
			GetDlgItemText( hWnd, IDC_ED_KEY, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "Server Key", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
															
			GetDlgItemText( hWnd, IDC_ED_URL, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "HTTP Path", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
																		
			GetDlgItemText( hWnd, IDC_ED_CLIENT, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "Client Support", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
																				
			GetDlgItemText( hWnd, IDC_MAX_USERS, szHostTemp, sizeof( szHostTemp ) );
			RegSetValueEx( hKey, "Max Clients", NULL, REG_SZ, (BYTE*)szHostTemp, lstrlen( szHostTemp ) );
			/////////////////////////////////////////////////////////////////////////////////////
			
			RegCloseKey( hKey );

			if ( g_fStarted )
			{
				fExit = TRUE;
				SendMessage( hWnd, WM_COMMAND, IDB_START, TRUE );
			}
			else
			{
				WSACleanup();
				SystrayDelete( hWnd );
				DestroyWindow( hWnd );
				PostQuitMessage( 0 );
			}

			break;	// case WM_CLOSE
		}

		default:
			if( ( msg == s_uTaskbarRestart ) && ( fMinimized ) )
			{
				SystrayDelete( hWnd );
				SystrayAdd( hWnd );
				break;
			}
	}
	return FALSE;
}
Esempio n. 5
0
BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static LPNMTTDISPINFO		lpnmtdi;
	static PAINTSTRUCT			ps;
	static RECT					windowRect;
	static HDC					hdc;

	switch (message)
	{
	case WM_DWMCOMPOSITIONCHANGED:
		ActivateGlass(hDlg);
		InvalidateRect(hDlg, NULL, true);
		break;
	case WM_ACTIVATE:
		ActivateGlass(hDlg);
		break;
	case WM_PAINT:
		hdc = OnPaint(hDlg, windowRect, hdc, ps, IDS_APP_TITLE);
		break;
	case WM_INITDIALOG:
		hInstance = (HINSTANCE) GetWindowLong (hDlg, GWL_HINSTANCE);

		// Set Icon
		hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
		hIconSally = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_SALLY));
		hIconWindow = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_MENU_WINDOW));
		hIconConfig = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_MENU_CONFIG));
		hIconApplication = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_APPLICATION));
		hIconLanguage = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_LANGUAGE));
		hIconTheme = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_THEME));
		hIconKeyboard = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_KEYBORD));

		SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon);
		SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
		
		// Menu
		himl = ImageList_Create(16, 16, ILC_COLOR32, 6, 0);
		ImageList_SetBkColor(himl, CLR_NONE);
		ImageList_AddIcon(himl, hIconWindow);
		ImageList_AddIcon(himl, hIconConfig);
		ImageList_AddIcon(himl, hIconApplication);
		ImageList_AddIcon(himl, hIconTheme);
		ImageList_AddIcon(himl, hIconLanguage);
		ImageList_AddIcon(himl, hIconKeyboard);

		hMenuView.SetHWND(GetDlgItem (hDlg, IDC_LIST_MENU));
		hMenuView.SetImageList(himl, LVSIL_SMALL);
		ListView_SetExtendedListViewStyle(hMenuView.GetHwnd(), LVS_EX_FULLROWSELECT | WS_EX_LTRREADING);

		hMenuView.InitListViewColumns(0, "Settings", 190);

		hMenuView.AddItem(0, 0, GetLocalisation(IDS_MENU_CONFIG, hInstance), 1, 0);
		hMenuView.AddItem(1, 0, GetLocalisation(IDS_MENU_APPLICATIONS, hInstance), 2, 2);
		hMenuView.AddItem(2, 0, GetLocalisation(IDS_MENU_THEMES, hInstance), 3, 3);
		hMenuView.AddItem(3, 0, GetLocalisation(IDS_MENU_LANGUAGES, hInstance), 4, 4);
		hMenuView.AddItem(4, 0, GetLocalisation(IDS_MENU_KEYBOARDS, hInstance), 5, 5);

		// Tabs
		hWndTabConfig = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_CONFIG), hDlg, DlgProcConfig);
		ShowWindow(hWndTabConfig, SW_HIDE);

		hWndTabPlugins = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_PLUGINS), hDlg, DlgProcPlugins);
		ShowWindow(hWndTabPlugins, SW_HIDE);

		hWndTabThemes = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_THEMES), hDlg, DlgProcThemes);
		ShowWindow(hWndTabThemes, SW_HIDE);

		hWndTabLanguages = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_LANGUAGES), hDlg, DlgProcLanguages);
		ShowWindow(hWndTabLanguages, SW_HIDE);

		hWndTabKeyboards = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_KEYBOARDS), hDlg, DlgProcKeyboards);
		ShowWindow(hWndTabKeyboards, SW_HIDE);

		SelectMenu(0);
		hMenuView.SelectItem(0);
		break;
	case WM_NOTIFY:
		lpnmtdi = (LPNMTTDISPINFO) lParam;

		if (lpnmtdi->hdr.hwndFrom == hMenuView.GetHwnd())
		{
			switch(lpnmtdi->hdr.code)
			{
			case LVN_ITEMCHANGED:
				LPNMLISTVIEW li;
				li = (LPNMLISTVIEW)lParam;
				if (li->uNewState != 3)
					break;
			case NM_CLICK:
			case NM_RCLICK:
			case NM_DBLCLK:
			case NM_RDBLCLK:
				SelectMenu();
				break;
			}
		}
		break;
	case WM_SIZE:
		RECT	windowRect;
		RECT	menuViewRect;
		RECT	tempViewRect;

		GetClientRect(hDlg, &windowRect);
		GetClientRect(hMenuView.GetHwnd(), &menuViewRect);

		MoveWindow(hMenuView.GetHwnd(), 7, TOP_BORDER_HEIGHT + 7, CONFIG_MENU_WIDTH - 7, windowRect.bottom - TOP_BORDER_HEIGHT - 14, TRUE);

		GetClientRect(hWndTabConfig, &tempViewRect);
		MoveWindow(hWndTabConfig,
			((windowRect.right - CONFIG_MENU_WIDTH - tempViewRect.right) / 2) + CONFIG_MENU_WIDTH,
			((windowRect.bottom - TOP_BORDER_HEIGHT - tempViewRect.bottom) / 2) + TOP_BORDER_HEIGHT,
			tempViewRect.right, tempViewRect.bottom, TRUE);

		MoveWindow(hWndTabPlugins, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT,
			windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE);

		MoveWindow(hWndTabThemes, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT,
			windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE);

		MoveWindow(hWndTabLanguages, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT,
			windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE);

		MoveWindow(hWndTabKeyboards, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT,
			windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE);

		SendMessage(hWndTabPlugins, WM_COMMAND, WM_SIZE, NULL);
		SendMessage(hWndTabThemes, WM_COMMAND, WM_SIZE, NULL);
		SendMessage(hWndTabLanguages, WM_COMMAND, WM_SIZE, NULL);
		SendMessage(hWndTabKeyboards, WM_COMMAND, WM_SIZE, NULL);
		break;
	case WM_COMMAND:
		switch (LOWORD (wParam))
		{
		case IDCANCEL:
			EndDialog (hDlg, 0);
			return TRUE;
		}
		break;
	case WM_GETMINMAXINFO:
		LPMINMAXINFO(lParam)->ptMinTrackSize.x = 750; // kleinste Breite
		LPMINMAXINFO(lParam)->ptMinTrackSize.y = 520; // kleinste Höhe
		return 0;
	case WM_NCHITTEST:
		LRESULT lresult;

		lresult = DefWindowProc(hDlg, WM_NCHITTEST, wParam, lParam); 
		if (lresult == HTCLIENT)
		{ 
			GetWindowRect(hDlg, &windowRect);

			int yPos;
			yPos = GET_Y_LPARAM(lParam);
			yPos = yPos - windowRect.top - GetSystemMetrics(SM_CYSIZE) - GetSystemMetrics(SM_CYBORDER);

			if (yPos <= TOP_BORDER_HEIGHT)
				lresult = HTCAPTION;
		} 
		SetWindowLong( hDlg, DWL_MSGRESULT, lresult ); 
		return (TRUE);
	}
	return FALSE ;
}