Exemple #1
0
BOOL CALLBACK main_ConnectDialogCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	char	szBuffer[128];

	switch ( Message )
	{
	case WM_CTLCOLORSTATIC:

		switch ( GetDlgCtrlID( (HWND) lParam ))
		{
		// Paint these two labels white.
		case IDC_INTROTEXT:
		case IDC_DESCTEXT:

			return (LRESULT) g_hWhiteBrush;
		// Ignore everything else.
		default:

			return NULL;
		}
		break;
	case WM_PAINT:
		{
			// Paint the top of the form white.
			PAINTSTRUCT Ps;
			RECT r;
			r.left = 0;
			r.top = 3;
			r.bottom = 55;
			r.right = 400;
			main_PaintRectangle( BeginPaint(hDlg, &Ps), &r, RGB(255, 255, 255));
		}
		break;
	case WM_INITDIALOG:

		{
			g_hDlg = hDlg;

			// Load the icon.
			SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) (HICON) LoadImage( g_hInst,	MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED ));
			SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)LoadIcon( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON )));

			//==============================
			// Create the notification icon.
			//==============================

			ZeroMemory( &g_NotifyIconData, sizeof( g_NotifyIconData ));
			g_NotifyIconData.cbSize = sizeof( g_NotifyIconData );
			g_NotifyIconData.hWnd = hDlg;
			g_NotifyIconData.uID = 0;
			g_NotifyIconData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
			g_NotifyIconData.uCallbackMessage = UWM_TRAY_TRAYID;
			g_NotifyIconData.hIcon =  (HICON) LoadImage( g_hInst,	MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED );			
			lstrcpy( g_NotifyIconData.szTip, g_szTooltip );
			Shell_NotifyIcon( NIM_ADD, &g_NotifyIconData );

			//==================
			// Create the menus.
			//==================
		
			// Create the favorites menu.
			g_hFavoritesMenu = CreatePopupMenu( );
			int iIndex = 1;
			for( std::vector<FAVORITE_s>::iterator i = g_Favorites.begin(); i != g_Favorites.end(); ++i )			
				AppendMenu( g_hFavoritesMenu, MF_STRING, IDR_DYNAMIC_MENU + iIndex++, (LPCTSTR)(&(*i->szName)) );

			// Create the tray menu.
			g_hTrayMenu = CreatePopupMenu( );
			AppendMenu( g_hTrayMenu, MF_STRING, IDR_TOGGLE, "Show/Hide" );
			AppendMenu( g_hTrayMenu, MF_STRING|MF_POPUP, (UINT)g_hFavoritesMenu, "Favorites");
			AppendMenu( g_hTrayMenu, MF_SEPARATOR, 0, 0 );
			AppendMenu( g_hTrayMenu, MF_STRING, IDR_EXIT, "Exit" );

			// Create the file menu.
			HMENU hFileMenu = CreatePopupMenu( );
			AppendMenu( hFileMenu, MF_STRING, IDR_EXIT, "Exit" );

			// Create the file menu.
			HMENU hHelpMenu = CreatePopupMenu( );
			AppendMenu( hHelpMenu, MF_STRING, IDR_ABOUT, "About..." );

			// Create the main menu.
			g_hMainMenu = CreateMenu( );
			AppendMenu( g_hMainMenu, MF_STRING|MF_POPUP, (UINT)hFileMenu, "File" );
			AppendMenu( g_hMainMenu, MF_STRING|MF_POPUP, (UINT)g_hFavoritesMenu, "Favorites");
			AppendMenu( g_hMainMenu, MF_STRING|MF_POPUP, (UINT)hHelpMenu, "Help");
			AppendMenu( g_hMainMenu, MF_SEPARATOR, 0, 0 );
			SetMenu( hDlg, g_hMainMenu );

			// Set up the status bar.
			g_hDlgStatusBar = CreateStatusWindow( WS_CHILD | WS_VISIBLE, (LPCTSTR)NULL, hDlg, IDC_STATIC );

			// Set up the top, white section.
			SendMessage( GetDlgItem( g_hDlg, IDC_INTROTEXT ), WM_SETFONT, (WPARAM) CreateFont( 13, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1 );
			LOGBRUSH LogBrush;
			LogBrush.lbStyle = BS_SOLID;
			LogBrush.lbColor = RGB( 255, 255, 255 );
			g_hWhiteBrush = CreateBrushIndirect( &LogBrush );

			// Load the server address that was used last time.
			if ( g_Config.HaveSections( ) && g_Config.SetSection( "Settings", true ) && g_Config.GetValueForKey( "LastServer" ) )
				SetDlgItemText( hDlg, IDC_SERVERIP, g_Config.GetValueForKey( "LastServer" ) );

		}
		break;
	case WM_COMMAND:

			// Selecting a favorite from the menu?
			if ( LOWORD( wParam ) > IDR_DYNAMIC_MENU && LOWORD( wParam ) <= IDR_DYNAMIC_MENU + g_Favorites.size( ))
			{
				main_ConnectToFavorite( LOWORD( wParam ) - IDR_DYNAMIC_MENU - 1 );
				return TRUE;
			}

			switch ( LOWORD( wParam ))
			{
			// This also occurs when esc is pressed.
			case IDCANCEL:

				if ( g_State == STATE_CONNECTING )
				{
					main_SetState( STATE_WAITING );
					main_EnableConnectionButtons( TRUE );
					main_UpdateStatusbar( "Cancelled." );
				}
				else
					main_Quit( );
				break;
			// The "connect" button.
			case IDOK:	

				// Disable all the inputs.
				main_EnableConnectionButtons( FALSE );

				// Read in what the user gave us.
				GetDlgItemText( hDlg, IDC_SERVERIP, szBuffer, 128 );
				NETWORK_StringToAddress( szBuffer,  &g_ServerAddress );
				GetDlgItemText( hDlg, IDC_PASSWORD, g_szPassword, 128 );

				// If the user didn't specify a port, use the default one.
				if ( g_ServerAddress.usPort == 0 )
					NETWORK_SetAddressPort( g_ServerAddress, DEFAULT_SERVER_PORT );

				// Do some quick error checking.
				if ( !strlen( szBuffer ))
					MessageBox( hDlg, "You should probably enter a server address.", "Input error.", MB_ICONEXCLAMATION );
				else if ( strlen( g_szPassword ) < 4 )
					MessageBox( hDlg, "RCON passwords must be at least four characters long.", "Input error.", MB_ICONEXCLAMATION );
				else
				{
					main_AttemptConnection( );
					break;
				}

				// Re-enable the form so the user can try again.
				main_EnableConnectionButtons( TRUE );
				break;
			case IDR_EXIT:
				
				main_Quit( );
				break;
			case IDR_ABOUT:

				DialogBox( g_hInst, MAKEINTRESOURCE( IDD_ABOUTDIALOG ), hDlg, main_AboutDialogCallback );
				break;
			}
			break;
	case WM_SYSCOMMAND:

		// Hide the window when minimized.
		if ( wParam == SC_MINIMIZE )
			ShowWindow( hDlg, SW_HIDE );
		else
			DefWindowProc( hDlg, Message, wParam, lParam );
		break;
	case WM_CLOSE:

		main_Quit( );
		break;
	case WM_DESTROY:

		Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData );
		PostQuitMessage( 0 );
		break;
	case UWM_TRAY_TRAYID:

		return main_TrayIconClicked( hDlg, lParam );		
	default:

		return FALSE;
	}

	return TRUE;
}
Exemple #2
0
LONG NotifyHandle(HIMC hUICurIMC, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	LONG lRet = 0L;
	LPINPUTCONTEXT lpIMC;
	HGLOBAL hUIExtra;
	LPUIEXTRA lpUIExtra;

	if (!(lpIMC = ImmLockIMC(hUICurIMC)))
	{
		return 0L;
	}

	hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE);
	lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);

	switch (wParam)
	{
	case IMN_CLOSESTATUSWINDOW:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_CLOSESTATUSWINDOW\n"));
		if (IsWindow(lpUIExtra->uiStatus.hWnd)) 
		{
			ShowWindow(lpUIExtra->uiStatus.hWnd, SW_HIDE);
		}
		break;

	case IMN_OPENSTATUSWINDOW:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_OPENSTATUSWINDOW\n"));
		CreateStatusWindow( hWnd, lpUIExtra);
		break;

	case IMN_OPENCANDIDATE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_OPENCANDIDATE\n"));
		break;

	case IMN_CHANGECANDIDATE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_CHANGECANDIDATE\n"));
		break;

	case IMN_CLOSECANDIDATE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_CLOSECANDIDATE\n"));
		break;

	case IMN_SETCONVERSIONMODE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETCONVERSIONMODE\n"));
		UpdateStatusWindow(lpUIExtra);
		break;

	case IMN_SETSENTENCEMODE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETSENTENCEMODE\n"));
		break;

	case IMN_SETOPENSTATUS:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETOPENSTATUS\n"));
		if(!IsIMEOpen(hUICurIMC))
		{
			MakeResultString(hUICurIMC,FALSE);
		}
		UpdateStatusWindow(lpUIExtra);
		break;

	case IMN_SETCANDIDATEPOS:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETCANDIDATEPOS\n"));
		break;

	case IMN_SETCOMPOSITIONFONT:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETCOMPOSITIONFONT\n"));
		break;

	case IMN_SETCOMPOSITIONWINDOW:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETCOMPOSITIONWINDOW\n"));
		if(wConversionSet & CONVERSION_SET_FOLLOW)
		{
			POINT ptSrc;
			SIZE szOffset;
			HDC hDC;
			HFONT oldFont;

			ptSrc = lpIMC->cfCompForm.ptCurrentPos;
			TRACE(TEXT("%d %d\n"), ptSrc.x, ptSrc.y);
			ClientToScreen(lpIMC->hWnd, &ptSrc);
			hDC = GetDC(lpIMC->hWnd);
			oldFont = (HFONT)SelectObject(hDC, hUIFont);
			GetTextExtentPoint(hDC,"A",1,&szOffset);
			SelectObject(hDC, oldFont);
			ReleaseDC(lpIMC->hWnd,hDC);

			lpUIExtra->uiComp.pt.x = ptSrc.x + szOffset.cx;
			lpUIExtra->uiComp.pt.y = ptSrc.y + szOffset.cy;
		}
		if (IsWindow(lpUIExtra->uiComp.hWnd))
		{
			InvalidateRect(lpUIExtra->uiComp.hWnd,NULL,FALSE);
		}

		break;

	case IMN_GUIDELINE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_GUIDELINE\n"));
		break;

	case IMN_SETSTATUSWINDOWPOS:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_SETSTATUSWINDOWPOS\n"));
		break;

	case IMN_PRIVATE:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY:IMN_PRIVATE\n"));
		break;

	default:
		break;
	}
	GlobalUnlock(hUIExtra);
	ImmUnlockIMC(hUICurIMC);

	return lRet;
}
Exemple #3
0
BOOL CALLBACK main_RCONDialogCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	char	szBuffer[128];

	switch ( Message )
	{
	case WM_CTLCOLORSTATIC:

		switch ( GetDlgCtrlID( (HWND) lParam ))
		{
		// Paint these two labels (and the disconnct button's background) white.
		case IDCANCEL:
		case IDC_STATUS:
		case IDC_SERVERSUBINFO:

			return (LRESULT) g_hWhiteBrush;
		// Ignore everything else.
		default:

			return NULL;
		}
		break;
	case WM_PAINT:
		{
			// Paint the top of the form white.
			PAINTSTRUCT Ps;
			RECT r;
			r.left = 0;
			r.top = 0;
			r.bottom = 48;
			r.right = 800;
			main_PaintRectangle( BeginPaint(hDlg, &Ps), &r, RGB(255, 255, 255));
		}
		break;
	case WM_INITDIALOG:
		
		// Hide the old dialog, and take its place.
		ShowWindow( g_hDlg, SW_HIDE );
		g_hDlg = hDlg;		

		SendDlgItemMessage( hDlg, IDC_CONSOLEBOX, EM_SETLIMITTEXT, 4096, 0 );
		SendDlgItemMessage( hDlg, IDC_INPUTBOX, EM_SETLIMITTEXT, 256, 0 );
		SetWindowText( hDlg, g_szHostname );
		main_SetState( STATE_CONNECTED );
		Printf( "\nMap: %s\n", g_szMapname );

		// Fill the console with the received history.
		sprintf( szBuffer, "Connected to \"%s\".", g_szHostname );
		SetDlgItemText( hDlg, IDC_CONSOLEBOX, szBuffer );
		SetDlgItemText( hDlg, IDC_STATUS, szBuffer );
		main_UpdateTrayTooltip( szBuffer );
		Printf_NoTimestamp( "\n" );
		for( std::list<FString>::iterator i = g_RecentConsoleHistory.begin(); i != g_RecentConsoleHistory.end(); ++i )
			Printf_NoTimestamp( "%s", *i );
		g_RecentConsoleHistory.clear();

		// Set up the top, white section.
		SendMessage( GetDlgItem( g_hDlg, IDC_STATUS ), WM_SETFONT, (WPARAM) CreateFont( 13, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1 );
		LOGBRUSH LogBrush;
		LogBrush.lbStyle = BS_SOLID;
		LogBrush.lbColor = RGB( 255, 255, 255 );
		g_hWhiteBrush = CreateBrushIndirect( &LogBrush );
		main_UpdateServerStatus( );

		// Set up the player list
		LVCOLUMN	ColumnData;
		ColumnData.mask = LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;
		ColumnData.fmt = LVCFMT_LEFT;
		ColumnData.cx = 192;
		ColumnData.pszText = "Name";
		ColumnData.cchTextMax = 64;
		ColumnData.iSubItem = 0;
		SendDlgItemMessage( hDlg, IDC_PLAYERLIST, LVM_INSERTCOLUMN, COLUMN_NAME, (LPARAM)&ColumnData );

		// Add the cached list of players.
		LVITEM		Item;
		Item.mask = LVIF_TEXT;
		Item.iSubItem = COLUMN_NAME;
		Item.iItem = MAXPLAYERS;
		while ( g_InitialPlayers.size( ) )
		{
			Item.pszText = (LPSTR) g_InitialPlayers.front( ).GetChars( );
			g_InitialPlayers.pop_front( );
			SendDlgItemMessage( g_hDlg, IDC_PLAYERLIST, LVM_INSERTITEM, 0, (LPARAM)&Item ) ;
		}

		// Load the icon.
		SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) (HICON) LoadImage( g_hInst,	MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED ));
		SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)LoadIcon( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON )));

		// Set up the status bar.
		g_hDlgStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE, (LPCTSTR)NULL, hDlg, IDC_STATIC);

		g_bRCONDialogVisible = true;
		break;
	case WM_COMMAND:

			switch ( LOWORD( wParam ))
			{

			// This also occurs when esc is pressed.
			case IDCANCEL:

				main_Quit( );
				break;

			// "Send" button.
			case IDC_SEND:
			
				char	szCommand[256];

				GetDlgItemText( hDlg, IDC_INPUTBOX, szCommand, sizeof( szCommand ));
				NETWORK_ClearBuffer( &g_MessageBuffer );
				NETWORK_WriteByte( &g_MessageBuffer.ByteStream, CLRC_COMMAND );

				if ( szCommand[0] == ':' ) // If the text in the send buffer begins with a :, the admin is just talking.
				{
					char	szBuffer2[256 + 4];

					sprintf( szBuffer2, "say %s", szCommand + 1 );
					NETWORK_WriteString( &g_MessageBuffer.ByteStream, szBuffer2 );
					break;
				}
				else if ( szCommand[0] == '/' ) // If the text in the send buffer begins with a slash, error out -- Skulltag used to require you to do this to send commands.
				{
					Printf( "You longer have to prefix commands with a / to send them.\n" );
					SetDlgItemText( hDlg, IDC_INPUTBOX, szCommand + 1 );
					SendMessage( GetDlgItem( hDlg, IDC_INPUTBOX ), EM_SETSEL, strlen( szCommand ) - 1, strlen( szCommand ) - 1 );
					break;
				}
				else
					NETWORK_WriteString( &g_MessageBuffer.ByteStream, szCommand );				
				
				NETWORK_LaunchPacket( &g_MessageBuffer, g_ServerAddress );
				time( &g_tLastSentCommand );
				SetDlgItemText( hDlg, IDC_INPUTBOX, "" );
				break;
			}
			break;
	case WM_SYSCOMMAND:

		// Hide the window when minimized.
		if ( wParam == SC_MINIMIZE )
			ShowWindow( hDlg, SW_HIDE );
		else
			DefWindowProc( hDlg, Message, wParam, lParam );
		break;
	case WM_CLOSE:

		main_Quit( );
		break;
	case WM_DESTROY:

		Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData );
		PostQuitMessage( 0 );
		break;
	case UWM_TRAY_TRAYID:

		return main_TrayIconClicked( hDlg, lParam );	
	default:

		return FALSE;
	}

	return TRUE; // If this is false, minimizing the window won't hide it.
}
Exemple #4
0
//-----------------------------------------------------------------------------
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static int nWidth, nHeight, nStatusHeight;

    switch(iMsg)
    {
        case WM_CREATE:
        {
            int parts[] = { 150, -1 };
            RECT rcStatus;

            hwndStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, _T("Ready"), hwnd, 0);

            //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);

            SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
            SendMessage(hwndStatus, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)"");

            SolWnd.Create(hwnd, WS_EX_CLIENTEDGE, WS_CHILD|WS_VISIBLE, 0, 0, 0, 0);

            CreateSol();

            // The status bar height is fixed and needed later in WM_SIZE and WM_GETMINMAXINFO
            // Force the window to process WM_GETMINMAXINFO again
            GetWindowRect(hwndStatus, &rcStatus);
            nStatusHeight = rcStatus.bottom - rcStatus.top;

            // Hide status bar if options say so
            if (!(dwOptions & OPTION_SHOW_STATUS))
            {
                ShowWindow(hwndStatus, SW_HIDE);
            }

            SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER);

            NewGame();

            dwAppStartTime = GetTickCount();

            return 0;
        }

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        case WM_TIMER:
            if (!fGameStarted)
            {
                KillTimer(hwndMain, IDT_PLAYTIMER);
                PlayTimer = 0;
            }
            else if (dwOptions & OPTION_SHOW_TIME)
            {
                if (((dwTime + 1) % 10 == 0) && (GetScoreMode() == SCORE_STD))
                {
                    lScore = lScore >= 2 ? lScore - 2 : 0;
                }

                dwTime++;
            }

            UpdateStatusBar();
            return 0;

        case WM_SIZE:
            nWidth  = LOWORD(lParam);
            nHeight = HIWORD(lParam);

            if (dwOptions & OPTION_SHOW_STATUS)
            {
                MoveWindow(SolWnd, 0, 0, nWidth, nHeight - nStatusHeight, TRUE);
                MoveWindow(hwndStatus, 0, nHeight - nStatusHeight, nWidth, nStatusHeight, TRUE);
            }
            else
            {
                MoveWindow(SolWnd, 0, 0, nWidth, nHeight, TRUE);
            }
            //parts[0] = nWidth - 256;
            //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
            return 0;

        case WM_GETMINMAXINFO:
        {
            MINMAXINFO *mmi;

            mmi = (MINMAXINFO *)lParam;
            mmi->ptMinTrackSize.x = X_BORDER + NUM_ROW_STACKS * (__cardwidth + X_ROWSTACK_BORDER) + X_BORDER;
            mmi->ptMinTrackSize.y = GetSystemMetrics(SM_CYCAPTION) +
                                    GetSystemMetrics(SM_CYMENU) +
                                    Y_BORDER +
                                    __cardheight +
                                    Y_ROWSTACK_BORDER +
                                    6 * yRowStackCardOffset +
                                    __cardheight +
                                    Y_BORDER +
                                    (dwOptions & OPTION_SHOW_STATUS ? nStatusHeight : 0);
            return 0;
        }

        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
            case IDM_GAME_NEW:
                //simulate a button click on the new button..
                NewGame();
                return 0;

            case IDM_GAME_DECK:
                ShowDeckOptionsDlg(hwnd);
                return 0;

            case IDM_GAME_OPTIONS:
                ShowGameOptionsDlg(hwnd);
                return 0;

            case IDM_HELP_CONTENTS:
                WinHelp(hwnd, szHelpPath, HELP_CONTENTS, 0);//HELP_KEY, (DWORD)"How to play");
                return 0;

            case IDM_HELP_ABOUT:
                MessageBox(hwnd, MsgAbout, szAppName, MB_OK|MB_ICONINFORMATION);
                return 0;

            case IDM_GAME_EXIT:
                PostMessage(hwnd, WM_CLOSE, 0, 0);
                return 0;
            }

            return 0;

        case WM_CLOSE:
            if (fGameStarted == false)
            {
                DestroyWindow(hwnd);
                return 0;
            }
            else
            {
                int ret;

                ret = MessageBox(hwnd, MsgQuit, szAppName, MB_YESNO|MB_ICONQUESTION);
                if (ret == IDYES)
                {
                    WinHelp(hwnd, szHelpPath, HELP_QUIT, 0);
                    DestroyWindow(hwnd);
                }
            }
            return 0;
    }

    return DefWindowProc (hwnd, iMsg, wParam, lParam);
}
Exemple #5
0
void CMainFrame::OnCreate(WPARAM wParam, LPARAM lParam)
{
  // Create MDI client window
  CLIENTCREATESTRUCT ccs;
  ccs.hWindowMenu = GetSubMenu(GetMenu(m_hWnd), 5);
  ccs.idFirstChild = 3;

  m_hClient = CreateWindow("MDICLIENT", NULL, WS_CHILD | WS_VISIBLE |
      WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL,
      0, 0, 0, 0, m_hWnd, (HMENU)IDR_CLIENT, NULL, &ccs); 

  // Create status bar
  m_hStatus = CreateStatusWindow(WS_VISIBLE | WS_CHILD | SBARS_SIZEGRIP,
      "Stopped", m_hWnd, IDR_STATUS);

  // Create rebar
  m_hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL,
      WS_CHILD | WS_VISIBLE |WS_BORDER| WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
      RBS_VARHEIGHT | CCS_NODIVIDER | RBS_AUTOSIZE | RBS_VARHEIGHT |
      RBS_BANDBORDERS, 0, 0, 0, 0, m_hWnd, (HMENU)IDR_REBAR, NULL,
      NULL);

  // Initialize rebar
  REBARINFO rbi;
  rbi.cbSize = sizeof(REBARINFO);
  ZeroMemory(&rbi, sizeof(REBARINFO));
  SendMessage(m_hRebar, RB_SETBARINFO, 0, (LPARAM)&rbi);

  // Load toolbar from resource
  m_hToolbar = LoadToolbar(NULL, TBSTYLE_FLAT | TBSTYLE_WRAPABLE |
      CCS_NODIVIDER |CCS_NOPARENTALIGN | CCS_NORESIZE , IDR_TOOLBAR, m_hRebar);
  
  // Insert toolbar into rebar
  SIZE size;
  REBARBANDINFO rbbi;
  SendMessage(m_hToolbar, TB_GETMAXSIZE, 0, (LPARAM)&size);
  ZeroMemory(&rbbi, sizeof(REBARBANDINFO));
  rbbi.cbSize     = sizeof(REBARBANDINFO);
  rbbi.fMask      = RBBIM_CHILD| RBBIM_CHILDSIZE | RBBIM_STYLE;
  rbbi.fStyle     = RBBS_GRIPPERALWAYS; 
  rbbi.hwndChild  = m_hToolbar;
  rbbi.cxMinChild = size.cx;
  rbbi.cyMinChild = size.cy;
  SendMessage(m_hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbbi);

  // TODO: Load and set window icon
  m_hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_APP));
  SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)m_hIcon);
  SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)m_hIcon);

  // Open command argument file if exists and valid
  if (__argc == 2)
  {
    // Create default model window
    m_pMainWnd = new CModelView(this, new CModelDoc);

    // Assign file name
    m_sFileName = __argv[1];

    // Open target file
    fstream file;
    file.open(__argv[1], ios::in|ios::binary);

    // Load data from file
    if (m_pMainWnd->m_pDocument->Load(&file) == FALSE)
    {
      // If error, clean file name
      m_sFileName.clear();

      // Create the window
      m_pMainWnd->Create("Root Document", m_hClient);

      // Release error data
      m_pMainWnd->OnDestroy(0, 0);
      m_pMainWnd = NULL;
    }
    else
    {
      // Create the window
      m_pMainWnd->Create("Root Document", m_hClient);

      // Compile blocks
      m_pMainWnd->m_pDocument->Compile();

      // Update document
      m_pMainWnd->m_pDocument->Update();
      m_pMainWnd->m_pDocument->Check();

      // Update window
      InvalidateRect(m_pMainWnd->m_hWnd, NULL, TRUE);
    }

    // End of file operating
    file.close();
  }
}
Exemple #6
0
void InterfaceSetup()
{
	HWND hwndTB; 
	TBADDBITMAP tbab; 
	TBBUTTON tbb[8];
	
	RECT rcClient;
	int status_widths[2];
	
	hwndTB = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,WS_CHILD | TBSTYLE_TOOLTIPS,
		0,0,0,0,hwndMain,(HMENU) IDC_TOOLBAR,hInst, NULL); 
	
	
	
	SendMessage(hwndTB,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0); 
	/*
	tbab.hInst = hInst;
	tbab.nID   = IDB_TOOLBAR;
	*/
	tbab.hInst = HINST_COMMCTRL;
	tbab.nID   = IDB_STD_SMALL_COLOR;
	
	SendMessage(hwndTB, TB_ADDBITMAP,15,(LPARAM)&tbab); 
	
	/* buttons to the toolbar */
	tbb[0].iBitmap = STD_DELETE; 
	tbb[0].idCommand = IDM_FILE_EXIT; 
	tbb[0].fsState = 0; 
	tbb[0].fsStyle = TBSTYLE_BUTTON; 
	tbb[0].dwData = 0; 
	tbb[0].iString = 0;
	
	tbb[1].iBitmap = STD_FILESAVE; 
	tbb[1].idCommand = IDM_FILE_SAVE; 
	tbb[1].fsState = 0; 
	tbb[1].fsStyle = TBSTYLE_BUTTON; 
	tbb[1].dwData = 0; 
	tbb[1].iString = 0;
	
	tbb[2].iBitmap = STD_UNDO; 
	tbb[2].idCommand = IDM_FILE_RELOADSYSTEM; 
	tbb[2].fsState = 0; 
	tbb[2].fsStyle = TBSTYLE_BUTTON; 
	tbb[2].dwData = 0; 
	tbb[2].iString = 0;
	
	tbb[3].iBitmap = 0;
	tbb[3].idCommand = 0;
	tbb[3].fsState = 0; 
	tbb[3].fsStyle = TBSTYLE_SEP; 
	tbb[3].dwData = 0; 
	tbb[3].iString = 0;
	
	tbb[4].iBitmap = STD_PROPERTIES; 
	tbb[4].idCommand = IDM_MESSAGES_MESSAGEOFTHEDAY;
	tbb[4].fsState = 0; 
	tbb[4].fsStyle = TBSTYLE_BUTTON; 
	tbb[4].dwData = 0; 
	tbb[4].iString = 0;
	
	tbb[5].iBitmap = 0;
	tbb[5].idCommand = 0;
	tbb[5].fsState = 0; 
	tbb[5].fsStyle = TBSTYLE_SEP; 
	tbb[5].dwData = 0; 
	tbb[5].iString = 0;
	
	tbb[6].iBitmap = STD_FIND;
	tbb[6].idCommand = IDM_HELP_ABOUT;
	tbb[6].fsState = TBSTATE_ENABLED; 
	tbb[6].fsStyle = TBSTYLE_BUTTON; 
	tbb[6].dwData = 0; 
	tbb[6].iString = 0;
	
	SendMessage(hwndTB,TB_ADDBUTTONS,7,(LPARAM)&tbb); 
	
	ShowWindow(hwndTB,SW_SHOW);
	
	CreateStatusWindow(WS_CHILD | WS_VISIBLE,"",hwndMain,IDS_STATUS_WINDOW);
	GetClientRect(hwndMain,&rcClient); 
	status_widths[0] = rcClient.right - STATUS_CONNECTION_WIDTH;
	status_widths[1] = rcClient.right - 1;
	
	SendDlgItemMessage(hwndMain,IDS_STATUS_WINDOW,SB_SETPARTS,2,(LPARAM)status_widths);
	SendDlgItemMessage(hwndMain,IDS_STATUS_WINDOW,SB_SETTEXT,1,(LPARAM)"  0");
	
	
}
CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent)
{
	cpu = _cpu;
	lastTicks = CoreTiming::GetTicks();
	keepStatusBarText = false;

	SetWindowText(m_hDlg, ConvertUTF8ToWString(_cpu->GetName()).c_str());
#ifdef THEMES
	//if (WTL::CTheme::IsThemingSupported())
		//EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB);
#endif
	int x = g_Config.iDisasmWindowX == -1 ? 500 : g_Config.iDisasmWindowX;
	int y = g_Config.iDisasmWindowY == -1 ? 200 : g_Config.iDisasmWindowY;
	int w = g_Config.iDisasmWindowW;
	int h = g_Config.iDisasmWindowH;
	// Start with the initial size so we have the right minimum size from the rc.
	SetWindowPos(m_hDlg, 0, x, y, 0, 0, SWP_NOSIZE);

	CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW));
	ptr->setDebugger(cpu);
	ptr->gotoAddr(0x00000000);

	CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST));
	rl->setCPU(cpu);

	GetWindowRect(m_hDlg, &defaultRect);

	//symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);
	symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);

	GetWindowRect(GetDlgItem(m_hDlg, IDC_REGLIST), &regRect);
	GetWindowRect(GetDlgItem(m_hDlg, IDC_DISASMVIEW), &disRect);
	GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), &breakpointRect);
	GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), &defaultBreakpointRect);

	HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS);

	TCITEM tcItem;
	ZeroMemory (&tcItem,sizeof (tcItem));
	tcItem.mask			= TCIF_TEXT;
	tcItem.dwState		= 0;
	tcItem.pszText		= L"Regs";
	tcItem.cchTextMax	= (int)wcslen(tcItem.pszText)+1;
	tcItem.iImage		= 0;
	int result1 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem);
	tcItem.pszText		= L"Funcs";
	tcItem.cchTextMax	= (int)wcslen(tcItem.pszText)+1;
	int result2 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem);
	ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), SW_NORMAL);
	ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), SW_HIDE);
	SetTimer(m_hDlg,1,1000,0);
	
	// subclass the goto edit box
	HWND editWnd = GetDlgItem(m_hDlg,IDC_ADDRESS);
	DefGotoEditProc = (WNDPROC)GetWindowLongPtr(editWnd,GWLP_WNDPROC);
	SetWindowLongPtr(editWnd,GWLP_WNDPROC,(LONG_PTR)GotoEditProc); 
	
	// init memory viewer
	CtrlMemView *mem = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW));
	mem->setDebugger(_cpu);
	
	breakpointList = new CtrlBreakpointList(GetDlgItem(m_hDlg,IDC_BREAKPOINTLIST));
	breakpointList->setCpu(cpu);
	breakpointList->setDisasm(ptr);
	breakpointList->reloadBreakpoints();

	threadList = new CtrlThreadList(GetDlgItem(m_hDlg,IDC_THREADLIST));
	threadList->reloadThreads();

	stackTraceView = new CtrlStackTraceView(GetDlgItem(m_hDlg,IDC_STACKFRAMES));
	stackTraceView->setCpu(cpu);
	stackTraceView->setDisasm(ptr);
	stackTraceView->loadStackTrace();
	
	// init bottom "tab"
	changeSubWindow(SUBWIN_FIRST);

	// init status bar
	statusBarWnd = CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"", m_hDlg, IDC_DISASMSTATUSBAR);
	if (g_Config.bDisplayStatusBar == false)
	{
		ShowWindow(statusBarWnd,SW_HIDE);
	}

	// Actually resize the window to the proper size (after the above setup.)
	if (w != -1 && h != -1)
	{
		// this will also call UpdateSize
		SetWindowPos(m_hDlg, 0, x, y, w, h, 0);
	}

	SetDebugMode(true, true);
}
void CMainGui::CreateStatusBar (void)
{
	m_hStatusWnd = (HWND)CreateStatusWindow( WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID );
	SendMessage( (HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)"" );
}
HWND CreateStatusBar(HWND hParent, UINT nID)
{
    return CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"", hParent, nID);
}
Exemple #10
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    WNDCLASSEX wcFrame = {
        sizeof(WNDCLASSEX),
        CS_HREDRAW | CS_VREDRAW/*style*/,
        FrameWndProc,
        0/*cbClsExtra*/,
        0/*cbWndExtra*/,
        hInstance,
        LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)),
        LoadCursor(0, IDC_ARROW),
        0/*hbrBackground*/,
        0/*lpszMenuName*/,
        szFrameClass,
        (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_MDI_APP), IMAGE_ICON,
            GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
    };
    ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class
#if 0
    WNDCLASS wcChild = {
        CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW,
        ChildWndProc,
        0/*cbClsExtra*/,
        0/*cbWndExtra*/,
        hInstance,
        0/*hIcon*/,
        LoadCursor(0, IDC_ARROW),
        0/*hbrBackground*/,
        0/*lpszMenuName*/,
        szChildClass
    };
    ATOM hChildWndClass = RegisterClass(&wcChild); // register child windows class
#else
    // WNDCLASSEX wcChild = {
    //     sizeof(WNDCLASSEX),
    //     CS_HREDRAW | CS_VREDRAW/*style*/,
    //     ChildWndProc,
    //     0/*cbClsExtra*/,
    //     sizeof(HANDLE)/*cbWndExtra*/,
    //     hInstance,
    //     LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)),
    //     LoadCursor(0, IDC_ARROW),
    //     0/*hbrBackground*/,
    //     0/*lpszMenuName*/,
    //     szChildClass,
    //     (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDC_MDI_APP), IMAGE_ICON,
    //         GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
    // };
    // ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class
#endif

    HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP));
    HMENU hMenuOptions = GetSubMenu(hMenu, ID_OPTIONS_MENU);
    // HMENU hChildMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP_CHILD));

    INITCOMMONCONTROLSEX icc = {
        sizeof(INITCOMMONCONTROLSEX),
        ICC_BAR_CLASSES
    };

    HDC hdc = GetDC(0);

    hMenuFrame = hMenu;
//  hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
    hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MDI_APP));
    hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif"));
    ReleaseDC(0, hdc);

    hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
//  hFrameWnd = CreateWindow(szFrameClass, szTitle,
                    WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                    NULL/*hWndParent*/, hMenuFrame, hInstance, NULL/*lpParam*/);
    if (!hFrameWnd) {
        return FALSE;
    }

    if (InitCommonControlsEx(&icc))
    {
        int nParts[3];
        TBBUTTON toolbarBtns[] = {
            {0, 0, 0, TBSTYLE_SEP},
            {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},
            {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
            {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON},
            {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
            {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},
            {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},
        };

        hToolBar = CreateToolbarEx(hFrameWnd, WS_CHILD|WS_VISIBLE,
            IDC_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns,
            sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON));
        CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED);

        // Create the status bar
        hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
                                        "", hFrameWnd, IDC_STATUSBAR);
        if (!hStatusBar)
            return FALSE;
        CheckMenuItem(hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);

        // Create the status bar panes
        nParts[0] = 100;
        nParts[1] = 210;
        nParts[2] = 400;
        SendMessage(hStatusBar, SB_SETPARTS, 3, (long)nParts);
    } else {
        CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_GRAYED);
        CheckMenuItem(hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_GRAYED);
	}

    ShowWindow(hFrameWnd, nCmdShow);
    UpdateWindow(hFrameWnd);
    UpdateStatusBar();
    return TRUE;
}