Example #1
0
static NTSTATUS PhpRefreshThreadStackThreadStart(
    _In_ PVOID Parameter
    )
{
    PH_AUTO_POOL autoPool;
    NTSTATUS status;
    PTHREAD_STACK_CONTEXT threadStackContext = Parameter;
    CLIENT_ID clientId;
    BOOLEAN defaultWalk;

    PhInitializeAutoPool(&autoPool);

    PhLoadSymbolsThreadProvider(threadStackContext->ThreadProvider);

    clientId.UniqueProcess = threadStackContext->ProcessId;
    clientId.UniqueThread = threadStackContext->ThreadId;
    defaultWalk = TRUE;

    if (threadStackContext->CustomWalk)
    {
        PH_PLUGIN_THREAD_STACK_CONTROL control;

        control.Type = PluginThreadStackWalkStack;
        control.UniqueKey = threadStackContext;
        control.u.WalkStack.Status = STATUS_UNSUCCESSFUL;
        control.u.WalkStack.ThreadHandle = threadStackContext->ThreadHandle;
        control.u.WalkStack.ProcessHandle = threadStackContext->SymbolProvider->ProcessHandle;
        control.u.WalkStack.ClientId = &clientId;
        control.u.WalkStack.Flags = PH_WALK_I386_STACK | PH_WALK_AMD64_STACK | PH_WALK_KERNEL_STACK;
        control.u.WalkStack.Callback = PhpWalkThreadStackCallback;
        control.u.WalkStack.CallbackContext = threadStackContext;
        PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackThreadStackControl), &control);
        status = control.u.WalkStack.Status;

        if (NT_SUCCESS(status))
            defaultWalk = FALSE;
    }

    if (defaultWalk)
    {
        PH_PLUGIN_THREAD_STACK_CONTROL control;

        control.UniqueKey = threadStackContext;

        if (PhPluginsEnabled)
        {
            control.Type = PluginThreadStackBeginDefaultWalkStack;
            PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackThreadStackControl), &control);
        }

        status = PhWalkThreadStack(
            threadStackContext->ThreadHandle,
            threadStackContext->SymbolProvider->ProcessHandle,
            &clientId,
            threadStackContext->SymbolProvider,
            PH_WALK_I386_STACK | PH_WALK_AMD64_STACK | PH_WALK_KERNEL_STACK,
            PhpWalkThreadStackCallback,
            threadStackContext
            );

        if (PhPluginsEnabled)
        {
            control.Type = PluginThreadStackEndDefaultWalkStack;
            PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackThreadStackControl), &control);
        }
    }

    if (threadStackContext->NewList->Count != 0)
        status = STATUS_SUCCESS;

    threadStackContext->WalkStatus = status;
    PostMessage(threadStackContext->ProgressWindowHandle, WM_PH_COMPLETED, 0, 0);

    PhDeleteAutoPool(&autoPool);

    return STATUS_SUCCESS;
}
Example #2
0
void FireCommandDelay(LPCSTR Command)
{
    strcpy(CommandDelayBuffer, Command);
    PostMessage(hThisWindow, WM_APP, 0, 0);
}
Example #3
0
//-----------------------------------------------------------------------------
// Name: OnInitDialog()
// Desc: Initializes the dialogs (sets up UI controls, etc.)
//-----------------------------------------------------------------------------
VOID OnInitDialog( HWND hDlg )
{
    HRESULT hr;

    // Load the icon
#ifdef _WIN64
    HINSTANCE hInst = (HINSTANCE) GetWindowLongPtr( hDlg, GWLP_HINSTANCE );
#else
    HINSTANCE hInst = (HINSTANCE) GetWindowLong( hDlg, GWL_HINSTANCE );
#endif
    HICON hIcon = LoadIcon( hInst, MAKEINTRESOURCE( IDR_MAINFRAME ) );

    // Create a static IDirectSound in the CSound class.  
    // Set coop level to DSSCL_PRIORITY, and set primary buffer 
    // format to stereo, 22kHz and 16-bit output.
    g_pSoundManager = new CSoundManager();
    if( NULL == g_pSoundManager )
    {
        DXTRACE_ERR_MSGBOX( TEXT("Initialize"), E_OUTOFMEMORY );
        EndDialog( hDlg, IDABORT );
        return;
    }

    if( FAILED( hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY ) ) )
    {
        DXTRACE_ERR_MSGBOX( TEXT("Initialize"), hr );
        MessageBox( hDlg, "Error initializing DirectSound.  Sample will now exit.", 
                            "DirectSound Sample", MB_OK | MB_ICONERROR );
        EndDialog( hDlg, IDABORT );
        return;
    }
    
    if( FAILED( hr = g_pSoundManager->SetPrimaryBufferFormat( 2, 22050, 16 ) ) )
    {
        DXTRACE_ERR_MSGBOX( TEXT("SetPrimaryBufferFormat"), hr );
        MessageBox( hDlg, "Error initializing DirectSound.  Sample will now exit.", 
                          "DirectSound Sample", MB_OK | MB_ICONERROR );
        EndDialog( hDlg, IDABORT );
        return;
    }

    // Set the icon for this dialog.
    PostMessage( hDlg, WM_SETICON, ICON_BIG,   (LPARAM) hIcon );  // Set big icon
    PostMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon );  // Set small icon

    // Create a timer, so we can check for when the soundbuffer is stopped
    SetTimer( hDlg, 0, 250, NULL );

    // Get handles to dialog items
    HWND hFreqSlider    = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
    HWND hPanSlider     = GetDlgItem( hDlg, IDC_PAN_SLIDER );
    HWND hVolumeSlider  = GetDlgItem( hDlg, IDC_VOLUME_SLIDER );

    // Set the focus to normal by default
    CheckRadioButton( hDlg, IDC_FOCUS_NORMAL, IDC_FOCUS_NORMAL, IDC_FOCUS_NORMAL );

    // Set the buffer mixing to default 
    CheckRadioButton( hDlg, IDC_MIX_DEFAULT, IDC_MIX_SOFTWARE, IDC_MIX_DEFAULT );

    // Set the range and position of the freq slider from 
    // DSBFREQUENCY_MIN and DSBFREQUENCY_MAX are DirectSound constants
    PostMessage( hFreqSlider, TBM_SETRANGEMAX, TRUE, DSBFREQUENCY_MAX );
    PostMessage( hFreqSlider, TBM_SETRANGEMIN, TRUE, DSBFREQUENCY_MIN );

    // Set the range and position of the pan slider from 
    PostMessage( hPanSlider, TBM_SETRANGEMAX, TRUE, ( 10000L/500L) );
    PostMessage( hPanSlider, TBM_SETRANGEMIN, TRUE, (-10000L/500L) );

    // Set the range and position of the volume slider 
    PostMessage( hVolumeSlider, TBM_SETRANGEMAX, TRUE, 0L );
    PostMessage( hVolumeSlider, TBM_SETRANGEMIN, TRUE, (-5000L/100L) );

    // Set the position of the sliders
    SetSlidersPos( hDlg, DSBFREQUENCY_MIN, 0, 0 );

    // Set the UI controls
    SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
    SetDlgItemText( hDlg, IDC_STATUS, TEXT("No file loaded.") );
    UpdateBehaviorText( hDlg );
}
Example #4
0
LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
{
    switch (uMsg)
    {
    case WM_CREATE:
    {
        //record class for future usage
        LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
        CMainGui * _this = (CMainGui *)lpcs->lpCreateParams;
        SetProp(hWnd, "Class", _this);

        _this->m_hMainWindow = hWnd;
        _this->CreateStatusBar();

        //Move the Main window to the location last executed from or center the window
        int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2;
        int	Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2;

        g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y);
        g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X);

        _this->SetPos(X, Y);

        _this->ChangeWinSize(640, 480);
    }
    break;
    case WM_SYSCOMMAND:
        switch (wParam) {
        case SC_SCREENSAVE:
        case SC_MONITORPOWER:
        {
            CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
            if (_this &&
                    _this->bCPURunning() &&
                    !g_Settings->LoadBool(GameRunning_CPU_Paused) &&
                    g_Settings->LoadDword(Setting_DisableScrSaver))
            {
                return 0;
            }
        }
        break;
        case SC_MAXIMIZE:
        {
            CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
            if (_this)
            {
                if (_this->RomBrowserVisible())
                {
                    _this->RomBrowserMaximize(true);
                }
            }
        }
        break;
        }
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
        break;
    case WM_MOVE:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");

        if (!_this->m_bMainWindow ||
                !_this->m_Created ||
                _this->m_AttachingMenu ||
                _this->m_MakingVisible ||
                IsIconic(hWnd) ||
                _this->ShowingRomBrowser())
        {
            break;
        }

        if (IsZoomed(hWnd))
        {
            if (_this->RomBrowserVisible())
            {
                // save that browser is maximized
            }
            break;
        }

        //get the current position of the window
        RECT WinRect;
        GetWindowRect(hWnd, &WinRect);

        //save the location of the window
        if (_this->RomBrowserVisible())
        {
            _this->m_SaveRomBrowserPos = true;
            _this->m_SaveRomBrowserTop = WinRect.top;
            _this->m_SaveRomBrowserLeft = WinRect.left;
        }
        else
        {
            _this->m_SaveMainWindowPos = true;
            _this->m_SaveMainWindowTop = WinRect.top;
            _this->m_SaveMainWindowLeft = WinRect.left;
        }
        KillTimer(hWnd, Timer_SetWindowPos);
        SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL);
    }
    if (CGuiSettings::bCPURunning() && g_BaseSystem)
    {
        if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen)
        {
            WriteTrace(TraceGFXPlugin, TraceDebug, "Starting");
            g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam));
            WriteTrace(TraceGFXPlugin, TraceDebug, "Done");
        }
    }
    break;
    case WM_TIMER:
        if (wParam == Timer_SetWindowPos)
        {
            KillTimer(hWnd, Timer_SetWindowPos);
            CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
            _this->SaveWindowLoc();
            break;
        }
        break;
    case WM_SIZE:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this) {
            _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam));
        }
        if (_this)
        {
            if (wParam == SIZE_MAXIMIZED)
            {
                if (_this->RomBrowserVisible())
                {
                    _this->RomBrowserMaximize(true);
                }
            }
            _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam));
        }
        if (_this)
        {
            if (wParam == SIZE_RESTORED && _this->RomBrowserVisible())
            {
                _this->RomBrowserMaximize(false);
            }
        }
    }
    break;
    case WM_NOTIFY:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this == NULL || !_this->RomBrowserVisible() || !_this->RomListNotify(wParam, lParam))
        {
            return DefWindowProc(hWnd, uMsg, wParam, lParam);
        }
    }
    break;
    case WM_DRAWITEM:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this)
        {
            if (!_this->RomListDrawItem(wParam, lParam))
            {
                return DefWindowProc(hWnd, uMsg, wParam, lParam);
            }
        }
    }
    break;
    case WM_PAINT:
    {
        //			CMainGui * _this = (CMainGui *)GetProp(hWnd,"Class");
        //			CN64System * System  = _this->m_System;

        //			if (bCPURunning() && Settings->Load(CPU_Paused)) {
        //				CPlugins * Plugins = System->Plugins();
        //				if (Plugins->Gfx()->DrawScreen) {
        //					Plugins->Gfx()->DrawScreen();
        //				}
        //			}
        ValidateRect(hWnd, NULL);
    }
    break;
    case WM_KEYUP:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");

        if (_this->m_bMainWindow && bCPURunning())
        {
            if (g_BaseSystem)
            {
                if (g_Plugins && g_Plugins->Control()->WM_KeyUp) {
                    g_Plugins->Control()->WM_KeyUp(wParam, lParam);
                }
            }
        }
    }
    break;
    case WM_KEYDOWN:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");

        if (_this->m_bMainWindow && bCPURunning())
        {
            if (g_BaseSystem)
            {
                if (g_Plugins && g_Plugins->Control()->WM_KeyDown)
                {
                    g_Plugins->Control()->WM_KeyDown(wParam, lParam);
                }
            }
        }
    }
    break;
    case WM_SETFOCUS:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this->RomBrowserVisible())
        {
            PostMessage(hWnd, WM_BROWSER_TOP, 0, 0);
            break;
        }

        if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
        {
            if (g_BaseSystem)
            {
                g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus);
            }
        }
    }
    break;
    case WM_KILLFOCUS:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this->RomBrowserVisible())
        {
            break;
        }

        if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
        {
            if (g_BaseSystem)
            {
                g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus);
            }
        }
    }
    break;
    case WM_ACTIVATEAPP:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        DWORD fActive = (BOOL)wParam;

        if (fActive && _this->RomBrowserVisible())
        {
            PostMessage(hWnd, WM_BROWSER_TOP, 0, 0);
        }
        if (_this->m_bMainWindow && bCPURunning())
        {
            if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen))
            {
                Notify().WindowMode();
                if (bAutoSleep() && g_BaseSystem)
                {
                    //System->ExternalEvent(PauseCPU_AppLostActiveDelayed );
                }
                break;
            }
            if (bAutoSleep() || fActive)
            {
                if (g_BaseSystem)
                {
                    g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive);
                }
            }
        }
    }
    break;
    case WM_HIDE_CUROSR:
        if (!wParam)
        {
            while (ShowCursor(FALSE) >= 0) {
                Sleep(0);
            }
        }
        else
        {
            while (ShowCursor(TRUE) < 0) {
                Sleep(0);
            }
        }
        break;
    case WM_MAKE_FOCUS:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        _this->BringToTop();
    }
    break;
    case WM_BROWSER_TOP:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        _this->RomBrowserToTop();
    }
    break;
    case WM_RESET_PLUGIN:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this->m_ResetInfo != NULL)
        {
            g_Notify->BreakPoint(__FILE__, __LINE__);
        }
        _this->m_ResetInfo = (RESET_PLUGIN *)lParam;
        _this->m_ResetPlugins = true;
    }
    break;
    case WM_GAME_CLOSED:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        Notify().WindowMode();
        if (g_Settings->LoadDword(RomBrowser_Enabled))
        {
            _this->ShowRomBrowser();
        }
        _this->RefreshMenu();
        _this->MakeWindowOnTop(false);
        _this->SetStatusText(0, L"");
        _this->SetStatusText(1, L"");
    }
    break;
    case WM_COMMAND:
    {
        CMainGui * _this = (CMainGui *)GetProp(hWnd, "Class");
        if (_this == NULL) {
            break;
        }

        switch (LOWORD(wParam)) {
        case ID_POPUPMENU_PLAYGAME:
            g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
            break;
        case ID_POPUPMENU_ROMDIRECTORY:
            _this->SelectRomDir();
            break;
        case ID_POPUPMENU_REFRESHROMLIST:
            _this->RefreshRomBrowser();
            break;
        case ID_POPUPMENU_ROMINFORMATION:
        {
            RomInformation Info(_this->CurrentedSelectedRom());
            Info.DisplayInformation(hWnd);
        }
        break;
        case ID_POPUPMENU_EDITSETTINGS:
        case ID_POPUPMENU_EDITCHEATS:
        {
            CN64Rom Rom;
            Rom.LoadN64Image(_this->CurrentedSelectedRom(), true);
            Rom.SaveRomSettingID(true);

            if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
            {
                CSettingConfig SettingConfig(true);
                SettingConfig.Display(hWnd);
            }

            if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
            {
                CCheatsUI * cheatUI = new CCheatsUI;
                g_cheatUI = cheatUI;
                cheatUI->SelectCheats(hWnd, true);
                if (g_cheatUI == cheatUI)
                {
                    g_cheatUI = NULL;
                }
            }

            if (g_Rom)
            {
                g_Rom->SaveRomSettingID(false);
            }
            else
            {
                Rom.ClearRomSettingID();
            }
        }
        break;
        default:
            if (_this->m_Menu)
            {
                if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100)
                {
                    if (g_Plugins->RSP())
                    {
                        g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam));
                    }
                }
                else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200)
                {
                    if (g_Plugins->Gfx())
                    {
                        WriteTrace(TraceGFXPlugin, TraceDebug, "Starting");
                        g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam));
                        WriteTrace(TraceGFXPlugin, TraceDebug, "Done");
                    }
                }
                else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300)
                {
                    if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
                    {
                        CN64Rom Rom;
                        if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true))
                        {
                            break;
                        }
                        Rom.SaveRomSettingID(true);
                        g_Notify->DisplayMessage(0, "");
                        BYTE * RomHeader = Rom.GetRomAddress();
                        WriteTrace(TraceGFXPlugin, TraceDebug, "OnRomBrowserMenuItem - Starting");
                        g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader);
                        WriteTrace(TraceGFXPlugin, TraceDebug, "OnRomBrowserMenuItem - Done");
                        if (g_Rom)
                        {
                            g_Rom->SaveRomSettingID(false);
                        }
                        else
                        {
                            g_Settings->SaveString(Game_IniKey, "");
                        }
                    }
                }
                else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam)))
                {
                    return true;
                }
            }
        }
    }
    break;
    case WM_DROPFILES:
    {
        char filename[MAX_PATH];

        HDROP hDrop = (HDROP)wParam;
        DragQueryFile(hDrop, 0, filename, sizeof(filename));
        DragFinish(hDrop);

        CN64System::RunFileImage(filename);
    }
    break;
    case WM_DESTROY:
        WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - start");
        {
            CMainGui   * _this = (CMainGui *)GetProp(hWnd, "Class");
            if (_this->m_bMainWindow)
            {
                Notify().WindowMode();
            }
            _this->m_hMainWindow = NULL;
            WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 1");
            if (_this->m_bMainWindow)
            {
                _this->SaveRomListColoumnInfo();
                WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 2");
                _this->SaveWindowLoc();
            }
        }
        WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 3");
        RemoveProp(hWnd, "Class");
        WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - 4");
        PostQuitMessage(0);
        WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - Done");
        break;
    default:
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }
    return TRUE;
}
Example #5
0
static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct TFtPageData *dat = (struct TFtPageData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	int i;

	switch (msg) {
	case WM_INITDIALOG:
		{
			// Force scrollbar visibility
			SCROLLINFO si = {0};
			si.cbSize = sizeof(si);
			si.fMask = SIF_DISABLENOSCROLL;
			SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

			dat = (struct TFtPageData *)mir_alloc(sizeof(struct TFtPageData));
			dat->wnds = (struct TLayoutWindowList *)List_Create(0, 1);
			dat->scrollPos = 0;
			dat->runningCount = 0;
			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
		}
		break;

	case WM_FT_ADD:
		{
			TLayoutWindowInfo *wnd = (struct TLayoutWindowInfo *)mir_alloc(sizeof(struct TLayoutWindowInfo));
			wnd->hwnd = (HWND)lParam;
			GetWindowRect(wnd->hwnd, &wnd->rc);
			List_Insert((SortedList *)dat->wnds, wnd, dat->wnds->realCount);
			LayoutTransfers(hwnd, dat);
			dat->runningCount++;
			PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);
		}
		break;

	case WM_FT_RESIZE:
		for (i=0; i < dat->wnds->realCount; ++i)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				GetWindowRect(dat->wnds->items[i]->hwnd, &dat->wnds->items[i]->rc);
				break;
			}
		LayoutTransfers(hwnd, dat);
		break;

	case WM_FT_REMOVE:
		for (i=0; i < dat->wnds->realCount; ++i)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				mir_free(dat->wnds->items[i]);
				List_Remove((SortedList *)dat->wnds, i);
				break;
			}
		LayoutTransfers(hwnd, dat);
		break;

	case WM_FT_COMPLETED:
		//wParam: { ACKRESULT_SUCCESS | ACKRESULT_FAILED | ACKRESULT_DENIED }
		dat->runningCount--;
		for (i=0; i < dat->wnds->realCount; i++) {
			// no error when canceling (WM_FT_REMOVE is send first, check if hwnd is still registered)
			if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
				SendMessage(GetParent(hwnd), WM_TIMER, 1, (LPARAM)wParam);
				break;
			}
		}
		if (i == dat->wnds->realCount)
			PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);

		if(dat->runningCount == 0 && (int)wParam == ACKRESULT_SUCCESS && db_get_b(NULL, "SRFile", "AutoClose", 0))
			ShowWindow(hwndFtMgr, SW_HIDE);
		break;

	case WM_FT_CLEANUP:
		for (i=0; i < dat->wnds->realCount; ++i)
			SendMessage(dat->wnds->items[i]->hwnd, WM_FT_CLEANUP, wParam, lParam);
		break;

	case WM_SIZE:
		LayoutTransfers(hwnd, dat);
		break;

	case WM_MOUSEWHEEL:
		{
			int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
			if (zDelta) {
				int nScrollLines = 0;
				SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0);
				for (i=0; i < (nScrollLines + 1) / 2; i++)
					SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
			}

			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, 0);
			return TRUE;
		}

	case WM_VSCROLL:
		{
			int pos = dat->scrollPos;
			switch (LOWORD(wParam)) {
			case SB_LINEDOWN:
				pos += 15;
				break;
			case SB_LINEUP:
				pos -= 15;
				break;
			case SB_PAGEDOWN:
				pos += dat->height - 10;
				break;
			case SB_PAGEUP:
				pos -= dat->height - 10;
				break;
			case SB_THUMBTRACK:
				pos = HIWORD(wParam);
				break;
			}

			if (pos > dat->dataHeight - dat->height) pos = dat->dataHeight - dat->height;
			if (pos < 0) pos = 0;

			if (dat->scrollPos != pos) {
				ScrollWindow(hwnd, 0, dat->scrollPos - pos, NULL, NULL);
				SetScrollPos(hwnd, SB_VERT, pos, TRUE);
				dat->scrollPos = pos;
			}
			break;
		}

	case M_PRESHUTDOWN:
		for (i=0; i < dat->wnds->realCount; ++i)
			PostMessage(dat->wnds->items[i]->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0);
		break;

	case M_CALCPROGRESS:
		{
			TFtProgressData *prg = (TFtProgressData *)wParam;
			for (i=0; i < dat->wnds->realCount; ++i) {
				struct FileDlgData *trdat = (struct FileDlgData *)GetWindowLongPtr(dat->wnds->items[i]->hwnd, GWLP_USERDATA);
				if (trdat->transferStatus.totalBytes && trdat->fs && !trdat->send && (trdat->transferStatus.totalBytes == trdat->transferStatus.totalProgress))
					prg->scan++;
				else if (trdat->transferStatus.totalBytes && trdat->fs) { // in progress
					prg->run++;
					prg->totalBytes += trdat->transferStatus.totalBytes;
					prg->totalProgress += trdat->transferStatus.totalProgress;
				}
				else if (trdat->fs) // starting
					prg->init++;
			}
		}
		break;

	case WM_DESTROY:
		for (i=0; i < dat->wnds->realCount; ++i)
			mir_free(dat->wnds->items[i]);
		List_Destroy((SortedList *)dat->wnds);
		mir_free(dat->wnds);
		mir_free(dat);
		break;
	}

	return FALSE;
}
Example #6
0
/** Maximiza la pantalla*/
void In2WindowsDetector::showWindow(HWND handler){
    PostMessage(handler,WM_SYSCOMMAND,SC_MAXIMIZE,0);
}
Example #7
0
static BOOL CALLBACK SkinEdit_ExtBkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    SKINDESCRIPTION *psd = (SKINDESCRIPTION *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

    if(psd) {
        ID_EXTBK_FIRST = psd->firstItem;
        ID_EXTBK_LAST = psd->lastItem;
        StatusItems = psd->StatusItems;
    }
    switch (msg) {
        case WM_INITDIALOG:
            psd = (SKINDESCRIPTION *)malloc(sizeof(SKINDESCRIPTION));
            ZeroMemory(psd, sizeof(SKINDESCRIPTION));
            CopyMemory(psd, (void *)lParam, sizeof(SKINDESCRIPTION));
            SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)psd);

            if(psd) {
                ID_EXTBK_FIRST = psd->firstItem;
                ID_EXTBK_LAST = psd->lastItem;
                StatusItems = psd->StatusItems;
            }

            TranslateDialogDefault(hwndDlg);
            FillItemList(hwndDlg);
            SendMessage(hwndDlg, WM_USER + 101, 0, 0);

            psd->hMenuItems = CreatePopupMenu();
            AppendMenu(psd->hMenuItems, MF_STRING | MF_DISABLED, (UINT_PTR)0, _T("Copy from"));
            AppendMenuA(psd->hMenuItems, MF_SEPARATOR, (UINT_PTR)0, NULL);

            {
				int i;
				
				for(i = ID_EXTBK_FIRST; i <= ID_EXTBK_LAST; i++) {
					int iOff = StatusItems[i - ID_EXTBK_FIRST].szName[0] == '{' ? 3 : 0;
					if(iOff)
						AppendMenuA(psd->hMenuItems, MF_SEPARATOR, (UINT_PTR)0, NULL);
					AppendMenuA(psd->hMenuItems, MF_STRING, (UINT_PTR)i, &StatusItems[i - ID_EXTBK_FIRST].szName[iOff]);
				}
			}
            return TRUE;
        case WM_USER + 101:
            {
                SendDlgItemMessage(hwndDlg, IDC_MRGN_LEFT_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_MRGN_TOP_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_MRGN_RIGHT_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_MRGN_BOTTOM_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_ALPHASPIN, UDM_SETRANGE, 0, MAKELONG(100, 0));
                SendDlgItemMessage(hwndDlg, IDC_ALPHASPIN2, UDM_SETRANGE, 0, MAKELONG(100, 0));

                return 0;
            }

        case WM_DRAWITEM:
            {
                DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *) lParam;
                int iItem = dis->itemData;
                TStatusItem *item = 0;

                SetBkMode(dis->hDC, TRANSPARENT);
                FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW));

                if(iItem >= ID_EXTBK_FIRST && iItem <= ID_EXTBK_LAST)
                    item = &StatusItems[iItem - ID_EXTBK_FIRST];

                if (dis->itemState & ODS_SELECTED && iItem != ID_EXTBKSEPARATOR) {
                    FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
                    SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
                }
                else {
                    FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW));
                    if(item && item->IGNORED)
                        SetTextColor(dis->hDC, RGB(255, 0, 0));
                    else if(item && item->dwFlags & S_ITEM_IMAGE_ONLY)
                    	SetTextColor(dis->hDC, RGB(0, 0, 255));
                    else
                        SetTextColor(dis->hDC, GetSysColor(COLOR_WINDOWTEXT));
                }
                if(iItem == ID_EXTBKSEPARATOR) {
                    HPEN    hPen, hPenOld;
                    POINT   pt;

                    hPen = CreatePen(PS_SOLID, 2, GetSysColor(COLOR_WINDOWTEXT));
                    hPenOld = (HPEN)SelectObject(dis->hDC, hPen);

                    MoveToEx(dis->hDC, dis->rcItem.left, (dis->rcItem.top + dis->rcItem.bottom) / 2, &pt);
                    LineTo(dis->hDC, dis->rcItem.right, (dis->rcItem.top + dis->rcItem.bottom) / 2);
                    SelectObject(dis->hDC, hPenOld);
                    DeleteObject((HGDIOBJ)hPen);
                }
                else if(dis->itemID >= 0 && item) {
                    char   *szName = item->szName[0] == '{' ? &item->szName[3] : item->szName;

                    TextOutA(dis->hDC, dis->rcItem.left, dis->rcItem.top, szName, lstrlenA(szName));
                }
                return TRUE;
            }

        case WM_CONTEXTMENU:
            {
                POINT pt;
                RECT  rc;
                HWND hwndList = GetDlgItem(hwndDlg, IDC_ITEMS);

                GetCursorPos(&pt);
                GetWindowRect(hwndList, &rc);
                if(PtInRect(&rc, pt)) {
                    int iSelection = (int)TrackPopupMenu(psd->hMenuItems, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);

                    if(iSelection >= ID_EXTBK_FIRST && iSelection <= ID_EXTBK_LAST) {
                        iSelection -= ID_EXTBK_FIRST;

                        for(int i = ID_EXTBK_FIRST; i <= ID_EXTBK_LAST; i++) {
                            if(SendMessage(hwndList, LB_GETSEL, i - ID_EXTBK_FIRST, 0) > 0) {
                                int iIndex = SendMessage(hwndList, LB_GETITEMDATA, i - ID_EXTBK_FIRST, 0);
                                iIndex -= ID_EXTBK_FIRST;

                                if(iIndex >= 0) {
                                    StatusItems[iIndex].ALPHA = StatusItems[iSelection].ALPHA;
                                    StatusItems[iIndex].COLOR = StatusItems[iSelection].COLOR;
                                    StatusItems[iIndex].COLOR2 = StatusItems[iSelection].COLOR2;
                                    StatusItems[iIndex].ALPHA2 = StatusItems[iSelection].ALPHA2;
                                    StatusItems[iIndex].CORNER = StatusItems[iSelection].CORNER;
                                    StatusItems[iIndex].GRADIENT = StatusItems[iSelection].GRADIENT;
                                    StatusItems[iIndex].IGNORED = StatusItems[iSelection].IGNORED;
                                    StatusItems[iIndex].imageItem = StatusItems[iSelection].imageItem;
                                    StatusItems[iIndex].MARGIN_BOTTOM = StatusItems[iSelection].MARGIN_BOTTOM;
                                    StatusItems[iIndex].MARGIN_LEFT = StatusItems[iSelection].MARGIN_LEFT;
                                    StatusItems[iIndex].MARGIN_RIGHT = StatusItems[iSelection].MARGIN_RIGHT;
                                    StatusItems[iIndex].MARGIN_TOP = StatusItems[iSelection].MARGIN_TOP;
                                    StatusItems[iIndex].TEXTCOLOR = StatusItems[iSelection].TEXTCOLOR;
                                    StatusItems[iIndex].dwFlags = StatusItems[iSelection].dwFlags;
                                }
                            }
                        }
                        OnListItemsChange(hwndDlg);
                    }
                }
                break;
            }
        case WM_COMMAND:
    // this will check if the user changed some actual statusitems values
    // if yes the flag bChanged will be set to TRUE
            SetChangedStatusItemFlag(wParam, hwndDlg);
            switch(LOWORD(wParam)) {
                case IDC_ITEMS:
                    if (HIWORD(wParam) != LBN_SELCHANGE)
                        return FALSE;
                    {
                        int iItem = SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETCURSEL, 0, 0), 0);
                        if(iItem == ID_EXTBKSEPARATOR)
                            return FALSE;
                    }
                    OnListItemsChange(hwndDlg);
					if(psd->pfnClcOptionsChanged)
						psd->pfnClcOptionsChanged();
                    break;
                case IDC_SKIP_UNDERLAY:
                case IDC_SKIP_IMAGE:
                case IDC_GRADIENT:
                case IDC_CORNER:
                case IDC_IGNORE:
                    ReActiveCombo(hwndDlg);
                    break;
            }
            if ((LOWORD(wParam) == IDC_ALPHA || LOWORD(wParam) == IDC_ALPHA2 || LOWORD(wParam) == IDC_MRGN_LEFT || LOWORD(wParam) == IDC_MRGN_BOTTOM || LOWORD(wParam) == IDC_MRGN_TOP || LOWORD(wParam) == IDC_MRGN_RIGHT) && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
                return 0;
            SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            break;

        case WM_NOTIFY:
            switch (((LPNMHDR) lParam)->idFrom) {
                case 0:
                    switch (((LPNMHDR) lParam)->code) {
                        case PSN_APPLY:
                // save user made changes
                            SaveLatestChanges(hwndDlg);
                // save struct to DB
							if(psd->pfnSaveCompleteStruct)
								psd->pfnSaveCompleteStruct();

                            if(psd->pfnClcOptionsChanged)
								psd->pfnClcOptionsChanged();
							if(psd->hwndCLUI) {
								SendMessage(psd->hwndCLUI, WM_SIZE, 0, 0);
								PostMessage(psd->hwndCLUI, WM_USER+100, 0, 0);          // CLUIINTM_REDRAW
							}
                            break;
                    }
            }
            break;
        case WM_DESTROY:
            DestroyMenu(psd->hMenuItems);
            break;
        case WM_NCDESTROY:
            free(psd);
            SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)0);
            break;
    }
    return FALSE;
}
void MulticrewUI::logged( const char *line ) {
	EnterCriticalSection( &d->loggedCritSect );
	d->loggedLines.push_back( line );
	LeaveCriticalSection( &d->loggedCritSect );
	PostMessage( d->hwnd, WM_COMMAND, ID_LOG, 0 );
}
void MulticrewUI::asyncSlot() {
	//dout << "posting async" << std::endl;
	PostMessage( d->hwnd, WM_COMMAND, ID_ASYNC, 0 );
}
void AppClass::ProcessKeyboard(void)
{
	bool bModifier = false;
	float fSpeed = 0.01f;

#pragma region ON PRESS/RELEASE DEFINITION
	static bool	bLastF1 = false, bLastF2 = false, bLastF3 = false, bLastF4 = false, bLastF5 = false,
				bLastF6 = false, bLastF7 = false, bLastF8 = false, bLastF9 = false, bLastF10 = false,
				bLastEscape = false, bLastF = false, bLastReturn = false, bLastSpace = false;
#define ON_KEY_PRESS_RELEASE(key, pressed_action, released_action){  \
			bool pressed = sf::Keyboard::isKeyPressed(sf::Keyboard::key);			\
			if(pressed){											\
				if(!bLast##key) pressed_action;}/*Just pressed? */\
			else if(bLast##key) released_action;/*Just released?*/\
			bLast##key = pressed; } //remember the state
#pragma endregion

#pragma region Modifiers
	if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift) || sf::Keyboard::isKeyPressed(sf::Keyboard::RShift))
		bModifier = true;
#pragma endregion

#pragma region Camera Positioning
	if(bModifier)
		fSpeed *= 10.0f;
	if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
		m_pCameraMngr->MoveForward(fSpeed);

	if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
		m_pCameraMngr->MoveForward(-fSpeed);
	
	if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
		m_pCameraMngr->MoveSideways(-fSpeed);

	if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
		m_pCameraMngr->MoveSideways(fSpeed);

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Q))
		m_pCameraMngr->MoveVertical(-fSpeed);

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::E))
		m_pCameraMngr->MoveVertical(fSpeed);
#pragma endregion

#pragma region Other Actions
	ON_KEY_PRESS_RELEASE(Escape, NULL, PostMessage(m_pWindow->GetHandler(), WM_QUIT, NULL, NULL));
	ON_KEY_PRESS_RELEASE(F1, NULL, m_pCameraMngr->SetCameraMode(CAMPERSP));
	ON_KEY_PRESS_RELEASE(F2, NULL, m_pCameraMngr->SetCameraMode(CAMROTHOZ));
	ON_KEY_PRESS_RELEASE(F3, NULL, m_pCameraMngr->SetCameraMode(CAMROTHOY));
	ON_KEY_PRESS_RELEASE(F4, NULL, m_pCameraMngr->SetCameraMode(CAMROTHOX));
	bool bEnter = false;
	ON_KEY_PRESS_RELEASE(Return, NULL, bEnter = true);
	if (bEnter)
	{
		m_pEntityMngr->ApplyForce(REAXISX * m_fForce, "Steve");
		m_pEntityMngr->ApplyForce(REAXISX * -m_fForce, "Creeper");
	}
	bool bSpace = false;
	ON_KEY_PRESS_RELEASE(Space, NULL, bSpace = true);
	if (bSpace)
	{
		m_pEntityMngr->ApplyForce(REAXISY * m_fForce, "Steve");
		m_pEntityMngr->ApplyForce(REAXISY * m_fForce, "Creeper");
	}
#pragma endregion
}
Example #11
0
static VOID
MainWndCommand(PMAIN_WND_INFO Info,
               WORD CmdId,
               HWND hControl)
{
    UNREFERENCED_PARAMETER(hControl);

    switch (CmdId)
    {
        case IDC_PROP:
        {
            HTREEITEM hSelected = TreeView_GetSelection(Info->hTreeView);
            OpenPropSheet(Info->hTreeView,
                          hSelected);
        }
        break;

        case IDC_REFRESH:
        {
            OnRefresh(Info);
        }
        break;

        case IDC_PROGHELP:
        {
            DisplayString(_T("Help is not yet implemented\n"));
            SetFocus(Info->hTreeView);
        }
        break;

        case IDC_EXIT:
        {
            PostMessage(Info->hMainWnd,
                        WM_CLOSE,
                        0,
                        0);
        }
        break;

        case IDC_ABOUT:
        {
            DialogBox(hInstance,
                      MAKEINTRESOURCE(IDD_ABOUTBOX),
                      Info->hMainWnd,
                      AboutDialogProc);

            SetFocus(Info->hTreeView);
        }
        break;

        case IDC_DEVBYTYPE:
        {
            Info->Display = DevicesByType;
            UpdateViewMenu(Info);
            OnRefresh(Info);
        }
        break;

        case IDC_DEVBYCONN:
        {
            Info->Display = DevicesByConnection;
            UpdateViewMenu(Info);
            OnRefresh(Info);
        }
        break;

        case IDC_SHOWHIDDEN:
        {
            Info->bShowHidden = !Info->bShowHidden;
            UpdateViewMenu(Info);
            OnRefresh(Info);
        }
        break;
    }
}
Example #12
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL,
      stopWnd = NULL, editWnd = NULL;
  static WNDPROC editWndOldProc = NULL;
  
  // Static members used for the find dialog.
  static FINDREPLACE fr;
  static WCHAR szFindWhat[80] = {0};
  static WCHAR szLastFindWhat[80] = {0};
  static bool findNext = false;
  static bool lastMatchCase = false;
  
  int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

  if(hWnd == editWnd)
  {
    // Callback for the edit window
    switch (message)
    {
    case WM_CHAR:
      if (wParam == VK_RETURN && g_handler.get())
      {
        // When the user hits the enter key load the URL
        CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
        wchar_t strPtr[MAX_URL_LENGTH] = {0};
        *((LPWORD)strPtr) = MAX_URL_LENGTH; 
        LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
        if (strLen > 0) {
          strPtr[strLen] = 0;
          browser->GetMainFrame()->LoadURL(strPtr);
        }

        return 0;
      }
    }

    return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam, lParam);
  }
  else if (message == uFindMsg)
  { 
    // Find event.
    LPFINDREPLACE lpfr = (LPFINDREPLACE)lParam;

    if (lpfr->Flags & FR_DIALOGTERM)
    { 
      // The find dialog box has been dismissed so invalidate the handle and
      // reset the search results.
      hFindDlg = NULL; 
      if(g_handler.get())
      {
        g_handler->GetBrowser()->StopFinding(true);
        szLastFindWhat[0] = 0;
        findNext = false;
      }
      return 0; 
    } 

    if ((lpfr->Flags & FR_FINDNEXT) && g_handler.get()) 
    {
      // Search for the requested string.
      bool matchCase = (lpfr->Flags & FR_MATCHCASE?true:false);
      if(matchCase != lastMatchCase ||
        (matchCase && wcsncmp(szFindWhat, szLastFindWhat,
          sizeof(szLastFindWhat)/sizeof(WCHAR)) != 0) ||
        (!matchCase && _wcsnicmp(szFindWhat, szLastFindWhat,
          sizeof(szLastFindWhat)/sizeof(WCHAR)) != 0))
      {
        // The search string has changed, so reset the search results.
        if(szLastFindWhat[0] != 0) {
          g_handler->GetBrowser()->StopFinding(true);
          findNext = false;
        }
        lastMatchCase = matchCase;
        wcscpy_s(szLastFindWhat, sizeof(szLastFindWhat)/sizeof(WCHAR),
            szFindWhat);
      }

      g_handler->GetBrowser()->Find(0, lpfr->lpstrFindWhat,
          (lpfr->Flags & FR_DOWN)?true:false, matchCase, findNext);
      if(!findNext)
        findNext = true;
    }

    return 0; 
  }
  else
  {
    // Callback for the main window
	  switch (message)
	  {
    case WM_CREATE:
      {
        // Create the single static handler class instance
        g_handler = new ClientHandler();
        g_handler->SetMainHwnd(hWnd);

        // Create the child windows used for navigation
        RECT rect;
        int x = 0;
        
        GetClientRect(hWnd, &rect);
        
        backWnd = CreateWindow(L"BUTTON", L"Back",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                               | WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
                               hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
        x += BUTTON_WIDTH;

        forwardWnd = CreateWindow(L"BUTTON", L"Forward",
                                  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                                  | WS_DISABLED, x, 0, BUTTON_WIDTH,
                                  URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
                                  hInst, 0);
        x += BUTTON_WIDTH;

        reloadWnd = CreateWindow(L"BUTTON", L"Reload",
                                 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                                 | WS_DISABLED, x, 0, BUTTON_WIDTH,
                                 URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
                                 hInst, 0);
        x += BUTTON_WIDTH;

        stopWnd = CreateWindow(L"BUTTON", L"Stop",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                               | WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
                               hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
        x += BUTTON_WIDTH;

        editWnd = CreateWindow(L"EDIT", 0,
                               WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
                               ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED, 
                               x, 0, rect.right - BUTTON_WIDTH * 4,
                               URLBAR_HEIGHT, hWnd, 0, hInst, 0);
        
        // Assign the edit window's WNDPROC to this function so that we can
        // capture the enter key
        editWndOldProc =
            reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
        SetWindowLongPtr(editWnd, GWLP_WNDPROC,
            reinterpret_cast<LONG_PTR>(WndProc)); 
        g_handler->SetEditHwnd(editWnd);
        g_handler->SetButtonHwnds(backWnd, forwardWnd, reloadWnd, stopWnd);
        
        rect.top += URLBAR_HEIGHT;
         
        CefWindowInfo info;
        CefBrowserSettings settings;

        // Populate the settings based on command line arguments.
        AppGetBrowserSettings(settings);

        // Initialize window info to the defaults for a child window
        info.SetAsChild(hWnd, rect);

        // Creat the new child browser window
        CefBrowser::CreateBrowser(info,
            static_cast<CefRefPtr<CefClient> >(g_handler),
            "http://www.google.com", settings);
      }
      return 0;

    case WM_COMMAND:
      {
        CefRefPtr<CefBrowser> browser;
        if(g_handler.get())
          browser = g_handler->GetBrowser();

        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_ABOUT:
          DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
          return 0;
        case IDM_EXIT:
          DestroyWindow(hWnd);
          return 0;
        case ID_WARN_CONSOLEMESSAGE:
          if(g_handler.get()) {
            std::wstringstream ss;
            ss << L"Console messages will be written to "
                << std::wstring(CefString(g_handler->GetLogFile()));
            MessageBox(hWnd, ss.str().c_str(), L"Console Messages",
                MB_OK | MB_ICONINFORMATION);
          }
          return 0;
        case ID_WARN_DOWNLOADCOMPLETE:
        case ID_WARN_DOWNLOADERROR:
          if(g_handler.get()) {
            std::wstringstream ss;
            ss << L"File \"" <<
                std::wstring(CefString(g_handler->GetLastDownloadFile())) <<
                L"\" ";

            if(wmId == ID_WARN_DOWNLOADCOMPLETE)
              ss << L"downloaded successfully.";
            else
              ss << L"failed to download.";

            MessageBox(hWnd, ss.str().c_str(), L"File Download",
                MB_OK | MB_ICONINFORMATION);
          }
          return 0;
        case ID_FIND:
          if(!hFindDlg)
          {
            // Create the find dialog.
            ZeroMemory(&fr, sizeof(fr));
            fr.lStructSize = sizeof(fr);
            fr.hwndOwner = hWnd;
            fr.lpstrFindWhat = szFindWhat;
            fr.wFindWhatLen = sizeof(szFindWhat);
            fr.Flags = FR_HIDEWHOLEWORD | FR_DOWN;

            hFindDlg = FindText(&fr);
          }
          else
          {
            // Give focus to the existing find dialog.
            ::SetFocus(hFindDlg);
          }
          return 0;
        case ID_PRINT:
          if(browser.get())
            browser->GetMainFrame()->Print();
          return 0;
        case IDC_NAV_BACK:  // Back button
          if(browser.get())
            browser->GoBack();
          return 0;
        case IDC_NAV_FORWARD: // Forward button
          if(browser.get())
            browser->GoForward();
          return 0;
        case IDC_NAV_RELOAD:  // Reload button
          if(browser.get())
            browser->Reload();
          return 0;
        case IDC_NAV_STOP:  // Stop button
          if(browser.get())
            browser->StopLoad();
          return 0;
        case ID_TESTS_GETSOURCE: // Test the GetSource function
          if(browser.get())
            RunGetSourceTest(browser);
          return 0;
        case ID_TESTS_GETTEXT: // Test the GetText function
          if(browser.get())
            RunGetTextTest(browser);
          return 0;
        case ID_TESTS_JAVASCRIPT_BINDING: // Test the V8 binding handler
          if(browser.get())
            RunBindingTest(browser);
          return 0;
        case ID_TESTS_JAVASCRIPT_EXTENSION: // Test the V8 extension handler
          if(browser.get())
            RunExtensionTest(browser);
          return 0;
        case ID_TESTS_JAVASCRIPT_PERFORMANCE: // Test the V8 performance
          if(browser.get())
            RunExtensionPerfTest(browser);
          return 0;
        case ID_TESTS_JAVASCRIPT_EXECUTE: // Test execution of javascript
          if(browser.get())
            RunJavaScriptExecuteTest(browser);
          return 0;
        case ID_TESTS_JAVASCRIPT_INVOKE:
          if(browser.get())
            RunJavaScriptInvokeTest(browser);
          return 0;
        case ID_TESTS_PLUGIN: // Test the custom plugin
          if(browser.get())
            RunPluginTest(browser);
          return 0;
        case ID_TESTS_POPUP: // Test a popup window
          if(browser.get())
            RunPopupTest(browser);
          return 0;
        case ID_TESTS_TRANSPARENT_POPUP: // Test a transparent popup window
          if(browser.get())
            RunTransparentPopupTest(browser);
          return 0;
        case ID_TESTS_REQUEST: // Test a request
          if(browser.get())
            RunRequestTest(browser);
          return 0;
        case ID_TESTS_SCHEME_HANDLER: // Test the scheme handler
          if(browser.get())
            RunSchemeTest(browser);
          return 0;
        case ID_TESTS_UIAPP: // Test the UI app
          if(browser.get())
            RunUIPluginTest(browser);
          return 0;
        case ID_TESTS_OSRAPP: // Test the OSR app
          if(browser.get())
            RunOSRPluginTest(browser, false);
          return 0;
        case ID_TESTS_TRANSPARENT_OSRAPP: // Test the OSR app with transparency
          if(browser.get())
            RunOSRPluginTest(browser, true);
          return 0;
        case ID_TESTS_DOMACCESS: // Test DOM access
          if(browser.get())
            RunDOMAccessTest(browser);
          return 0;
        case ID_TESTS_LOCALSTORAGE: // Test localStorage
          if(browser.get())
            RunLocalStorageTest(browser);
          return 0;
        case ID_TESTS_ACCELERATED2DCANVAS: // Test accelerated 2d canvas
          if(browser.get())
            RunAccelerated2DCanvasTest(browser);
          return 0;
        case ID_TESTS_ACCELERATEDLAYERS: // Test accelerated layers
          if(browser.get())
            RunAcceleratedLayersTest(browser);
          return 0;
        case ID_TESTS_WEBGL: // Test WebGL
          if(browser.get())
            RunWebGLTest(browser);
          return 0;
        case ID_TESTS_HTML5VIDEO: // Test HTML5 video
          if(browser.get())
            RunHTML5VideoTest(browser);
          return 0;
        case ID_TESTS_DRAGDROP: // Test drag & drop
          if(browser.get())
            RunDragDropTest(browser);
          return 0;
        case ID_TESTS_XMLHTTPREQUEST: // Test XMLHttpRequest
          if(browser.get())
            RunXMLHTTPRequestTest(browser);
          return 0;
        case ID_TESTS_WEBURLREQUEST:
          if (browser.get())
            RunWebURLRequestTest(browser);
          return 0;
        case ID_TESTS_ZOOM_IN:
          if(browser.get())
            browser->SetZoomLevel(browser->GetZoomLevel() + 0.5);
          return 0;
        case ID_TESTS_ZOOM_OUT:
          if(browser.get())
            browser->SetZoomLevel(browser->GetZoomLevel() - 0.5);
          return 0;
        case ID_TESTS_ZOOM_RESET:
          if(browser.get())
            browser->SetZoomLevel(0.0);
          return 0;
        case ID_TESTS_DEVTOOLS_SHOW:
          if (browser.get())
            browser->ShowDevTools();
          return 0;
        case ID_TESTS_DEVTOOLS_CLOSE:
          if (browser.get())
            browser->CloseDevTools();
          return 0;
        case ID_TESTS_MODALDIALOG:
          if(browser.get())
            RunModalDialogTest(browser);
          return 0;
        case ID_TESTS_GETIMAGE:
          if(browser.get())
            RunGetImageTest(browser);
          return 0;
        }
      }
      break;

    case WM_PAINT:
      hdc = BeginPaint(hWnd, &ps);
      EndPaint(hWnd, &ps);
      return 0;

    case WM_SETFOCUS:
      if(g_handler.get() && g_handler->GetBrowserHwnd())
      {
        // Pass focus to the browser window
        PostMessage(g_handler->GetBrowserHwnd(), WM_SETFOCUS, wParam, NULL);
      }
      return 0;

    case WM_SIZE:
      if(g_handler.get() && g_handler->GetBrowserHwnd())
      {
        // Resize the browser window and address bar to match the new frame
        // window size
        RECT rect;
        GetClientRect(hWnd, &rect);
        rect.top += URLBAR_HEIGHT;

        int urloffset = rect.left + BUTTON_WIDTH * 4;

        HDWP hdwp = BeginDeferWindowPos(1);
        hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset,
          0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER);
        hdwp = DeferWindowPos(hdwp, g_handler->GetBrowserHwnd(), NULL,
          rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
          SWP_NOZORDER);
        EndDeferWindowPos(hdwp);
      }
      break;

    case WM_ERASEBKGND:
      if(g_handler.get() && g_handler->GetBrowserHwnd())
      {
        // Dont erase the background if the browser window has been loaded
        // (this avoids flashing)
        return 0;
      }
      break;

    case WM_CLOSE:
      if (g_handler.get()) {
        CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
        if (browser.get()) {
          // Let the browser window know we are about to destroy it.
          browser->ParentWindowWillClose();
        }
      }
      break;

    case WM_DESTROY:
      // The frame window has exited
      PostQuitMessage(0);
      return 0;
    }
  	
    return DefWindowProc(hWnd, message, wParam, lParam);
  }
}
Example #13
0
BOOL CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
  switch (uMsg)
  {
    case WM_INITDIALOG:
    {
      hDoneBtn=GetDlgItem(hWnd,IDOK);

      if (wcslen(szFile) != 0) 
      {
        SetDlgItemText(hWnd,IDC_FILENAME,szFile);
        EnableWindow(hDoneBtn,TRUE);
      }
      return TRUE;
    }
    case WM_CLOSE:
    {
      EndDialog(hWnd,0);
      break;
    }
    case WM_COMMAND:
    {
      switch (wParam)
      {
        case IDCANCEL:
        {
          PostMessage(hWnd,WM_CLOSE,0,0);
          break;
        }
        case IDOK:
        {
          WCHAR suffix[200];
          DWORD suffix_length = 0;

          ZeroMemory(suffix, sizeof(suffix));
          suffix_length = GetDlgItemTextW(hWnd,IDC_URLS_SUFFIX,
            suffix,ARRAYSIZE(suffix) - 1);

          int dwSize=GetDlgItemTextW(hWnd,IDC_URLS,lpBuf,1024*1024);
          if (dwSize != 0)
          {
            InjectToPeURLsSection(szFile, lpBuf, dwSize, suffix);
          }
          //HANDLE hRes=BeginUpdateResource(szFile,FALSE);
          //UpdateResource(hRes,RT_RCDATA, MAKEINTRESOURCE(100), 0,lpBuf,(dwSize+1)*sizeof(WCHAR));
          //EndUpdateResource(hRes,FALSE);
        }
        break;

        case IDC_BROWSE:
        {
          TCHAR szFileName[MAX_PATH];
          szFileName[0]=0;
          OPENFILENAME ofn;

          memset(&ofn, 0, sizeof(ofn));

          ofn.lStructSize=sizeof(OPENFILENAME);
          ofn.hwndOwner=hWnd;
          ofn.lpstrFilter=TEXT("Библиотеки (*.dll)\0*.dll\0Программы (*.exe)\0*.exe\0Все файлы (*.*)\0*.*\0");
          ofn.Flags=OFN_HIDEREADONLY+OFN_PATHMUSTEXIST+OFN_FILEMUSTEXIST;
          ofn.nMaxFile=MAX_PATH;
          ofn.nFilterIndex=1;
          ofn.lpstrFile=szFileName;
          if (GetOpenFileName(&ofn))
          {
            SetDlgItemText(hWnd,IDC_FILENAME,szFileName);
            EnableWindow(hDoneBtn,TRUE);
            ZeroMemory(szFile, sizeof(szFile));
            lstrcpy(szFile,szFileName);
          }
          break;
        }
      }
      break;
    }
    break;
  }
  return FALSE;
}
Example #14
0
LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
{
    WPARAM mode         = wparam & 0xffff;
	unsigned cmd         = RARCH_CMD_NONE;
	bool do_wm_close     = false;
   settings_t *settings = config_get_ptr();
   global_t   *global   = global_get_ptr();

   (void)global;

	switch (mode)
   {
      case ID_M_LOAD_CORE:
      case ID_M_LOAD_CONTENT:
         {
            char win32_file[PATH_MAX_LENGTH] = {0};
            const char *extensions  = NULL;
            const char *title       = NULL;
            const char *initial_dir = NULL;

            if      (mode == ID_M_LOAD_CORE)
            {
               extensions  = "All Files\0*.*\0 Libretro core(.dll)\0*.dll\0";
               title       = "Load Core";
               initial_dir = settings->libretro_directory;
            }
            else if (mode == ID_M_LOAD_CONTENT)
            {
               extensions  = "All Files\0*.*\0\0";
               title       = "Load Content";
               initial_dir = settings->menu_content_directory;
            }

            if (win32_browser(owner, win32_file, extensions, title, initial_dir))
            {
               switch (mode)
               {
                  case ID_M_LOAD_CORE:
                     strlcpy(settings->libretro, win32_file, sizeof(settings->libretro));
                     cmd = RARCH_CMD_LOAD_CORE;
                     break;
                  case ID_M_LOAD_CONTENT:
                     strlcpy(global->fullpath, win32_file, sizeof(global->fullpath));
                     cmd = RARCH_CMD_LOAD_CONTENT;
                     do_wm_close = true;
                     break;
               }
            }
         }
         break;
      case ID_M_RESET:
         cmd = RARCH_CMD_RESET;
         break;
      case ID_M_MUTE_TOGGLE:
         cmd = RARCH_CMD_AUDIO_MUTE_TOGGLE;
         break;
      case ID_M_MENU_TOGGLE:
         cmd = RARCH_CMD_MENU_TOGGLE;
         break;
      case ID_M_PAUSE_TOGGLE:
         cmd = RARCH_CMD_PAUSE_TOGGLE;
         break;
      case ID_M_LOAD_STATE:
         cmd = RARCH_CMD_LOAD_STATE;
         break;
      case ID_M_SAVE_STATE:
         cmd = RARCH_CMD_SAVE_STATE;
         break;
      case ID_M_DISK_CYCLE:
         cmd = RARCH_CMD_DISK_EJECT_TOGGLE;
         break;
      case ID_M_DISK_NEXT:
         cmd = RARCH_CMD_DISK_NEXT;
         break;
      case ID_M_DISK_PREV:
         cmd = RARCH_CMD_DISK_PREV;
         break;
      case ID_M_FULL_SCREEN:
         cmd = RARCH_CMD_FULLSCREEN_TOGGLE;
         break;
#ifdef HAVE_OPENGL
      case ID_M_SHADER_PARAMETERS:
         shader_dlg_show(owner);
         break;
#endif
      case ID_M_MOUSE_GRAB:
         cmd = RARCH_CMD_GRAB_MOUSE_TOGGLE;
         break;
      case ID_M_TAKE_SCREENSHOT:
         cmd = RARCH_CMD_TAKE_SCREENSHOT;
         break;
      case ID_M_QUIT:
         do_wm_close = true;
         break;
      default:
         if (mode >= ID_M_WINDOW_SCALE_1X && mode <= ID_M_WINDOW_SCALE_10X)
         {
            unsigned idx = (mode - (ID_M_WINDOW_SCALE_1X-1));
            global->pending.windowed_scale = idx;
            cmd = RARCH_CMD_RESIZE_WINDOWED_SCALE;
         }
         else if (mode == ID_M_STATE_INDEX_AUTO)
         {
            signed idx = -1;
            settings->state_slot = idx;
         }
         else if (mode >= (ID_M_STATE_INDEX_AUTO+1) && mode <= (ID_M_STATE_INDEX_AUTO+10))
         {
            signed idx = (mode - (ID_M_STATE_INDEX_AUTO+1));
            settings->state_slot = idx;
         }
         break;
   }

	if (cmd != RARCH_CMD_NONE)
		rarch_main_command(cmd);

	if (do_wm_close)
		PostMessage(owner, WM_CLOSE, 0, 0);
	
	return 0L;
}
Example #15
0
void OnRightClickList(UINT flags, CPoint pt)
{
	PostMessage(hWndThis, WM_RBUTTONUP, flags, MAKELPARAM(pt.x + adjX, pt.y + adjY));
}
Example #16
0
/*! \internal
    \brief Post a message to a subscriber
    \note Obtains ::cs_kmq_msg_ref, ::cs_kmq_msg, kmq_queue::cs
    \note Should be called with ::cs_kmq_msg held
    \note Should be called with ::cs_kmq_types held if try_send is true
    */
void kmqint_post(kmq_msg_subscription * s, kmq_message * m, khm_boolean try_send) {
    if(s->rcpt_type == KMQ_RCPTTYPE_CB) {
        kmq_queue *q;
        kmq_message_ref *r;

        q = s->queue;

        if(try_send && q->thread == GetCurrentThreadId()) {
            khm_int32 rv;
            /* we are sending a message from this thread to this
               thread.  just call the recipient directly, bypassing
               the message queue. */
            m->refcount++;
            m->nSent++;
            rv = s->recipient.cb(m->type, m->subtype, 
                                 m->uparam, m->vparam);
            m->refcount--;
            if(KHM_SUCCEEDED(rv))
                m->nCompleted++;
            else
                m->nFailed++;
        } else {

            EnterCriticalSection(&q->cs);
            if (q->flags & KMQ_QUEUE_FLAG_DELETED) {
                LeaveCriticalSection(&q->cs);
                return;
            }
            LeaveCriticalSection(&q->cs);

            EnterCriticalSection(&cs_kmq_msg_ref);
            r = kmqint_get_message_ref();
            LeaveCriticalSection(&cs_kmq_msg_ref);

            r->msg = m;
            r->recipient = s->recipient.cb;

            m->refcount++;
            m->nSent++;

            EnterCriticalSection(&q->cs);
            QPUT(q,r);
            SetEvent(q->wait_o);
            LeaveCriticalSection(&q->cs);
        }
    }

#ifdef _WIN32
    else if(s->rcpt_type == KMQ_RCPTTYPE_HWND) {
        if(try_send && 
           GetCurrentThreadId() == GetWindowThreadProcessId(s->recipient.hwnd, 
                                                            NULL)) {
            /* kmqint_post does not know whether there are any other
               messages waiting to be posted at this point.  Hence,
               simply sending the message is not the right thing to do
               as the recipient may incorrectly assume that the
               message has completed when (m->nCompleted + m->nFailed
               == m->nSent).  Therefore, we only increment nSent after
               the message is sent. */

            m->refcount++;

            /* the kmq_wm_begin()/kmq_wm_end() and kmq_wm_dispatch()
               handlers decrement the reference count on the message
               when they are done. */
            SendMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, 
                        m->type, (LPARAM) m);

            m->nSent++;

        } else {
            m->nSent++;
            m->refcount++;

            /* the kmq_wm_begin()/kmq_wm_end() and kmq_wm_dispatch()
               handlers decrement the reference count on the message
               when they are done. */
            PostMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, 
                        m->type, (LPARAM) m);
        }
    }
#endif

    else {
        /* This could either be because we were passed in an invalid
           subscription or because we lost a race to a thread that
           deleted an ad-hoc subscription. */
#ifdef DEBUG
        assert(FALSE);
#endif
    }
}
Example #17
0
static INT_PTR CALLBACK ShutdownOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			WORD setting=db_get_w(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
			if (setting<3) setting=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
			SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(999,3));
			SendDlgItemMessage(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,EM_SETLIMITTEXT,3,0);
			SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
			SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,setting,FALSE);
		}
		CheckDlgButton(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK,db_get_b(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT) != 0 ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK_REMEMBERONRESTART,db_get_b(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT) != 0 ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG,db_get_b(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT) != 0 ? BST_CHECKED : BST_UNCHECKED);
		{
			BOOL enabled = ServiceIsTypeEnabled(SDSDT_SHUTDOWN,0);
			if (enabled) {
				if (ServiceExists(MS_WEATHER_UPDATE)) {
					EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER),TRUE);
					CheckDlgButton(hwndDlg,IDC_CHECK_WEATHER,db_get_b(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT) != 0 ? BST_CHECKED : BST_UNCHECKED);
				}
			}
		}
		SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
		return TRUE; /* default focus */

	case M_ENABLE_SUBCTLS:
		{
			BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG) != 0;
			if (checked != IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN))) {
				EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN),checked);
				EnableWindow(GetDlgItem(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN),checked);
				EnableWindow(GetDlgItem(hwndDlg,IDC_TEXT_COUNTDOWNSTARTS),checked);
				EnableWindow(GetDlgItem(hwndDlg,IDC_TEXT_SECONDS),checked);
			}
			return TRUE;
		}

	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDC_EDIT_CONFIRMDLGCOUNTDOWN:
			if (HIWORD(wParam)==EN_KILLFOCUS)
				if ((int)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,TRUE)<3) {
					SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(3,0));
					SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,3,FALSE);
				}
				if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
					return TRUE; /* no apply */
				break;
		}
		PostMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
		PostMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); /* enable apply */
		return FALSE;

	case WM_NOTIFY:
		switch(((NMHDR*)lParam)->code) {
		case PSN_APPLY:
			db_set_b(NULL,"AutoShutdown","ShowConfirmDlg",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG) != 0));
			db_set_w(NULL,"AutoShutdown","ConfirmDlgCountdown",(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,FALSE));
			db_set_b(NULL,"AutoShutdown","RememberOnRestart",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_REMEMBERONRESTART) != 0));
			db_set_b(NULL,"AutoShutdown","SmartOfflineCheck",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK) != 0));
			if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER)))
				db_set_b(NULL,"AutoShutdown","WeatherShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_WEATHER) != 0));
			return TRUE;
		}
		break;
	}
	return FALSE;
}
Example #18
0
BOOL CALLBACK Subsets_OpenSave_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
   static BOOL fEditing = FALSE;

   if (msg == WM_INITDIALOG)
      SetWindowLongPtr (hDlg, DWLP_USER, lp);

   LPSUBSET_OPENSAVE_PARAMS lpp;
   if ((lpp = (LPSUBSET_OPENSAVE_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
      {
      switch (msg)
         {
         case WM_INITDIALOG:
            fEditing = FALSE;
            Subsets_OpenSave_OnInitDialog (hDlg, lpp);
            break;

         case WM_COMMAND:
            if (!fEditing)
               {
               switch (LOWORD(wp))
                  {
                  case IDCANCEL:
                     EndDialog (hDlg, IDCANCEL);
                     break;

                  case IDOK:
                     GetDlgItemText (hDlg, IDC_SUBSET_NAME, lpp->szSubset, cchNAME);
                     if (lpp->szSubset[0] != TEXT('\0'))
                        {
                        BOOL fClose = TRUE;

                        if (!lpp->fOpen)
                           {
                           HKEY hk;
                           if ((hk = OpenSubsetsSubKey (NULL, lpp->szSubset, FALSE)) != NULL)
                              {
                              RegCloseKey (hk);

                              int rc = Message (MB_YESNO | MB_ICONASTERISK, IDS_SUBSET_SAVE_TITLE, IDS_SUBSET_SAVE_DESC, TEXT("%s"), lpp->szSubset);
                              if (rc != IDYES)
                                 fClose = FALSE;
                              }
                           }

                        if (fClose)
                           EndDialog (hDlg, IDOK);
                        }
                     break;

                  case IDC_SUBSET_DELETE:
                     Subsets_OpenSave_OnDelete (hDlg);
                     break;

                  case IDC_SUBSET_RENAME:
                     Subsets_OpenSave_OnRename (hDlg);
                     break;
                  }
               }
            break;

         case WM_NOTIFY:
            switch (((LPNMHDR)lp)->code)
               {
               case LVN_ITEMCHANGED:
                  if (!fEditing)
                     {
                     if ( ((LPNM_LISTVIEW)lp)->uNewState & LVIS_SELECTED )
                        Subsets_OpenSave_OnSelect (hDlg);
                     }
                  break;

               case NM_DBLCLK:
                  if (!fEditing)
                     {
                     if (((LPNMHDR)lp)->hwndFrom == GetDlgItem (hDlg, IDC_SUBSET_LIST))
                        {
                        Subsets_OpenSave_OnSelect (hDlg);
                        PostMessage (hDlg, WM_COMMAND, IDOK, 0);
                        }
                     }
                  break;

               case LVN_BEGINLABELEDIT:
                  fEditing = TRUE;
                  return FALSE;  // okay to edit label

               case LVN_ENDLABELEDIT:
                  LV_DISPINFO *plvdi;
                  if ((plvdi = (LV_DISPINFO*)lp) != NULL)
                     {
                     if ((plvdi->item.iItem != -1) &&
                         (plvdi->item.pszText != NULL))
                        {
                        HWND hList = GetDlgItem (hDlg, IDC_SUBSET_LIST);
                        TCHAR szOldName[ cchNAME ];
                        LV_GetItemText (hList, plvdi->item.iItem, 0, szOldName);

                        if (lstrcmpi (szOldName, plvdi->item.pszText))
                           {
                           BOOL fRename = TRUE;
                           BOOL fRepopulate = FALSE;

                           HKEY hk;
                           if ((hk = OpenSubsetsSubKey (NULL, plvdi->item.pszText, FALSE)) != NULL)
                              {
                              RegCloseKey (hk);

                              int rc = Message (MB_YESNO | MB_ICONASTERISK, IDS_SUBSET_SAVE_TITLE, IDS_SUBSET_SAVE_DESC, TEXT("%s"), lpp->szSubset);
                              if (rc != IDYES)
                                 fRename = FALSE;
                              else
                                 fRepopulate = TRUE;
                              }

                           if (fRename)
                              {
                              LPSUBSET subRename;
                              if ((subRename = Subsets_LoadSubset (NULL, szOldName)) != NULL)
                                 {
                                 if (Subsets_SaveSubset (NULL, plvdi->item.pszText, subRename))
                                    {
                                    (void)OpenSubsetsSubKey (NULL, szOldName, 2); // 0=open,1=create,2=delete

                                    if (fRepopulate)
                                       Subsets_OpenSave_Populate (hDlg);
                                    else
                                       {
                                       LV_SetItemText (hList, plvdi->item.iItem, 0, plvdi->item.pszText);
                                       Subsets_OpenSave_OnSelect (hDlg);
                                       }

                                    Subsets_FreeSubset (subRename);
                                    }
                                 }
                              }
                           }
                        }
                     }

                  fEditing = FALSE;
                  break;
               }
            break;
         }
      }

   return FALSE;
}
Example #19
0
static LRESULT CALLBACK TrayCBWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_TASKBARCREATED)
	{
		InitTrayIcon();
		return 0;
	}
	switch (uMsg)
	{
		case WM_TRAY_NOTIFY:
			switch(lParam)
			{
				case WM_LBUTTONDBLCLK:
					PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDM_TRAY_HIDESHOW, 0), 0);
					break;
				case WM_RBUTTONUP:
				{
					SetForegroundWindow(hWnd);
					POINT pt = { 0 };
					GetCursorPos(&pt);
					TrackPopupMenu(hTrayMenu, 0, pt.x, pt.y, 0, hWnd, 0);
					PostMessage(hWnd, WM_NULL, 0, 0);
					break;
				}
			}
			break;
		case WM_COMMAND:
			switch (LOWORD(wParam))
			{
				case IDM_TRAY_HIDESHOW:
					if (IsWindowVisible(hMainWnd))
					{
						//ShowWindow(hMainWnd, SW_HIDE);
						CloseWindow(hMainWnd);
					}
					else
					{
						ShowWindow(hMainWnd, SW_RESTORE);
						SetForegroundWindow(hMainWnd);
					}
					break;
				default:
					PostMessage(hMainWnd, WM_COMMAND, wParam, lParam);
					break;
			}
			break;
		case WM_INITMENUPOPUP:
			SendMessage(hMainWnd, WM_INITMENUPOPUP, 0, 0);
			break;
		case WM_MEASUREITEM:
		{
			if (!dwNoOwnerDrawMenu)
			{
				LPMEASUREITEMSTRUCT pMIS = (LPMEASUREITEMSTRUCT)lParam;
				if (pMIS->CtlType == ODT_MENU)
				{
					return pEBMenuTray->MeasureItem(wParam, lParam);
				}
			}
			return FALSE;
		}
		case WM_DRAWITEM:
		{
			if (!dwNoOwnerDrawMenu)
			{
				LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
				if (pDIS->CtlType == ODT_MENU)
				{
					return pEBMenuTray->DrawItem(wParam, lParam);
				}
			}
			return FALSE;
		}
		default:
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
	return 0;
}
Example #20
0
BOOL Start_File_Learn(char *filename)
{
	//OPENFILENAME ofn;
	//char filename[FILE_LEN];
	char buf[3];

	//filename[0] = '\0';
	//memset(&ofn, 0, sizeof(OPENFILENAME));
	//ofn.lStructSize = sizeof(OPENFILENAME);
	//ofn.lpstrFilter = "kifu file(*.new)\0*.new\0all file(*.*)\0*.*\0\0";
	//ofn.lpstrFile = filename;
	//ofn.nMaxFile = sizeof(filename);
	//ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
	//ofn.lpstrDefExt = "new";

	//if(!GetOpenFileName(&ofn))
	//{
	//	return FALSE;
	//}

	int error;
	FILE *fp;
	char dir_path[256], file_path[256];
	strcpy_s(dir_path, "kifu\\");
	sprintf_s(file_path, "%s%s", dir_path, filename);

	if((error = fopen_s(&fp, file_path, "r")) != 0){
		return FALSE;
	}

	int i = 0, color = BLACK;
	BitBoard bk, wh, rev;
	BitBoard first_bk = 34628173824, first_wh = 68853694464;
	BitBoard temp_b[60], temp_w[60];
	int teban[60];
	int turn;
	int move, stone_diff, cnt = 0, bad_cnt = 0;
	bool bad_data = false, end_flag = false;
	//HDC hdc;

	//MessageBox(hWnd, "エラー", "エラー", MB_OK);
	/* ファイルの終端? */
	while(1)
	{
		bk = first_bk;
		wh = first_wh;
		color = BLACK;
		turn = 0;
		/* スペース? */
   		while(1)
		{
			/* 英字を読み込む */
			buf[0] = (char )fgetc(fp);
			/* オシマイ */
			if(buf[0] == EOF)
			{
				end_flag = true;
				break;
			}
			/* スペースなら定石との切れ目か石差 */
			if(buf[0] == ' ')
			{
				/* スペースの次が数字だった場合は抜ける */
				while((buf[0] = (char )fgetc(fp)) == ' ');
				if(isdigit(buf[0]) || buf[0] == '-')
				{
					break;
				}
				/* 続きがある場合はそのまま続行 */
			}
			else if(!isalpha(buf[0]))
			{
				bad_data = true;
				break;
			}
			/* 数字を読み込む */
			buf[1] = (char )fgetc(fp);

			/****** ここからエラー処理 ******/
			/* なぜかおかしな棋譜データが結構ある */
			if(!isdigit(buf[1]))
			{
				bad_data = true;
				break;
			}
			move = ConvertToMove_U(buf);
			/* a9 とか明らかに間違った手を含んでいる棋譜がある */
			if(move == -1)
			{
				bad_data = true;
				break;
			}
			/* なぜかすでに置いたマスに置いている棋譜がある */
			if(bk & (one << move) || wh & (one << move))
			{
				bad_data = true;
				break;
			}
			/****** ここまで ******/

			if(color == BLACK)
			{
				rev = GetRev[move](bk, wh);
				/* 黒パス? */
				if(rev == 0)
				{
					rev = GetRev[move](wh, bk);
					/* 一応合法手になっているかのチェック */
					if(rev == 0)
					{
						bad_data = true;
						break;
					}
					bk ^= rev;
					wh ^= ((one << move) | rev);
				}
				else
				{
					bk ^= ((one << move) | rev);
					wh ^= rev;
					color ^= 1;
				}
			}
			else
			{
				rev = GetRev[move](wh, bk);
				/* 白パス? */
				if(rev == 0)
				{
					rev = GetRev[move](bk, wh);
					/* 一応合法手になっているかのチェック */
					if(rev == 0)
					{
						bad_data = true;
						break;
					}
					bk ^= ((one << move) | rev);
					wh ^= rev;
				}
				else
				{
					bk ^= rev;
					wh ^= ((one << move) | rev);
					color ^= 1;
				}
			}

			turn++;
			/* 対局データ生成 */
			temp_b[(turn - 1)] = bk;
			temp_w[(turn - 1)] = wh;
			teban[(turn - 1)] = color;
		}

		if(end_flag == true)
		{
			break;
		}
		if(!bad_data)
		{
			/* 石差 */
			buf[1] = (char )fgetc(fp);
			buf[2] = (char )fgetc(fp);
			sscanf_s(buf, "%d", &stone_diff);

			for(i = 0; i < 56; i++)
			{
				init_index_board(temp_b[i], temp_w[i]);
				SaveModel(data_fp[i / 4], stone_diff, temp_b[i], temp_w[i], teban[i]);
			}

		}
		else
		{
			bad_data = false;
			bad_cnt++;
		}
		/* 次の棋譜までスキップ */
		while(fgetc(fp) != 0x0A);
		/*Sleep(500);
		black = bk;
		white = wh;
		hdc = GetDC(hWnd);
		DrawBoard(hWnd, hdc, hStatus, move / 8, move % 8);
		ReleaseDC(hWnd, hdc);*/
		cnt++;
	}
	char str[512];
	sprintf_s(str, "[%s]\ngame:%d, bad:%d", filename, cnt, bad_cnt);
	PostMessage(hStatus, SB_SETTEXT, (WPARAM)0 | 3, (LPARAM)str);
	fclose(fp);

	return TRUE;
}
Example #21
0
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
                                   LPARAM lParam) {
  static SERVICE_TABLE_ENTRY service_table[] = {
    {server_name, (LPSERVICE_MAIN_FUNCTION) ServiceMain},
    {NULL, NULL}
  };
  int service_installed;
  char buf[200], *service_argv[] = {__argv[0], NULL};
  POINT pt;
  HMENU hMenu;

  switch (msg) {
    case WM_CREATE:
      if (__argv[1] != NULL &&
          !strcmp(__argv[1], service_magic_argument)) {
        start_mongoose(1, service_argv);
        StartServiceCtrlDispatcher(service_table);
        exit(EXIT_SUCCESS);
      } else {
        start_mongoose(__argc, __argv);
      }
      break;
    case WM_COMMAND:
      switch (LOWORD(wParam)) {
        case ID_QUIT:
          mg_stop(ctx);
          Shell_NotifyIcon(NIM_DELETE, &TrayIcon);
          PostQuitMessage(0);
          break;
        case ID_EDIT_CONFIG:
          edit_config_file();
          break;
        case ID_INSTALL_SERVICE:
        case ID_REMOVE_SERVICE:
          manage_service(LOWORD(wParam));
          break;
      }
      break;
    case WM_USER:
      switch (lParam) {
        case WM_RBUTTONUP:
        case WM_LBUTTONUP:
        case WM_LBUTTONDBLCLK:
          hMenu = CreatePopupMenu();
          AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, server_name);
          AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, "");
          service_installed = manage_service(0);
          snprintf(buf, sizeof(buf), "NT service: %s installed",
                   service_installed ? "" : "not");
          AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, buf);
          AppendMenu(hMenu, MF_STRING | (service_installed ? MF_GRAYED : 0),
                     ID_INSTALL_SERVICE, "Install");
          AppendMenu(hMenu, MF_STRING | (!service_installed ? MF_GRAYED : 0),
                     ID_REMOVE_SERVICE, "Deinstall");
          AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, "");
          AppendMenu(hMenu, MF_STRING, ID_EDIT_CONFIG, "Edit config file");
          AppendMenu(hMenu, MF_STRING, ID_QUIT, "Exit");
          GetCursorPos(&pt);
          SetForegroundWindow(hWnd);
          TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
          PostMessage(hWnd, WM_NULL, 0, 0);
          DestroyMenu(hMenu);
          break;
      }
      break;
  }

  return DefWindowProc(hWnd, msg, wParam, lParam);
}
Example #22
0
/*
 * HeapWalkProc - show task status
 */
BOOL FAR PASCAL HeapWalkProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    HMENU       mh;
    HMENU       mh2;
    HCURSOR     hourglass;
    HCURSOR     oldcursor;
    DLGPROC     dlgproc;
    DWORD       index;
    heap_list   hl;
    GblWndInfo  *info;
    RECT        area;
    about_info  ai;

    info = (GblWndInfo *)GetWindowLong( hwnd, 0 );
    switch( msg ) {
    case WM_CREATE:
        InitPaintProc();
        info = MemAlloc( sizeof( GblWndInfo ) );
        if( info == NULL ) {
            ErrorBox( hwnd, STR_UNABLE_2_STARTUP, MB_OK | MB_ICONINFORMATION );
            PostQuitMessage( 0 );
        }
        memset( info, 0, sizeof( GblWndInfo ) );
        SetWindowLong( hwnd, 0, (DWORD)info );
//      hdc = GetDC( hwnd );
//      ReleaseDC(hwnd, hdc);
        SetDisplayType( hwnd, &( info->list.title ), HEAPMENU_DISPLAY_INIT );
        CreateListBox( hwnd, &info->list, GLOBAL_LB );
        info->alloc_dlgproc = MakeProcInstance_DLG( AllocDlgProc, Instance );
        info->alloc_dialog = JCreateDialog( Instance, "ALLOC_DLG", hwnd, info->alloc_dlgproc );
        memset( &ResHwnd, 0, MAX_RES * sizeof( HWND ) );
        break;
    case WM_MEASUREITEM:
        break;
    case WM_MOVE:
        GetWindowRect( hwnd, &area );
        if( !info->minimized ) {
            Config.last_glob_xpos = Config.glob_xpos;
            Config.last_glob_ypos = Config.glob_ypos;
            Config.glob_xpos = area.left;
            Config.glob_ypos = area.top;
        }
        break;
    case WM_SIZE:
        ResizeListBox( LOWORD( lparam ), HIWORD( lparam ), &( info->list ) );
        if( wparam == SIZE_MINIMIZED || wparam == SIZE_MAXIMIZED ) {
            Config.glob_xpos = Config.last_glob_xpos;
            Config.glob_ypos = Config.last_glob_ypos;
        }
        if( wparam == SIZE_MINIMIZED ) {
            info->minimized = TRUE;
            HideResources( TRUE );
        } else if( info->minimized ) {
            HideResources( FALSE );
            info->minimized = FALSE;
        } else if( wparam != SIZE_MAXIMIZED )  {
            GetWindowRect( hwnd, &area );
            Config.glob_xsize = area.right - area.left;
            Config.glob_ysize = area.bottom - area.top;
        }
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        break;
    case WM_CLOSE:
        PostMessage( hwnd, WM_COMMAND, HEAPMENU_EXIT, 0L );
        return( TRUE );
    case WM_QUERYENDSESSION:
        SaveConfigFile( FALSE );
        return( TRUE );
        break;
    case WM_DESTROY:
        FiniPaintProc();
        KillPushWin( info->list.title );
        SaveConfigFile( FALSE );
        if( info != NULL ) {
            FreeProcInstance_DLG( info->alloc_dlgproc );
            MemFree( info );
        }
        DestroyMonoFonts();
        CvrCtl3dUnregister( Instance );
        CvrCtl3DFini( Instance );
        WWinHelp( hwnd, "heapwalk.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;
    case WM_ACTIVATEAPP:
        if( wparam && !NoRefresh ) {
            if( info->doing_add ) {
                info->need_refresh = TRUE;
            } else {
                InitHeapList( info->list.box, TRUE );
            }
        }
        break;
    case WM_MENUSELECT:
        if( LOWORD( lparam & MF_POPUP ) ) {
            mh = GetMenu( hwnd );
            mh2 = GetSubMenu( mh, 6 );
            if( (HMENU)wparam == mh2  ) {
                ShowWindow( info->alloc_dialog, SW_SHOWNOACTIVATE );
            } else if( (HMENU)wparam != GetSubMenu( mh2, 3 ) &&
                        (HMENU)wparam != GetSubMenu( mh2, 4 ) &&
                        (HMENU)wparam != GetSubMenu( mh2, 5 ) ) {
                ShowWindow( info->alloc_dialog, SW_HIDE );
            }
        }
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        break;
    case WM_COMMAND:
        switch( wparam ) {
        case HEAPMENU_ABOUT:
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = HWAllocRCString( STR_ABOUT_NAME );
            ai.version = HWAllocRCString( STR_ABOUT_VERSION );
            ai.title = HWAllocRCString( STR_ABOUT_TITLE );
            DoAbout( &ai );
            HWFreeRCString( ai.title );
            HWFreeRCString( ai.version );
            HWFreeRCString( ai.name );
            break;
        case HEAPMENU_HELP_CONTENTS:
            WWinHelp( hwnd, "heapwalk.hlp", HELP_CONTENTS, 0 );
            break;
        case HEAPMENU_HELP_SRCH:
            WWinHelp( hwnd, "heapwalk.hlp", HELP_PARTIALKEY, (HELP_DATA)(LPCSTR)"" );
            break;
        case HEAPMENU_HELP_ON_HELP:
            WWinHelp( hwnd, "winhelp.hlp", HELP_HELPONHELP, 0 );
            break;
        case HEAPEX_LIST:
            if( !info->doing_add ) {
                if( HIWORD( lparam ) == LBN_DBLCLK ) {
                    ShowHeapObject( (HWND)LOWORD( lparam ) );
                }
            } else {
                if( HIWORD( lparam ) == LBN_SELCHANGE
                    || HIWORD( lparam ) == LBN_DBLCLK ) {
                    RefreshAdd( info->add_dialog, info->list.box );
                    RedrawBox( info->list.box, index );
                }
            }
            break;
        case HEAPMENU_GLOBAL_REFRESH:
            InitHeapList( info->list.box, TRUE );
            break;
        case HEAPMENU_FONT:
            if( ChooseMonoFont( hwnd ) ) {
                ResetFont( info );
            }
            break;
        case HEAPMENU_EXIT:
            DestroyWindow( hwnd );
            FreeHeapList();
            break;
        case HEAPMENU_DISPLAY_DPMI:
        case HEAPMENU_DISPLAY_ENTIRE:
        case HEAPMENU_DISPLAY_LRU:
        case HEAPMENU_DISPLAY_FREE:
            SetDisplayType( hwnd, &( info->list.title ), wparam );
            InitHeapList( info->list.box, FALSE );
            break;
        case HEAPMENU_SORT_ADDR:
        case HEAPMENU_SORT_HANDLE:
        case HEAPMENU_SORT_MODULE:
        case HEAPMENU_SORT_SIZE:
        case HEAPMENU_SORT_TYPE:
        case HEAPMENU_SORT_GRAN:
        case HEAPMENU_SORT_DPL:
        case HEAPMENU_SORT_FLAG:
        case HEAPMENU_SORT_LRU:
            mh = GetMenu( hwnd );
            CheckMenuItem( mh, GSortType, MF_UNCHECKED | MF_BYCOMMAND );
            CheckMenuItem( mh, wparam, MF_CHECKED | MF_BYCOMMAND );
            if( GSortType != wparam ) {
                GSortType = wparam;
                SortHeapList();
                ReDisplayHeapList( info->list.box, NULL );
            }
            break;
        case HEAPMENU_OBJECT_SHOW:
            ShowHeapObject( info->list.box );
            break;
        case HEAPMENU_OBJECT_DISCARD:
            if( GlobDiscardObj( info->list.box ) ) {
                InitHeapList( info->list.box, TRUE );
            }
            break;
        case HEAPMENU_OBJECT_NEWEST:
            if( GlobSetObjPos( info->list.box, FALSE ) ) {
                if( GSortType == HEAPMENU_SORT_LRU ) {
                    InitHeapList( info->list.box, TRUE );
                }
            }
            break;
        case HEAPMENU_OBJECT_OLDEST:
            if( GlobSetObjPos( info->list.box, TRUE ) ) {
                if( GSortType == HEAPMENU_SORT_LRU ) {
                    InitHeapList( info->list.box, TRUE );
                }
            }
            break;
        case HEAPMENU_OBJECT_GET_SELECTOR:
            ShowSelector( info->list.box );
            break;
        case HEAPMENU_GLOBAL_HEAPINFO:
            DisplayGlobHeapInfo( hwnd );
            break;
        case HEAPMENU_GLOBAL_MEMORYINFO:
            DisplayMemManInfo( hwnd );
            break;
        case HEAPMENU_GLOBAL_COMPACT:
            GlobalCompact( 0 );
            InitHeapList( info->list.box, TRUE );
            break;
        case HEAPMENU_GLOBAL_COMP_DISC:
            GlobalCompact( -1 );
            InitHeapList( info->list.box, TRUE );
            break;
        case HEAPMENU_GLOBAL_CODE_SIZE:
            dlgproc = MakeProcInstance_DLG( SetCodeDlgProc, Instance );
            JDialogBox( Instance, "CODE_AREA_DLG", hwnd, dlgproc );
            FreeProcInstance_DLG( dlgproc );
            break;
        case HEAPMENU_FILE_SAVE:
            InitHeapList( info->list.box, TRUE );
            SaveListBox( SLB_SAVE_TMP, PutOutGlobalHeader, DumpGlobalLine, Config.gfname, HeapWalkName, hwnd, info->list.box );
            break;
        case HEAPMENU_FILE_SAVE_TO:
            InitHeapList( info->list.box, TRUE );
            SaveListBox( SLB_SAVE_AS, PutOutGlobalHeader, DumpGlobalLine, Config.gfname, HeapWalkName, hwnd, info->list.box );
            break;
        case HEAPMENU_SAVE_CONFIG:
            SaveConfigFile( TRUE );
            break;
        case HEAPMENU_CONFIGURE:
            HWConfigure();
            break;
        case HEAPMENU_LOCAL_MONITOR:
            index = CheckForLocalSelect( info );
            if( index != LB_ERR ) {
                BeginMonitor( HeapList[index] );
            }
            break;
        case HEAPMENU_COMPACT_AND_LOCALWALK:
            LocalCompact( -1 );
            /* fall through */
        case HEAPMENU_LOCAL_LOCALWALK:
            index = CheckForLocalSelect( info );
            if( index != LB_ERR ) {
                LocalWalk( HeapList[index] );
            }
            break;
        case HEAPMENU_GDI_LOCALWALK:
            if( GetDGroupItem( "GDI", &hl ) ) {
                LocalWalk( &hl );
            }
            break;
        case HEAPMENU_USER_LOCALWALK:
            if( GetDGroupItem( "USER", &hl ) ) {
                LocalWalk( &hl );
            }
            break;
        case HEAPMENU_FREE_ALL:
            MyFreeAllMem();
            UpdateAllocInfo( info->alloc_dialog );
            PaintAllWindows();
            break;
        case HEAPMENU_FREE_1K:
        case HEAPMENU_FREE_2K:
        case HEAPMENU_FREE_5K:
        case HEAPMENU_FREE_10K:
        case HEAPMENU_FREE_25K:
        case HEAPMENU_FREE_50K:
            hourglass = LoadCursor( NULL, IDC_WAIT );
            SetCapture( hwnd );
            oldcursor= SetCursor( hourglass );
            FreeSomeMem( wparam );
            UpdateAllocInfo( info->alloc_dialog );
            SetCursor( oldcursor );
            ReleaseCapture();
            PaintAllWindows();
            break;
        case HEAPMENU_ALLOC_1K:
        case HEAPMENU_ALLOC_2K:
        case HEAPMENU_ALLOC_5K:
        case HEAPMENU_ALLOC_10K:
        case HEAPMENU_ALLOC_25K:
        case HEAPMENU_ALLOC_50K:
            hourglass = LoadCursor( NULL, IDC_WAIT );
            SetCapture( hwnd );
            oldcursor= SetCursor( hourglass );
            AllocMore( wparam );
            UpdateAllocInfo( info->alloc_dialog );
            SetCursor( oldcursor );
            ReleaseCapture();
            PaintAllWindows();
            break;
        case HEAPMENU_ALLOC_ALL:
        case HEAPMENU_ALLOC_BUT_1K:
        case HEAPMENU_ALLOC_BUT_2K:
        case HEAPMENU_ALLOC_BUT_5K:
        case HEAPMENU_ALLOC_BUT_10K:
        case HEAPMENU_ALLOC_BUT_25K:
        case HEAPMENU_ALLOC_BUT_50K:
            hourglass = LoadCursor( NULL, IDC_WAIT );
            SetCapture( hwnd );
            oldcursor= SetCursor( hourglass );
            AllocAllBut( wparam );
            UpdateAllocInfo( info->alloc_dialog );
            SetCursor( oldcursor );
            ReleaseCapture();
            PaintAllWindows();
            break;
        case HEAPMENU_ALLOC_NK:
        case HEAPMENU_ALLOC_BUT_NK:
        case HEAPMENU_FREE_NK:
            DoNBytes( hwnd, wparam );
            UpdateAllocInfo( info->alloc_dialog );
            PaintAllWindows();
            break;
        case HEAPMENU_ADD:
            info->add_dialog = StartAdd( hwnd, &info->list );
            if( info->add_dialog != NULL ) {
                info->doing_add = TRUE;
                info->need_refresh = FALSE;
            } else {
                ErrorBox( hwnd, STR_UNABLE_TO_ADD,
                          MB_OK| MB_ICONINFORMATION );
            }
            break;
        }
        break;
    case WM_USER:
        /* an owned window is being destroyed make sure
         * Windows doesn't take the focus away from us*/
        NoRefresh = TRUE;
        SetFocus( hwnd );
        NoRefresh = FALSE;
        break;
    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( FALSE );

} /* HeapWalkProc */
Example #23
0
static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct TFtMgrData *dat = (struct TFtMgrData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		{
			TCITEM tci = {0};
			HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);

			TranslateDialogDefault(hwnd);
			Window_SetIcon_IcoLib(hwnd, SKINICON_EVENT_FILE);

			dat = (struct TFtMgrData *)mir_calloc(sizeof(struct TFtMgrData));

			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);

			dat->hhkPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwnd, M_PRESHUTDOWN);

			dat->hwndIncoming = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
			dat->hwndOutgoing = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
			ShowWindow(dat->hwndIncoming, SW_SHOW);

			tci.mask = TCIF_PARAM|TCIF_TEXT;
			tci.pszText = TranslateT("Incoming");
			tci.lParam = (LPARAM)dat->hwndIncoming;
			TabCtrl_InsertItem(hwndTab, 0, &tci);
			tci.pszText = TranslateT("Outgoing");
			tci.lParam = (LPARAM)dat->hwndOutgoing;
			TabCtrl_InsertItem(hwndTab, 1, &tci);

			// Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_");
			SAVEWINDOWPOS swp;
			swp.hwnd = hwnd; swp.hContact = NULL; swp.szModule = "SRFile"; swp.szNamePrefix = "FtMgrDlg_";
			CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp);

			// Fall through to setup initial placement
		}
	case WM_SIZE:
		{
			RECT rc, rcButton;
			HDWP hdwp;
			HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);

			GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rcButton);
			OffsetRect(&rcButton, -rcButton.left, -rcButton.top);

			GetClientRect(hwnd, &rc);
			InflateRect(&rc, -6, -6);

			hdwp = BeginDeferWindowPos(3);

			hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
			hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);

			rc.bottom -= rcButton.bottom + 5;

			hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER);

			EndDeferWindowPos(hdwp);

			GetWindowRect(hwndTab, &rc);
			MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2);
			TabCtrl_AdjustRect(hwndTab, FALSE, &rc);
			InflateRect(&rc, -5, -5);

			hdwp = BeginDeferWindowPos(2);

			hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);
			hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);

			EndDeferWindowPos(hdwp);

			break;
		}

	case WM_MOUSEWHEEL:
		if (IsWindowVisible(dat->hwndIncoming)) SendMessage(dat->hwndIncoming, msg, wParam, lParam);
		if (IsWindowVisible(dat->hwndOutgoing)) SendMessage(dat->hwndOutgoing, msg, wParam, lParam);
		break;

	case WM_FT_SELECTPAGE:
		{
			TCITEM tci = {0};
			HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);

			if (TabCtrl_GetCurSel(hwndTab) == (int)wParam) break;

			tci.mask = TCIF_PARAM;

			TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
			ShowWindow((HWND)tci.lParam, SW_HIDE);

			TabCtrl_SetCurSel(hwndTab, wParam);

			TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
			ShowWindow((HWND)tci.lParam, SW_SHOW);
		}
		break;

	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
			lpmmi->ptMinTrackSize.x = 300;
			lpmmi->ptMinTrackSize.y = 400;
			return 0;
		}

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			PostMessage(hwnd, WM_CLOSE , 0, 0);
			break;

		case IDC_CLEAR:
			PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0);
			PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0);
			break;
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case IDC_TABS:
			{
				HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);
				switch (((LPNMHDR)lParam)->code) {
				case TCN_SELCHANGING:
					{
						TCITEM tci = {0};
						tci.mask = TCIF_PARAM;
						TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
						ShowWindow((HWND)tci.lParam, SW_HIDE);
						break;
					}

				case TCN_SELCHANGE:
					{
						TCITEM tci = {0};
						tci.mask = TCIF_PARAM;
						TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
						ShowWindow((HWND)tci.lParam, SW_SHOW);
						break;
					}
				}
				break;
			}
		}
		break;

	case M_PRESHUTDOWN:
		SendMessage(dat->hwndIncoming, M_PRESHUTDOWN, 0, 0);
		SendMessage(dat->hwndOutgoing, M_PRESHUTDOWN, 0, 0);
		DestroyWindow(hwnd);
		break;

	case WM_CLOSE:
		ShowWindow(hwnd, SW_HIDE);
		if (db_get_b(NULL, "SRFile", "AutoClear", 1)) {
			PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0);
			PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0);
		}
		return TRUE; /* Disable default IDCANCEL notification */

	case WM_DESTROY:
		UnhookEvent(dat->hhkPreshutdown);
		Window_FreeIcon_IcoLib(hwnd);
		DestroyWindow(dat->hwndIncoming);
		DestroyWindow(dat->hwndOutgoing);
		mir_free(dat);
		SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
		Utils_SaveWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_");
		break;

	case WM_ACTIVATE:
		dat->errorState = TBPF_NOPROGRESS;
		wParam = 1;
		break;

	case WM_SHOWWINDOW:
		if ( !wParam) { // hiding
			KillTimer(hwnd, 1);
			break;
		}
		lParam = 0;

	case WM_TIMER:
		if (pTaskbarInterface) {
			SetTimer(hwnd, 1, 400, NULL);
			if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED))
				dat->errorState = TBPF_ERROR;

			TFtProgressData prg = {0};
			SendMessage(dat->hwndIncoming, M_CALCPROGRESS, (WPARAM)&prg, 0);
			SendMessage(dat->hwndOutgoing, M_CALCPROGRESS, (WPARAM)&prg, 0);
			if (dat->errorState) {
				pTaskbarInterface->SetProgressState(hwnd, dat->errorState);
				if ( !prg.run)
					pTaskbarInterface->SetProgressValue(hwnd, 1, 1);
			}
			else if (prg.run)
				pTaskbarInterface->SetProgressState(hwnd, TBPF_NORMAL);
			else if (prg.init || prg.scan)
				pTaskbarInterface->SetProgressState(hwnd, TBPF_INDETERMINATE);
			else {
				pTaskbarInterface->SetProgressState(hwnd, TBPF_NOPROGRESS);
				KillTimer(hwnd, 1);
			}

			if (prg.run)
				pTaskbarInterface->SetProgressValue(hwnd, prg.totalProgress, prg.totalBytes);
		}
		break;
	}

	return FALSE;
}
Example #24
0
INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hwndDlg, IDC_LANGUAGES);

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		ComboBox_ResetContent(hwndList);
		EnumLangpacks(InsertPackItemEnumProc, (WPARAM)hwndList, (LPARAM)0);
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_LANGEMAIL:
			{
				char buf[512];
				mir_strcpy(buf, "mailto:");
				if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], _countof(buf) - 7))
					Utils_OpenUrl(buf);
			}
			break;

		case IDC_MORELANG:
			Utils_OpenUrl("http://wiki.miranda-ng.org/index.php?title=Langpacks/en#Download");
			break;

		case IDC_LANGUAGES:
			if (HIWORD(wParam) == CBN_SELCHANGE) {
				int idx = ComboBox_GetCurSel(hwndList);
				LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, idx);
				DisplayPackInfo(hwndDlg, pack);
				if (!(pack->flags & LPF_ENABLED))
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), (pack->flags & LPF_ENABLED) && !(pack->flags & LPF_DEFAULT));
			}
			break;

		case IDC_RELOAD:
			{
				EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), FALSE);
				int idx = ComboBox_GetCurSel(hwndList);
				LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, idx);
				ReloadLangpack(pack->tszFullPath);
				DisplayPackInfo(hwndDlg, pack);
				EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), TRUE);
			}
			break;
		}
		break;

	case WM_NOTIFY:
		if (LPNMHDR(lParam)->code == PSN_APPLY) {
			TCHAR tszPath[MAX_PATH]; tszPath[0] = 0;
			int idx = ComboBox_GetCurSel(hwndList);
			int count = ComboBox_GetCount(hwndList);
			for (int i = 0; i < count; i++) {
				LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, i);
				if (i == idx) {
					db_set_ts(NULL, "Langpack", "Current", pack->tszFileName);
					mir_tstrcpy(tszPath, pack->tszFullPath);
					pack->flags |= LPF_ENABLED;
				}
				else pack->flags &= ~LPF_ENABLED;
			}

			if (tszPath[0]) {
				ReloadLangpack(tszPath);

				if (LPPSHNOTIFY(lParam)->lParam == IDC_APPLY) {
					HWND hwndParent = GetParent(hwndDlg);
					PostMessage(hwndParent, WM_CLOSE, 1, 0);
					mir_forkthread(ReloadOptions, hwndParent);
				}
			}
		}
		break;

	case WM_DESTROY:
		int count = ListBox_GetCount(hwndList);
		for (int i = 0; i < count; i++)
			delete (LANGPACK_INFO*)ListBox_GetItemData(hwndList, i);
		ComboBox_ResetContent(hwndList);
		return TRUE;
	}
	return FALSE;
}
Example #25
0
LRESULT CALLBACK outwnd_handler(HWND hwnd,UINT msg,WPARAM wParam, LPARAM lParam)
{
	
	switch(msg)	{
	case WM_ACTIVATEAPP:
		// The application z-ordering has change
		// foreground application wParm will be
		OutputActive = (BOOL)wParam;
		break;

	case WM_CREATE:	{
			SCROLLINFO si;
			si.cbSize = sizeof(SCROLLINFO);
			si.fMask = SIF_RANGE | SIF_POS;
			si.nMin = 0;
			si.nMax = max_scroll_pos;
			si.nPos = max_scroll_pos;
			SetScrollInfo(hwnd, SB_VERT, &si, 1 );
		}
		break;

	case WM_TIMER:
		if (scroll_wait)
			PostMessage(hwnd, WM_MOUSEMOVE, 0, last_mousemove);

		if ( Outwnd_changed )	{
			RECT client;
			GetClientRect(hOutputWnd, &client);
			client.top = client.bottom - nTextHeight;
			InvalidateRect(hOutputWnd,&client,0);
		}

		scroll_wait = 0;
		break;

	case WM_COMMAND:	{
		int z;

		z = LOWORD(wParam);
		if (z >= ID_FILTER && z < ID_FILTER + outwnd_filter_count)
		{
			z -= ID_FILTER;
			outwnd_filter[z]->state = !outwnd_filter[z]->state;

			if ( !stricmp( outwnd_filter[z]->name, "error" ) )	{
				outwnd_filter[z]->state = 1;
			} else if ( !stricmp( outwnd_filter[z]->name, "general" ) )	{
				outwnd_filter[z]->state = 1;
			} else if ( !stricmp( outwnd_filter[z]->name, "warning" ) )	{
				outwnd_filter[z]->state = 1;
			}
			save_filter_info();
			break;
		}

		switch (z)
		{
			case ID_COPY:
				outwnd_copy_marked_selection(hwnd);
				break;

			/*
			case ID_FIND:
				if (DialogBox(GetModuleHandle(NULL), "FIND_DIALOG", hOutputWnd,
					(int (__stdcall *)(void)) find_dlg_handler) == IDOK)
				{
					find_text_in_outwindow(mprintf_last_line, 0);
				}

				break;
				*/
		}
		break;
	}

	case WM_RBUTTONDOWN:	{
			HMENU h_menu = CreatePopupMenu();
			HMENU h_sub_menu = CreatePopupMenu();
			POINT pt;
			int i;

			for (i=0; i<outwnd_filter_count; i++)
			{
				UINT flags = MFT_STRING;	//MF_GRAYED;

				if ( !stricmp( outwnd_filter[i]->name, "error" ) )	{
					flags |= MF_GRAYED;
				} else if ( !stricmp( outwnd_filter[i]->name, "general" ) )	{
					flags |= MF_GRAYED;
				} else if ( !stricmp( outwnd_filter[i]->name, "warning" ) )	{
					flags |= MF_GRAYED;
				}

				if (outwnd_filter[i]->state)
					AppendMenu(h_sub_menu, flags | MF_CHECKED, ID_FILTER + i, outwnd_filter[i]->name);
				else
					AppendMenu(h_sub_menu, flags, ID_FILTER + i, outwnd_filter[i]->name);
			}

			AppendMenu(h_menu, MFT_STRING, ID_COPY, "&Copy\tEnter");
			AppendMenu(h_menu, MFT_STRING, ID_FIND, "&Find Text");
			AppendMenu(h_menu, MF_POPUP, (unsigned int) h_sub_menu, "Filter &Messages");
			pt.x = LOWORD(lParam);
			pt.y = HIWORD(lParam);
			ClientToScreen(hwnd, &pt);

			TrackPopupMenu(h_menu, 0, pt.x, pt.y, 0, hwnd, NULL);
			DestroyMenu(h_menu);
			break;
		}
		
	case WM_LBUTTONDOWN:
		fix_marking_coords(marking_started_x, marking_started_y, lParam);
		SetCapture(hwnd);  // monopolize mouse
		marking_active = 1;
		outwnd_update_marking(lParam, hwnd);
		break;

	case WM_MOUSEMOVE:
		last_mousemove = lParam;
		if (marking_active){
			outwnd_update_marking(lParam, hwnd);
		}
		break;

	case WM_LBUTTONUP:
		if (marking_active)
		{
			ReleaseCapture();
			marking_active = 0;
			outwnd_update_marking(lParam, hwnd);
		}
		break;
	
	case WM_VSCROLL:	{
			SCROLLINFO si;
			int vpos = GetScrollPos( hwnd, SB_VERT );
			int old_vpos=vpos;
			switch (LOWORD(wParam))	{
			case SB_LINEDOWN:
				vpos++;
				break;
			case SB_LINEUP:
				vpos--;
				break;
			case SB_THUMBPOSITION:
				vpos = HIWORD(wParam);
				break;
			case SB_THUMBTRACK:
				vpos = HIWORD(wParam);
				break;
			case SB_PAGEDOWN:
				vpos += nCharRows;
				break;
			case SB_PAGEUP:
				vpos -= nCharRows;
				break;
			}
			if ( vpos < 0 ) vpos = 0;
			else if ( vpos > max_scroll_pos ) vpos = max_scroll_pos;
			si.cbSize = sizeof(SCROLLINFO);
			si.fMask = SIF_POS;
			si.nPos = vpos;
			SetScrollInfo(hwnd, SB_VERT, &si, 1 );
			ScrollWindow(hwnd,0,(old_vpos-vpos)*nTextHeight,NULL,NULL);
			UpdateWindow(hOutputWnd);
			//InvalidateRect(hOutputWnd,NULL,0);
		}
		break;

	case WM_KEYDOWN:	{
			SCROLLINFO si;
			int vpos = GetScrollPos( hwnd, SB_VERT );
			int old_vpos=vpos;
			int nVirtKey = (int) wParam;  // virtual-key code
			switch(nVirtKey)	{
			case VK_DOWN:
			case VK_RIGHT:
				vpos++;
				break;
			case VK_UP:
			case VK_LEFT:
				vpos--;
				break;
			case VK_NEXT:
				vpos += nCharRows;
				break;
			case VK_PRIOR:
				vpos -= nCharRows;
				break;
			case VK_END:
				vpos = 0;
				break;
			case VK_HOME:
				vpos = max_scroll_pos;
				break;
			case VK_RETURN:
				outwnd_copy_marked_selection(hwnd);
				break;
			case UP_FAST:  // special value we define
				vpos -= 5;
				break;
			case DOWN_FAST:  // special value we define
				vpos += 5;
				break;
			}
			
			if ( vpos < 0 ) vpos = 0;
			else if ( vpos > max_scroll_pos ) vpos = max_scroll_pos;
			si.cbSize = sizeof(SCROLLINFO);
			si.fMask = SIF_POS;
			si.nPos = vpos;
			SetScrollInfo(hwnd, SB_VERT, &si, 1 );
			ScrollWindow(hwnd, 0, (old_vpos-vpos)*nTextHeight, NULL, NULL);
			UpdateWindow(hOutputWnd);
			//InvalidateRect(hOutputWnd,NULL,0);
		}
		break;

	case WM_SIZE:
		InvalidateRect(hOutputWnd,NULL,0);
		break;

	case WM_PAINT:
		outwnd_paint(hwnd);
		break;

	case WM_DESTROY:
		outwnd_disabled = 1;
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
		break;
	}

	return 0;
}
Example #26
0
LRESULT CALLBACK
w1394_AppWndProc (
                  HWND    hWnd,
                  UINT    iMsg,
                  WPARAM  wParam,
                  LPARAM  lParam)
/*++

Routine Description:

    This is the application main WndProc. Here we will handle
    all messages sent to the application.

--*/
{
    ULONG   i;

    switch(iMsg) 
    {

        case WM_CREATE:

#ifdef LOGGING
            if (!DoNT5Checking()) {

                PostMessage(hWnd, WM_DESTROY, 0, 0);
                return DefWindowProc(hWnd, iMsg, wParam, lParam);
            }
#endif
            // create an edit control for the main app.
            g_hWndEdit = CreateWindow( 
                "edit",
                NULL,
                WS_CHILD | WS_VISIBLE | WS_VSCROLL |
                WS_BORDER | ES_LEFT | ES_MULTILINE | ES_WANTRETURN |
                ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_READONLY,
                0,
                0,
                0,
                0,
                hWnd,
                (HMENU) EDIT_ID,
                g_hInstance,
                NULL);

            //
            // set a timer, 1 time a second, we will print 
            // loopback test results with this
            //
            SetTimer (hWnd, APP_TIMER_ID, 1000, NULL);

            SelectedDevice = NULL;

        break; // WM_CREATE

        case WM_DESTROY:

            PostQuitMessage (0);
            break; // WM_DESTROY

        case WM_SIZE:

            MoveWindow (g_hWndEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
            break; // WM_SIZE

        case WM_COMMAND:

            switch(LOWORD(wParam))
            {

                case EDIT_ID:

                    switch (HIWORD(wParam)) {

                        // check fot text overflow in edit control
                        case EN_ERRSPACE:
                        case EN_MAXTEXT:

                            // just clear out the buffer
                            SetWindowText(g_hWndEdit, "\0");
                            break;

                        default:
                            break;
                    }
                break;

                case IDM_CLEAR_BUFFER:

                    SetWindowText(g_hWndEdit, "\0");
                    break; // IDM_CLEAR_BUFFER

                case IDM_ABOUT:

                    DialogBox (
                        g_hInstance, 
                        "IDD_ABOUTBOX", 
                        hWnd, 
                        w1394_AboutDlgProc);

                    break; // IDM_ABOUT

                case IDM_EXIT:

                    SendMessage(hWnd, WM_DESTROY, 0, 0L);
                    break; // IDM_EXIT

                case IDM_ADD_VIRTUAL_DRIVER:

                    w1394_AddVirtualDriver (g_hWndEdit);

                    break; // IDM_ADD_VIRTUAL_DRIVER

                case IDM_REMOVE_VIRTUAL_DRIVER:

                    w1394_RemoveVirtualDriver (g_hWndEdit);

                    break; // IDM_REMOVE_VIRTUAL_DRIVER

                case IDM_SELECT_VIRTUAL_TEST_DEVICE:  
                    
                    FillDeviceList (hWnd, (LPGUID)&GUID_KMDF_VDEV, &DeviceData);

                    if (DeviceData.numDevices) 
                    {

                        w1394_SelectVirtualTestDevice(g_hWndEdit);
                    }
                    else
                    {

                        TRACE(
                            TL_TRACE, 
                            (g_hWndEdit, 
                            "No available virtual test devices.\r\n"));
                    }
                    break; // IDM_SELECT_VIRT_TEST_DEVICE

                case IDM_ALLOCATE_ADDRESS_RANGE:

                    w1394_AllocateAddressRange(g_hWndEdit, SelectedDevice);

                    break; // IDM_ALLOCATE_ADDRESS_RANGE

                case IDM_FREE_ADDRESS_RANGE:

                    w1394_FreeAddressRange(g_hWndEdit, SelectedDevice);

                    break; // IDM_FREE_ADDRESS_RANGE

                case IDM_ASYNC_READ:

                    w1394_AsyncRead(g_hWndEdit, SelectedDevice);

                    break; // IDM_ASYNC_READ

                case IDM_ASYNC_WRITE:

                    w1394_AsyncWrite(g_hWndEdit, SelectedDevice);

                    break; // IDM_ASYNC_WRITE

                case IDM_ASYNC_LOCK:

                    w1394_AsyncLock(g_hWndEdit, SelectedDevice);

                    break; // IDM_ASYNC_LOCK

                case IDM_ASYNC_STREAM:

                    w1394_AsyncStream(g_hWndEdit, SelectedDevice);

                    break; // IDM_ASYNC_STREAM
               
                case IDM_ISOCH_ALLOCATE_BANDWIDTH:

                    w1394_IsochAllocateBandwidth(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_ALLOCATE_BANDWIDTH

                case IDM_ISOCH_ALLOCATE_CHANNEL:

                    w1394_IsochAllocateChannel(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_ALLOCATE_CHANNEL

                case IDM_ISOCH_ALLOCATE_RESOURCES:

                    w1394_IsochAllocateResources(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_ALLOCATE_RESOURCES

                case IDM_ISOCH_ATTACH_BUFFERS:

                    w1394_IsochAttachBuffers(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_ATTACH_BUFFERS

                case IDM_ISOCH_DETACH_BUFFERS:

                    w1394_IsochDetachBuffers(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_DETACH_BUFFERS

                case IDM_ISOCH_FREE_BANDWIDTH:

                    w1394_IsochFreeBandwidth(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_FREE_BANDWIDTH

                case IDM_ISOCH_FREE_CHANNEL:

                    w1394_IsochFreeChannel(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_FREE_CHANNEL

                case IDM_ISOCH_FREE_RESOURCES:

                    w1394_IsochFreeResources(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_FREE_RESOURCES

                case IDM_ISOCH_LISTEN:

                    w1394_IsochListen(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_LISTEN

                case IDM_ISOCH_QUERY_CURRENT_CYCLE_TIME:

                    w1394_IsochQueryCurrentCycleTime(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_QUERY_CURRENT_CYCLE_TIME

                case IDM_ISOCH_QUERY_RESOURCES:

                    w1394_IsochQueryResources(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_QUERY_RESOURCES

                case IDM_ISOCH_SET_CHANNEL_BANDWIDTH:

                    w1394_IsochSetChannelBandwidth(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_SET_CHANNEL_BANDWIDTH

                case IDM_ISOCH_STOP:

                    w1394_IsochStop(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_STOP

                case IDM_ISOCH_TALK:

                    w1394_IsochTalk(g_hWndEdit, SelectedDevice);

                    break; // IDM_ISOCH_TALK

                case IDM_BUS_RESET:

                    w1394_BusReset(g_hWndEdit, SelectedDevice);

                    break; // IDM_BUS_RESET

                case IDM_GET_GENERATION_COUNT:

                    w1394_GetGenerationCount(g_hWndEdit, SelectedDevice);

                    break; // IDM_GET_GENERATION_COUNT

                case IDM_GET_LOCAL_HOST_INFORMATION:

                    w1394_GetLocalHostInfo(g_hWndEdit, SelectedDevice);

                    break; // IDM_GET_LOCAL_HOST_INFORMATION


                case IDM_GET_ADDRESS_FROM_DEVICE_OBJECT:

                    w1394_Get1394AddressFromDeviceObject(g_hWndEdit, SelectedDevice);

                    break; // IDM_GET_ADDRESS_FROM_DEVICE_OBJECT

                case IDM_CONTROL:

                    w1394_Control(g_hWndEdit, SelectedDevice);

                    break; // IDM_CONTROL

                case IDM_GET_MAX_SPEED_BETWEEN_DEVICES:

                    w1394_GetMaxSpeedBetweenDevices(g_hWndEdit, SelectedDevice);

                    break; // IDM_GET_MAX_SPEED_BETWEEN_DEVICES

                case IDM_GET_CONFIGURATION_INFORMATION:

                    w1394_GetConfigurationInfo(g_hWndEdit, SelectedDevice);

                    break; // IDM_GET_CONFIGURATION_INFORMATION

                case IDM_SET_DEVICE_XMIT_PROPERTIES:

                    w1394_SetDeviceXmitProperties(g_hWndEdit, SelectedDevice);

                    break; // IDM_SET_DEVICE_XMIT_PROPERTIES

                case IDM_SEND_PHY_CONFIG_PACKET:

                    w1394_SendPhyConfigPacket(g_hWndEdit, SelectedDevice);

                    break; // IDM_SEND_PHY_CONFIG_PACKET

                case IDM_BUS_RESET_NOTIFICATION:

                    w1394_BusResetNotification(g_hWndEdit, SelectedDevice);

                    break; // IDM_BUS_RESET_NOTIFICATION

                case IDM_SET_LOCAL_HOST_PROPERTIES:

                    w1394_SetLocalHostInfo(g_hWndEdit, SelectedDevice);

                    break; // IDM_SET_LOCAL_HOST_PROPERTIES

                default:
                    break; // default
            }
            break; // WM_COMMAND

        case NOTIFY_DEVICE_CHANGE:
            TRACE(TL_TRACE, (g_hWndEdit, "NOTIFY_DEVICE_CHANGE\r\n"));

            FillDeviceList (hWnd, (LPGUID)&GUID_KMDF_VDEV, &DeviceData);

            TRACE(
                TL_TRACE, 
                (g_hWndEdit, 
                "number Virtual Devices = 0x%x\r\n", 
                DeviceData.numDevices));

            for (i=0; i < DeviceData.numDevices; i++) 
            {
                TRACE(
                    TL_TRACE, 
                    (g_hWndEdit, 
                    "DeviceName[0x%x] = %s\r\n", 
                    i, 
                    DeviceData.deviceList[i].DeviceName));
            }

            if (!SelectedDevice && DeviceData.numDevices) 
            {
                SelectedDevice = DeviceData.deviceList[0].DeviceName;
                TRACE(
                    TL_TRACE, 
                    (g_hWndEdit, 
                    "Selected Device = %s\r\n", 
                    SelectedDevice));
            }
            
            break; // NOTIFY_DEVICE_CHANGE

        case NOTIFY_BUS_RESET:
            TRACE(TL_TRACE, (g_hWndEdit, "BUS RESET!!!\r\n"));
            break; // NOTIFY_BUS_RESET

        default:
            break;
    } // switch iMsg

    return DefWindowProc(hWnd, iMsg, wParam, lParam);
} // w1394_AppWndProc
Example #27
0
BOOL ConfigDlg::OnInitDialog() 
{
    
    CDialog::OnInitDialog();
    ListView_SetExtendedListViewStyleEx( m_List, LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT,LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);

    m_List.InsertColumn( 0, "PDB Path", LVCFMT_LEFT, 500 );
    m_bChanged = false;
    //////////////////////////////////////////////////////////////////////////
    CString csExeName;
    GetModuleFileName( 0, csExeName.GetBuffer( MAX_PATH), MAX_PATH );
    csExeName.ReleaseBuffer();
    csExeName = csExeName.MakeLower();
    csExeName.Replace( _T(".exe"), _T("Mem.ini"));
    if( PathFileExists( csExeName ))
    {
        CStdioFile File;
        File.Open( csExeName,CFile::modeRead );
        CString csLine;
        while( File.ReadString( csLine ))
        {
            csLine.Replace( _T("\r"), _T(""));
            m_List.InsertItem( 0, csLine );
            m_csPath += csLine + _T(";");            
        }
        File.Close();
    }
    else
    {
        CString csSystemPath;
        if (GetEnvironmentVariable("SYSTEMROOT", csSystemPath.GetBuffer( MAX_PATH), MAX_PATH) > 0)
        {
            csSystemPath.ReleaseBuffer();
            csSystemPath += _T("\\system32");
        }
        else
        {
            csSystemPath.ReleaseBuffer();
        }        
        m_List.InsertItem( 0, csSystemPath );
        csSystemPath += _T("\r\n");     
        
        CString SymbolPath;
        if (GetEnvironmentVariable("_NT_SYMBOL_PATH", SymbolPath.GetBuffer( MAX_PATH), MAX_PATH) > 0)
        {
            SymbolPath.ReleaseBuffer();
            csSystemPath += SymbolPath + _T("\r\n");
            m_List.InsertItem( 0, SymbolPath );                

        }
        else
        {
            csSystemPath.ReleaseBuffer();
        }
        //add the hook dll path so that it can load the pdb of hookdll
        CString csDllPath;
        HMODULE hHookDll = GetModuleHandle( _T("HookDll.dll"));
        if( GetModuleFileName( hHookDll, csDllPath.GetBuffer( MAX_PATH), MAX_PATH ))
        {
            csDllPath.ReleaseBuffer();
            int nPos = csDllPath.ReverseFind( _T('\\'));
            if( 0 < nPos )
            {
                csDllPath = csDllPath.Left( nPos + 1 );
                m_List.InsertItem( 0, csDllPath );
            }
            
        }
    }
    m_EditCtrl.Create( WS_CHILD|WS_BORDER, CRect(0,0,0,0), &m_List, 1 );
    g_HookType = HT_MEMORY;
    ((CButton*)GetDlgItem( IDC_RADIO_MEM ))->SetCheck( BST_CHECKED );
    SetDlgItemText( IDC_EDIT1, _T("20"));


#if _DEBUG
    SetAppMode();
    if(g_IS_TEST_APP)
    {
        LoadSymbols();        
        PostMessage( WM_CLOSE,0,0);
    }
#endif
    return TRUE;
}
Example #28
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
                         LPARAM lParam) {
  static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL,
      stopWnd = NULL, editWnd = NULL;
  static WNDPROC editWndOldProc = NULL;

  // Static members used for the find dialog.
  static FINDREPLACE fr;
  static WCHAR szFindWhat[80] = {0};
  static WCHAR szLastFindWhat[80] = {0};
  static bool findNext = false;
  static bool lastMatchCase = false;

  int wmId, wmEvent;
  PAINTSTRUCT ps;
  HDC hdc;

  if (hWnd == editWnd) {
    // Callback for the edit window
    switch (message) {
    case WM_CHAR:
      if (wParam == VK_RETURN && g_handler.get()) {
        // When the user hits the enter key load the URL
        CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
        wchar_t strPtr[MAX_URL_LENGTH+1] = {0};
        *((LPWORD)strPtr) = MAX_URL_LENGTH;
        LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
        if (strLen > 0) {
          strPtr[strLen] = 0;
          browser->GetMainFrame()->LoadURL(strPtr);
        }

        return 0;
      }
    }

    return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam,
                                   lParam);
  } else if (message == uFindMsg) {
    // Find event.
    LPFINDREPLACE lpfr = (LPFINDREPLACE)lParam;

    if (lpfr->Flags & FR_DIALOGTERM) {
      // The find dialog box has been dismissed so invalidate the handle and
      // reset the search results.
      hFindDlg = NULL;
      if (g_handler.get()) {
        g_handler->GetBrowser()->GetHost()->StopFinding(true);
        szLastFindWhat[0] = 0;
        findNext = false;
      }
      return 0;
    }

    if ((lpfr->Flags & FR_FINDNEXT) && g_handler.get())  {
      // Search for the requested string.
      bool matchCase = (lpfr->Flags & FR_MATCHCASE?true:false);
      if (matchCase != lastMatchCase ||
          (matchCase && wcsncmp(szFindWhat, szLastFindWhat,
              sizeof(szLastFindWhat)/sizeof(WCHAR)) != 0) ||
          (!matchCase && _wcsnicmp(szFindWhat, szLastFindWhat,
              sizeof(szLastFindWhat)/sizeof(WCHAR)) != 0)) {
        // The search string has changed, so reset the search results.
        if (szLastFindWhat[0] != 0) {
          g_handler->GetBrowser()->GetHost()->StopFinding(true);
          findNext = false;
        }
        lastMatchCase = matchCase;
        wcscpy_s(szLastFindWhat, sizeof(szLastFindWhat)/sizeof(WCHAR),
            szFindWhat);
      }

      g_handler->GetBrowser()->GetHost()->Find(0, lpfr->lpstrFindWhat,
          (lpfr->Flags & FR_DOWN)?true:false, matchCase, findNext);
      if (!findNext)
        findNext = true;
    }

    return 0;
  } else {
    // Callback for the main window
    switch (message) {
    case WM_CREATE: {
      // Create the single static handler class instance
      g_handler = new ClientHandler();
      g_handler->SetMainHwnd(hWnd);

      // Create the child windows used for navigation
      RECT rect;
      int x = 0;

      GetClientRect(hWnd, &rect);

      backWnd = CreateWindow(L"BUTTON", L"Back",
                              WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                              | WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
                              hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
      x += BUTTON_WIDTH;

      forwardWnd = CreateWindow(L"BUTTON", L"Forward",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                                | WS_DISABLED, x, 0, BUTTON_WIDTH,
                                URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
                                hInst, 0);
      x += BUTTON_WIDTH;

      reloadWnd = CreateWindow(L"BUTTON", L"Reload",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                                | WS_DISABLED, x, 0, BUTTON_WIDTH,
                                URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
                                hInst, 0);
      x += BUTTON_WIDTH;

      stopWnd = CreateWindow(L"BUTTON", L"Stop",
                              WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
                              | WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
                              hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
      x += BUTTON_WIDTH;

      editWnd = CreateWindow(L"EDIT", 0,
                              WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
                              ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
                              x, 0, rect.right - BUTTON_WIDTH * 4,
                              URLBAR_HEIGHT, hWnd, 0, hInst, 0);

      // Assign the edit window's WNDPROC to this function so that we can
      // capture the enter key
      editWndOldProc =
          reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
      SetWindowLongPtr(editWnd, GWLP_WNDPROC,
          reinterpret_cast<LONG_PTR>(WndProc));
      g_handler->SetEditHwnd(editWnd);
      g_handler->SetButtonHwnds(backWnd, forwardWnd, reloadWnd, stopWnd);

      rect.top += URLBAR_HEIGHT;

      CefWindowInfo info;
      CefBrowserSettings settings;
	 
      if (1||AppIsOffScreenRenderingEnabled()) {
        CefRefPtr<CefCommandLine> cmd_line = AppGetCommandLine();
        bool transparent =
            cmd_line->HasSwitch(cefclient::kTransparentPaintingEnabled);
		transparent=true;
        CefRefPtr<OSRWindow> osr_window =
            OSRWindow::Create(&g_main_browser_provider, transparent);
        osr_window->CreateWidget(hWnd, rect, hInst, szOSRWindowClass);
        info.SetAsOffScreen(osr_window->hwnd());
       // info.SetTransparentPainting(transparent ? TRUE : FALSE);
		info.SetTransparentPainting(TRUE);
        g_handler->SetOSRHandler(osr_window.get());
      } else {
        // Initialize window info to the defaults for a child window.
        info.SetAsChild(hWnd, rect);
      }

      // Creat the new child browser window
      CefBrowserHost::CreateBrowser(info, g_handler.get(),
	  "http://htzs.jiyoutang.com/source/upgrade/client/description.html", settings, NULL);

      return 0;
    }

    case WM_COMMAND: {
      CefRefPtr<CefBrowser> browser;
      if (g_handler.get())
        browser = g_handler->GetBrowser();

      wmId    = LOWORD(wParam);
      wmEvent = HIWORD(wParam);
      // Parse the menu selections:
      switch (wmId) {
      case IDM_ABOUT:
        DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
        return 0;
      case IDM_EXIT:
        if (g_handler.get())
          g_handler->CloseAllBrowsers(false);
        return 0;
      case ID_WARN_CONSOLEMESSAGE:
        if (g_handler.get()) {
          std::wstringstream ss;
          ss << L"Console messages will be written to "
              << std::wstring(CefString(g_handler->GetLogFile()));
          MessageBox(hWnd, ss.str().c_str(), L"Console Messages",
              MB_OK | MB_ICONINFORMATION);
        }
        return 0;
      case ID_WARN_DOWNLOADCOMPLETE:
      case ID_WARN_DOWNLOADERROR:
        if (g_handler.get()) {
          std::wstringstream ss;
          ss << L"File \"" <<
              std::wstring(CefString(g_handler->GetLastDownloadFile())) <<
              L"\" ";

          if (wmId == ID_WARN_DOWNLOADCOMPLETE)
            ss << L"downloaded successfully.";
          else
            ss << L"failed to download.";

          MessageBox(hWnd, ss.str().c_str(), L"File Download",
              MB_OK | MB_ICONINFORMATION);
        }
        return 0;
      case ID_FIND:
        if (!hFindDlg) {
          // Create the find dialog.
          ZeroMemory(&fr, sizeof(fr));
          fr.lStructSize = sizeof(fr);
          fr.hwndOwner = hWnd;
          fr.lpstrFindWhat = szFindWhat;
          fr.wFindWhatLen = sizeof(szFindWhat);
          fr.Flags = FR_HIDEWHOLEWORD | FR_DOWN;

          hFindDlg = FindText(&fr);
        } else {
          // Give focus to the existing find dialog.
          ::SetFocus(hFindDlg);
        }
        return 0;
      case IDC_NAV_BACK:   // Back button
        if (browser.get())
          browser->GoBack();
        return 0;
      case IDC_NAV_FORWARD:  // Forward button
        if (browser.get())
          browser->GoForward();
        return 0;
      case IDC_NAV_RELOAD:  // Reload button
        if (browser.get())
          browser->Reload();
        return 0;
      case IDC_NAV_STOP:  // Stop button
        if (browser.get())
          browser->StopLoad();
        return 0;
      case ID_TESTS_GETSOURCE:  // Test the GetSource function
        if (browser.get())
          RunGetSourceTest(browser);
        return 0;
      case ID_TESTS_GETTEXT:  // Test the GetText function
        if (browser.get())
          RunGetTextTest(browser);
        return 0;
      case ID_TESTS_POPUP:  // Test a popup window
        if (browser.get())
          RunPopupTest(browser);
        return 0;
      case ID_TESTS_REQUEST:  // Test a request
        if (browser.get())
          RunRequestTest(browser);
        return 0;
      case ID_TESTS_PLUGIN_INFO:  // Test plugin info
        if (browser.get())
          RunPluginInfoTest(browser);
        return 0;
      case ID_TESTS_ZOOM_IN:
        if (browser.get())
          ModifyZoom(browser, 0.5);
        return 0;
      case ID_TESTS_ZOOM_OUT:
        if (browser.get())
          ModifyZoom(browser, -0.5);
        return 0;
      case ID_TESTS_ZOOM_RESET:
        if (browser.get())
          browser->GetHost()->SetZoomLevel(0.0);
        return 0;
      case ID_TESTS_TRACING_BEGIN:
        g_handler->BeginTracing();
        return 0;
      case ID_TESTS_TRACING_END:
        g_handler->EndTracing();
        return 0;
      case ID_TESTS_PRINT:
        if(browser.get())
          browser->GetHost()->Print();
        return 0;
      case ID_TESTS_OTHER_TESTS:
        if (browser.get())
          RunOtherTests(browser);
        return 0;
      }
      break;
    }

    case WM_PAINT:
      hdc = BeginPaint(hWnd, &ps);
      EndPaint(hWnd, &ps);
      return 0;

    case WM_SETFOCUS:
      if (g_handler.get() && g_handler->GetBrowser()) {
        // Pass focus to the browser window
        CefWindowHandle hwnd =
            g_handler->GetBrowser()->GetHost()->GetWindowHandle();
        if (hwnd)
          PostMessage(hwnd, WM_SETFOCUS, wParam, NULL);
      }
      return 0;

    case WM_SIZE:
      // Minimizing resizes the window to 0x0 which causes our layout to go all
      // screwy, so we just ignore it.
      if (wParam != SIZE_MINIMIZED && g_handler.get() &&
          g_handler->GetBrowser()) {
        CefWindowHandle hwnd =
            g_handler->GetBrowser()->GetHost()->GetWindowHandle();
        if (hwnd) {
          // Resize the browser window and address bar to match the new frame
          // window size
          RECT rect;
          GetClientRect(hWnd, &rect);
          rect.top += URLBAR_HEIGHT;

          int urloffset = rect.left + BUTTON_WIDTH * 4;

          HDWP hdwp = BeginDeferWindowPos(1);
          hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset,
            0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER);
          hdwp = DeferWindowPos(hdwp, hwnd, NULL,
            rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
            SWP_NOZORDER);
          EndDeferWindowPos(hdwp);
        }
      }
      break;

    case WM_ERASEBKGND:
      if (g_handler.get() && g_handler->GetBrowser()) {
        CefWindowHandle hwnd =
            g_handler->GetBrowser()->GetHost()->GetWindowHandle();
        if (hwnd) {
          // Dont erase the background if the browser window has been loaded
          // (this avoids flashing)
          return 1;
        }
      }
      break;

    case WM_ENTERMENULOOP:
      if (!wParam) {
        // Entering the menu loop for the application menu.
        CefSetOSModalLoop(true);
      }
      break;

    case WM_EXITMENULOOP:
      if (!wParam) {
        // Exiting the menu loop for the application menu.
        CefSetOSModalLoop(false);
      }
      break;

    case WM_CLOSE:
      if (g_handler.get() && !g_handler->IsClosing()) {
        CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
        if (browser.get()) {
          // Notify the browser window that we would like to close it. This
          // will result in a call to ClientHandler::DoClose() if the
          // JavaScript 'onbeforeunload' event handler allows it.
          browser->GetHost()->CloseBrowser(false);

          // Cancel the close.
          return 0;
        }
      }

      // Allow the close.
      break;

    case WM_DESTROY:
      // Quitting CEF is handled in ClientHandler::OnBeforeClose().
      return 0;
    }

    return DefWindowProc(hWnd, message, wParam, lParam);
  }
}
Example #29
0
//-----------------------------------------------------------------------------
// Name: OnSliderChanged()  
// Desc: Called when the dialog's slider bars are changed by the user, or need
//       updating
//-----------------------------------------------------------------------------
VOID OnSliderChanged( HWND hDlg )
{
    TCHAR strBuffer[10];

    // Get handles to dialog items
    HWND hFreqSlider   = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
    HWND hPanSlider    = GetDlgItem( hDlg, IDC_PAN_SLIDER );
    HWND hVolumeSlider = GetDlgItem( hDlg, IDC_VOLUME_SLIDER );

    // Get the position of the sliders
    LONG lFrequency = (LONG)SendMessage( hFreqSlider,   TBM_GETPOS, 0, 0 ) * 1L;
    LONG lPan       = (LONG)SendMessage( hPanSlider,    TBM_GETPOS, 0, 0 ) * 500L;
    LONG lVolume    = (LONG)SendMessage( hVolumeSlider, TBM_GETPOS, 0, 0 ) * 100L;

    // Set the static text boxes
    wsprintf( strBuffer, TEXT("%ld"), lFrequency );
    SetWindowText( GetDlgItem( hDlg, IDC_FREQUENCY ), strBuffer );

    wsprintf( strBuffer, TEXT("%ld"), lPan );
    SetWindowText( GetDlgItem( hDlg, IDC_PAN       ), strBuffer );

    wsprintf( strBuffer, TEXT("%ld"), lVolume );
    SetWindowText( GetDlgItem( hDlg, IDC_VOLUME    ), strBuffer );

    // Set the options in the DirectSound buffer
    if( g_pSound )
    {
        LPDIRECTSOUNDBUFFER pDSB = g_pSound->GetBuffer( 0 );

        if( pDSB )
        {
            if( FAILED( pDSB->SetFrequency( lFrequency ) ) )
            {
                DSCAPS dscaps;
                ZeroMemory( &dscaps, sizeof(DSCAPS) );
                dscaps.dwSize = sizeof(DSCAPS);
                g_pSoundManager->GetDirectSound()->GetCaps( &dscaps );
                
                DSBCAPS dsbcaps;
                ZeroMemory( &dsbcaps, sizeof(DSBCAPS) );
                dsbcaps.dwSize = sizeof(DSBCAPS);
                pDSB->GetCaps( &dsbcaps );

                // Try to guess why it failed 
                if( (dsbcaps.dwFlags & DSBCAPS_LOCHARDWARE) && 
                    (DWORD)lFrequency > dscaps.dwMaxSecondarySampleRate )
                {                    
                    // Hardware buffers don't support >dwMaxSecondarySampleRate
                    SetDlgItemText( hDlg, IDC_STATUS, TEXT("Hardware buffers don't support greater") 
                                                      TEXT("than dscaps.dwMaxSecondarySampleRate") );
                }
                else if( lFrequency > 100000 )
                {
                    // Some platforms (pre-WinXP SP1) do not support 
                    // >100k Hz so they will fail when setting it higher
                    SetDlgItemText( hDlg, IDC_STATUS, TEXT("Some OS platforms do not support >100k Hz") );
                }
                else
                {
                    SetDlgItemText( hDlg, IDC_STATUS, TEXT("Set frequency failed") );
                }

                // Reset to the last valid freq
                pDSB->SetFrequency( g_dwLastValidFreq );                  
                PostMessage( hFreqSlider, TBM_SETPOS, TRUE, g_dwLastValidFreq );               
            }
            else
            {
                g_dwLastValidFreq = lFrequency;
            }
            
            pDSB->SetPan( lPan );
            pDSB->SetVolume( lVolume );
        }
    }
}
Example #30
0
void ezWorld::DeleteObjectDelayed(const ezGameObjectHandle& hObject)
{
  ezMsgDeleteGameObject msg;
  PostMessage(hObject, msg, ezObjectMsgQueueType::NextFrame);
}