Exemplo n.º 1
0
//
//   函数: InitInstance(HINSTANCE, int)
//
//   目的: 保存实例句柄并创建主窗口
//
//   注释:
//
//        在此函数中,我们在全局变量中保存实例句柄并
//        创建和显示主程序窗口。
//
HWND InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   hInst = hInstance; // 将实例句柄存储在全局变量中

   HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
      return NULL;

   DragAcceptFiles(hWnd, TRUE);
   menu = LoadMenu(hInst, MAKEINTRESOURCE(IDC_PLAYER));

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   TCHAR path[256];
   ::GetModuleFileName(hInstance, path, 256);
   std::wstring wpath = path;
   int i = wpath.rfind('\\');
   wpath = wpath.substr( 0 ,i);
   wpath += _T("\\KGPlayer.dll");
   dll = LoadLibrary(wpath.c_str());
   if (!dll || INVALID_HANDLE_VALUE == dll)
   {
       std::wstring msg = _T("加载\"") + wpath + _T("\"失败!");
       MessageBox(NULL, msg.c_str(), _T("出错啦!"), MB_OK);
       return NULL;
   }

	typedef HRESULT (_stdcall *CreatePlayerFun)(ICorePlayer** player,HWND recv);
	CreatePlayerFun CreatePlayer = (CreatePlayerFun)GetProcAddress(dll ,
		(LPCSTR)MAKEINTRESOURCE(3));
    if (!CreatePlayer)
    {
		MessageBox(NULL, _T("创建播放器失败!"), _T("出错啦!"), MB_OK);
        return NULL;
    }
	
    CreatePlayer(&player,hWnd);
    if (!player)
    {
		MessageBox(NULL, _T("创建播放器失败!"), _T("出错啦!"), MB_OK);
        return NULL;
    }

    player->QueryInterface(IID_IPlayerConfig, (void**)&playerConfig);
    if (!playerConfig)
        return NULL;

    HMENU m = GetSubMenu(menu, 0);
    HMENU outMenu = GetSubMenu(m, 3);
    if (!outMenu)
        return NULL;

    DeleteMenu(outMenu, 0, MF_BYPOSITION); 

    MENUITEMINFO info;
    ZeroMemory(&info, sizeof(info));
    info.cbSize = sizeof(info);
    info.fMask = MIIM_STRING | MIIM_ID | MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_STATE;
    info.fType = MFT_RADIOCHECK;
    
    outputCount = 0;
    wchar_t name[255] = {0};
    while(playerConfig->GetOutputTypeNameList(outputCount, name, 255) != -1)
    {
        info.wID = AUDIOMENUIDBASE + outputCount;
        info.dwTypeData = name;
        if (!outputCount)
            info.fState = MFS_CHECKED;
        else
            info.fState = 0;

//         info.cch = wcslen(name);
        InsertMenuItem(outMenu, outputCount, TRUE, &info);
        ++outputCount;
    }
	return hWnd;
}
Exemplo n.º 2
0
CMainWindow::CMainWindow(CPS2VM& virtualMachine, char* cmdLine) 
: m_virtualMachine(virtualMachine)
, m_recordingAvi(false)
, m_recordBuffer(nullptr)
, m_recordBufferWidth(0)
, m_recordBufferHeight(0)
, m_recordAviMutex(NULL)
, m_frames(0)
, m_drawCallCount(0)
, m_stateSlot(0)
, m_outputWnd(nullptr)
, m_statusBar(nullptr)
, m_accTable(NULL)
{
	m_recordAviMutex = CreateMutex(NULL, FALSE, NULL);

	TCHAR sVersion[256];

	CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_UI_PAUSEWHENFOCUSLOST, true);

	if(!DoesWindowClassExist(CLSNAME))
	{
		WNDCLASSEX wc;
		memset(&wc, 0, sizeof(WNDCLASSEX));
		wc.cbSize			= sizeof(WNDCLASSEX);
		wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground	= (HBRUSH)(COLOR_WINDOW); 
		wc.hInstance		= GetModuleHandle(NULL);
		wc.lpszClassName	= CLSNAME;
		wc.lpfnWndProc		= CWindow::WndProc;
		wc.style			= CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
		RegisterClassEx(&wc);
	}

	Create(NULL, CLSNAME, _T(""), WNDSTYLE, Framework::Win32::CRect(0, 0, 640, 480), NULL, NULL);
	SetClassPtr();

#ifdef DEBUGGER_INCLUDED
	CDebugger::InitializeConsole();
#endif

	m_virtualMachine.Initialize();

	SetIcon(ICON_SMALL, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PUREI)));
	SetIcon(ICON_BIG, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PUREI)));

	SetMenu(LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINWINDOW)));

#ifdef DEBUGGER_INCLUDED
	m_debugger = std::unique_ptr<CDebugger>(new CDebugger(m_virtualMachine));
	m_frameDebugger = std::unique_ptr<CFrameDebugger>(new CFrameDebugger());
	CreateDebugMenu();
#endif

	PrintVersion(sVersion, countof(sVersion));

	m_outputWnd = new COutputWnd(m_hWnd);

	m_statusBar = new Framework::Win32::CStatusBar(m_hWnd);
	m_statusBar->SetParts(2, m_statusBarPanelWidths);
	m_statusBar->SetText(STATUSPANEL,	sVersion);
	m_statusBar->SetText(FPSPANEL,		_T(""));

	//m_virtualMachine.CreateGSHandler(CGSH_Null::GetFactoryFunction());
	m_virtualMachine.CreateGSHandler(CGSH_OpenGLWin32::GetFactoryFunction(m_outputWnd));

	m_virtualMachine.CreatePadHandler(CPH_DirectInput::GetFactoryFunction(m_hWnd));

	m_deactivatePause = false;
	m_pauseFocusLost = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_UI_PAUSEWHENFOCUSLOST);

	m_virtualMachine.m_gs->OnNewFrame.connect(boost::bind(&CMainWindow::OnNewFrame, this, _1));

	SetTimer(m_hWnd, NULL, 1000, NULL);
	//Initialize status bar
	OnTimer(0);

	m_virtualMachine.m_os->OnExecutableChange.connect(boost::bind(&CMainWindow::OnExecutableChange, this));

	CreateStateSlotMenu();
	CreateAccelerators();

	if(strstr(cmdLine, "--cdrom0") != nullptr)
	{
		BootCDROM();
	}
#ifdef DEBUGGER_INCLUDED
	if(strstr(cmdLine, "--debugger") != nullptr)
	{
		ShowDebugger();
	}
	if(strstr(cmdLine, "--framedebugger") != nullptr)
	{
		ShowFrameDebugger();
	}
#endif

	RefreshLayout();

	UpdateUI();
	Center();
	Show(SW_SHOW);
}
Exemplo n.º 3
0
/*
 * spyInit - initialization
 */
static BOOL spyInit( HANDLE currinst, HANDLE previnst, int cmdshow )
{
    WNDCLASS    wc;
    HANDLE      memhdl;
    WORD        i;

    i=i;
    memhdl = memhdl;    /* shut up the compiler for non-NT version */
    JDialogInit();
    Instance = currinst;
    ResInstance = currinst;
    if( !InitGblStrings() ) {
        return( FALSE );
    }
    SpyMenu = LoadMenu( ResInstance, "SPYMENU" );
#ifdef __WATCOMC__
    _STACKLOW = 0;
#endif
    MemStart();

    HandleMessageInst = MakeProcInstance( (FARPROC) HandleMessage, Instance );
    HintWndInit( Instance, NULL, 0 );


    /*
     * set up window class
     */
    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = SpyWindowProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = sizeof( LONG_PTR );
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( ResInstance, "APPLICON" );
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW);
#ifdef __NT__
        wc.hbrBackground = NULL;
#else
        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = SPY_CLASS_NAME;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }

#ifdef USE_SNAP_WINDOW
        if( !RegisterSnapClass( Instance ) ) {
            return( FALSE );
        }
#endif
    }

#ifndef NOUSE3D
    CvrCtl3DInit( Instance );
    CvrCtl3dRegister( Instance );
    CvrCtl3dAutoSubclass( Instance );
#endif

    /*
     * now make the main window
     */
    LoadSpyConfig( NULL );
    SpyMainWindow = CreateWindow(
        SPY_CLASS_NAME,         /* Window class name */
        SpyName,                /* Window caption */
        WS_OVERLAPPEDWINDOW,    /* Window style */
        SpyMainWndInfo.xpos,    /* Initial x position */
        SpyMainWndInfo.ypos,    /* Initial y position */
        SpyMainWndInfo.xsize,   /* Initial x size */
        SpyMainWndInfo.ysize,   /* Initial y size */
        (HWND)NULL,             /* Parent window handle */
        (HMENU)SpyMenu,         /* Window menu handle */
        Instance,               /* Program instance handle */
        NULL );                 /* Create parameters */

    if( SpyMainWindow == NULL ) {
        return( FALSE );
    }
    MyTask = GetWindowTask( SpyMainWindow );

    ShowWindow( SpyMainWindow, cmdshow );
    UpdateWindow( SpyMainWindow );

    InitMessages();
    return( TRUE );

} /* spyInit */
void CManageBookmarksDialog::ShowViewMenu()
{
    DWORD dwButtonState = static_cast<DWORD>(SendMessage(m_hToolbar,TB_GETSTATE,TOOLBAR_ID_VIEWS,MAKEWORD(TBSTATE_PRESSED,0)));
    SendMessage(m_hToolbar,TB_SETSTATE,TOOLBAR_ID_VIEWS,MAKEWORD(dwButtonState|TBSTATE_PRESSED,0));

    HMENU hMenu = LoadMenu(GetInstance(),MAKEINTRESOURCE(IDR_MANAGEBOOKMARKS_VIEW_MENU));

    UINT uCheck;

    if(m_pmbdps->m_bSortAscending)
    {
        uCheck = IDM_MB_VIEW_SORTASCENDING;
    }
    else
    {
        uCheck = IDM_MB_VIEW_SORTDESCENDING;
    }

    CheckMenuRadioItem(hMenu,IDM_MB_VIEW_SORTASCENDING,IDM_MB_VIEW_SORTDESCENDING,uCheck,MF_BYCOMMAND);

    switch(m_pmbdps->m_SortMode)
    {
    case NBookmarkHelper::SM_NAME:
        uCheck = IDM_MB_VIEW_SORTBYNAME;
        break;

    case NBookmarkHelper::SM_LOCATION:
        uCheck = IDM_MB_VIEW_SORTBYLOCATION;
        break;

    case NBookmarkHelper::SM_VISIT_DATE:
        uCheck = IDM_MB_VIEW_SORTBYVISITDATE;
        break;

    case NBookmarkHelper::SM_VISIT_COUNT:
        uCheck = IDM_MB_VIEW_SORTBYVISITCOUNT;
        break;

    case NBookmarkHelper::SM_ADDED:
        uCheck = IDM_MB_VIEW_SORTBYADDED;
        break;

    case NBookmarkHelper::SM_LAST_MODIFIED:
        uCheck = IDM_MB_VIEW_SORTBYLASTMODIFIED;
        break;
    }

    CheckMenuRadioItem(hMenu,IDM_MB_VIEW_SORTBYNAME,IDM_MB_VIEW_SORTBYLASTMODIFIED,uCheck,MF_BYCOMMAND);

    RECT rcButton;
    SendMessage(m_hToolbar,TB_GETRECT,TOOLBAR_ID_VIEWS,reinterpret_cast<LPARAM>(&rcButton));

    POINT pt;
    pt.x = rcButton.left;
    pt.y = rcButton.bottom;
    ClientToScreen(m_hToolbar,&pt);

    TrackPopupMenu(GetSubMenu(hMenu,0),TPM_LEFTALIGN,pt.x,pt.y,0,m_hDlg,NULL);
    DestroyMenu(hMenu);

    SendMessage(m_hToolbar,TB_SETSTATE,TOOLBAR_ID_VIEWS,MAKEWORD(dwButtonState,0));
}
Exemplo n.º 5
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_CREATE:
	{
		switcher = make_shared<Switcher>();
		switcher->add_exclusion_process(L"vlc.exe");
		switcherThread = make_shared<thread>([] {switcher->run(); });

		hTrayMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TRAY));
		hTrayPopupMenu = GetSubMenu(hTrayMenu, 0);

		ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
		nid.cbSize = sizeof(nid);
		nid.hWnd = hWnd;
		nid.uFlags = NIF_ICON | NIF_MESSAGE;
		nid.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_POWERPLANSWITCHER));
		nid.uCallbackMessage = WM_USER;
		nid.uID = IDI_POWERPLANSWITCHER;
		Shell_NotifyIcon(NIM_ADD, &nid);

		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	case WM_COMMAND:
	{
		int wmId = LOWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case ID_TRAY_EXIT:
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
	}
	break;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(hWnd, &ps);
		// TODO: Add any drawing code that uses hdc here...
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_USER:
		if (lParam == WM_RBUTTONDOWN)
		{
			POINT p;
			GetCursorPos(&p);
			TrackPopupMenu(hTrayPopupMenu, TPM_LEFTALIGN | TPM_BOTTOMALIGN, p.x, p.y, 0, hWnd, 0);
			break;
		}
		break;
	case WM_DESTROY:
		switcher->stop();
		switcherThread->detach();
		Shell_NotifyIcon(NIM_DELETE, &nid);
		DestroyMenu(hTrayMenu);
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Exemplo n.º 6
0
// ウィンドウプロシージャ
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
    HMENU hMenu, hSubMenu;
    POINT pt;

    switch (msg) {
        case WM_RBUTTONDOWN:
            // クリックされた位置にポップアップメニューを表示
            hMenu = LoadMenu(hInst, TEXT("MYMENU"));
            hSubMenu = GetSubMenu(hMenu, 0);
            pt.x = LOWORD(lp);
            pt.y = HIWORD(lp);
            ClientToScreen(hWnd, &pt);
            TrackPopupMenu(
                hSubMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL);
            DestroyMenu(hMenu);
            break;
        case WM_COMMAND:
            switch (LOWORD(wp)) {
                case IDM_TRAY:   // 「タスクトレイに入れる」メニュー項目
                    // NOTIFYICONDATA構造体のメンバをセット
                    memset(&ni, 0, sizeof(NOTIFYICONDATA));
                    ni.cbSize = sizeof(NOTIFYICONDATA);
                    ni.hWnd = hWnd;
                    ni.uID = ID_MYTRAY;
                    ni.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
                    ni.hIcon = (HICON)LoadImage(
                        hInst, TEXT("MYICON"), IMAGE_ICON, 0, 0, 0);
                    ni.uCallbackMessage = MYTRAY_MESSAGE;
                    lstrcpy(ni.szTip, TEXT("猫でもわかるタスクトレイ"));

                    // タスクトレイにアイコンを表示
                    Shell_NotifyIcon(NIM_ADD, &ni);
                    // メインウィンドウを非表示にする
                    ShowWindow(hWnd, SW_HIDE);

                    bTray = TRUE;
                    break;
                case IDM_OUT:    // 「タスクトレイより出す」メニュー項目
                    // タスクトレイのアイコンを削除
                    Shell_NotifyIcon(NIM_DELETE, &ni);
                    // メインウィンドウを表示
                    ShowWindow(hWnd, SW_SHOWNORMAL);

                    bTray = FALSE;
                    break;
                case IDM_END:    // 「終了」メニュー項目
                    SendMessage(hWnd, WM_CLOSE, 0, 0);
                    break;
            }
            break;
        case MYTRAY_MESSAGE:     // タスクトレイ上のイベント
            switch(lp) {
                case WM_RBUTTONDOWN:
                    // クリックされた位置にポップアップメニューを表示
                    hMenu = LoadMenu(hInst, TEXT("MYTRAY"));
                    hSubMenu = GetSubMenu(hMenu, 0);
                    GetCursorPos(&pt);    // クリック位置を取得
                    SetForegroundWindow(hWnd);
                    TrackPopupMenu(
                        hSubMenu, TPM_BOTTOMALIGN, pt.x, pt.y, 0, hWnd, NULL);
                    DestroyMenu(hMenu);
                    break;
                default:
                    return (DefWindowProc(hWnd, msg, wp, lp));
            }
            break;
        case WM_CLOSE:
            if (bTray)   // タスクトレイにアイコンがあるなら…
                // …タスクトレイのアイコンを削除
                Shell_NotifyIcon(NIM_DELETE, &ni);
            DestroyWindow(hWnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return (DefWindowProc(hWnd, msg, wp, lp));
    }
    return 0;
}
Exemplo n.º 7
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
					PSTR szCmdLine, int iCmdShow)
{
	static TCHAR szAppName [] = TEXT ("BitMap") ;
	HWND         hwnd ;
	MSG          msg ;
	WNDCLASS     wndclass ;
	HMENU        hmenu;
	HACCEL       haccel;

	wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
	wndclass.lpfnWndProc   = WndProc ;
	wndclass.cbClsExtra    = 0 ;
	wndclass.cbWndExtra    = 0 ;
	wndclass.hInstance     = hInstance ;

	//加载自定义的icon和cursor
	wndclass.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
	wndclass.hCursor=LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR1));

	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
	wndclass.lpszMenuName  = NULL ;
	wndclass.lpszClassName = szAppName ;
	
	if (!RegisterClass (&wndclass))
	{
		MessageBox (NULL, TEXT ("This program requires Windows NT!"),
			szAppName, MB_ICONERROR) ;
		return 0 ;
	}

	hwnd = CreateWindow (szAppName, TEXT ("Millionaire"), 
		WS_SYSMENU|WS_MINIMIZEBOX, 
		0, 0,
		0, 0,
		NULL, NULL, hInstance, NULL) ;

	//加载菜单
	hmenu=LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1));
	SetMenu(hwnd,hmenu);

	ShowWindow (hwnd, iCmdShow) ;
	UpdateWindow (hwnd) ;

	/*hDlgMaxRecord=CreateDialog(hInstance,TEXT("最高纪录"),hwnd,MaxRecordProc);*/
	


	//加载加速键
	haccel=LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1));

	while (GetMessage (&msg, NULL, 0, 0))
	{
		/*if(!TranslateAccelerator(hwnd,haccel,&msg)||(hDlgMaxRecord==0||!IsDialogMessage(hDlgMaxRecord,&msg)))
		{
			TranslateMessage (&msg) ;
			DispatchMessage (&msg) ;
		}*/
		if(!TranslateAccelerator(hwnd,haccel,&msg))
		{
			TranslateMessage (&msg) ;
			DispatchMessage (&msg) ;
		}
	}
	return msg.wParam ;
}
Exemplo n.º 8
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 命令处理
VOID COpenDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
	INT i;
	RECT rtRect;
	BOOL bPreview;
	PUINT puValue;
	const UINT c_uFormats[][2] = 
	{
		{352, 288}, {176, 144}, {128, 96},
		{320, 240}, {160, 120},
		{640, 480}, {320, 240}, {160, 120},
		{352, 240}, {352, 288},
		{720, 480}, {720, 576},
	};

	_ExIf((HWND) lParam == m_hToolbar, SetFocus(m_hToolbar));
	switch (LOWORD(wParam))
	{
	case IDC_Open_MulSignText:
		if (m_hFormatMenu == NULL)
		{
			m_hFormatMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_Menu_Format));
		}
		GetWindowRect(GetDlgItem(m_hWnd, IDC_Open_MulSignText), &rtRect);
		TrackPopupMenu(GetSubMenu(m_hFormatMenu, 0), TPM_TOPALIGN, rtRect.left, rtRect.top, 0, m_hWnd, NULL);
		break;

	case IDM_Format_CIF:
	case IDM_Format_QCIF:
	case IDM_Format_SUBQCIF:
	case IDM_Format_SIF:
	case IDM_Format_QSIF:
	case IDM_Format_VGA:
	case IDM_Format_QVGA:
	case IDM_Format_QQVGA:
	case IDM_Format_VCDNTSC:
	case IDM_Format_VCDPAL:
	case IDM_Format_DVDNTSC:
	case IDM_Format_DVDPAL:
		i = LOWORD(wParam) - IDM_Format_CIF;
		SetDlgItemInt(m_hWnd, IDC_Open_Width, c_uFormats[i][0], FALSE);
		SetDlgItemInt(m_hWnd, IDC_Open_Height, c_uFormats[i][1], TRUE);
		OnCommand(MAKELONG(IDC_Open_Width, EN_KILLFOCUS));
		OnCommand(MAKELONG(IDC_Open_Height, EN_KILLFOCUS));
		break;

	case IDC_Open_Preview:
		// 切换预览
		if (HIWORD(wParam) == BN_CLICKED)
		{
			IsPreviewChecked() ? InvalidateRect(m_hWnd, &m_rtPreview, TRUE) : m_pWnd->Stop();
			OnCommand(IDC_RawVideo_Seek);
		}
		break;

	case IDC_Open_Width:
	case IDC_Open_Height:
	case IDC_Open_FrameRate:
	case IDC_Open_FrameStep:
		if (HIWORD(wParam) == EN_KILLFOCUS)
		{
			switch (LOWORD(wParam))
			{
			case IDC_Open_Width:
				puValue = &m_riFormat.m_uWidth;
				break;

			case IDC_Open_Height:
				puValue = (PUINT) &m_riFormat.m_iHeight;
				break;

			case IDC_Open_FrameRate:
				puValue = &m_riFormat.m_uFrameRate;
				break;

			case IDC_Open_FrameStep:
				puValue = (PUINT) &m_riFormat.m_iFrameStep;
				break;
			}

			// 限制尺寸范围
			*puValue = GetDlgItemInt(m_hWnd, LOWORD(wParam), NULL, TRUE);
			m_pWnd->Open(m_pWnd->m_tzFileName, &m_riFormat);
			SetDlgItemInt(m_hWnd, LOWORD(wParam), *puValue, TRUE);
		}
		break;

	case IDM_Play_Play:
		m_pWnd->TogglePlay();
		break;

	case IDM_Play_GotoStart:
		m_pWnd->Stop();
		m_pWnd->Seek(0);
		break;

	case IDM_Play_GotoEnd:
		m_pWnd->Stop();
		m_pWnd->Seek(MAX_Frame);
		break;

	case IDM_Play_StepBackward:
		m_pWnd->Stop();
		m_pWnd->Step(-1);
		break;

	case IDM_Play_StepForward:
		m_pWnd->Stop();
		m_pWnd->Step(1);
		break;

	case IDC_RawVideo_Play:
		SendMessage(m_hToolbar, TB_CHECKBUTTON, IDM_Play_Play, lParam);
		break;

	case IDC_RawVideo_Change:
		bPreview = CanPreview();
		for (i = IDM_Play_Play; i <= IDM_Play_GotoEnd; i++)
		{
			SendMessage(m_hToolbar, TB_ENABLEBUTTON, i, MAKELONG(bPreview, 0));
		}

		i = m_pWnd->m_uTotalFrame ? (m_pWnd->m_uTotalFrame - 1) : 0;
		SendDlgItemMessage(m_hWnd, IDC_Open_FrameStepSpin, UDM_SETRANGE, 0, MAKELONG(i, -i));		
		InvalidateRect(GetDlgItem(m_hWnd, IDC_Open_FrameStepSpin), NULL, FALSE);

		// 计算位置和尺寸
		CopyRect(&rtRect, &m_rtPreview);
		InflateRect(&rtRect, -5, -5);
		i = MulDiv(m_pWnd->m_uWidth, _RectHeight(m_rtPreview), m_pWnd->m_iHeight);
		if (i > _RectWidth(rtRect))
		{
			i = MulDiv(m_pWnd->m_iHeight, _RectWidth(rtRect), m_pWnd->m_uWidth);
			if (_RectHeight(rtRect) > i)
			{
				rtRect.top += (_RectHeight(rtRect) - i) / 2;
				rtRect.bottom = rtRect.top + i;
			}
		}
		else
		{
			rtRect.left += (_RectWidth(rtRect) - i) / 2;
			rtRect.right = rtRect.left + i;
		}
		m_pWnd->SetDrawRect(&rtRect);

		SetDlgItemInt(m_hWnd, IDC_Open_TotalFrame, m_pWnd->m_uTotalFrame, FALSE);
		InvalidateRect(m_hWnd, &m_rtPreview, TRUE);
		break;

	case IDC_RawVideo_Seek:
		if (CanPreview())
		{
			SetDlgItemInt(m_hWnd, IDC_Open_StatusText, m_pWnd->m_uCurFrame + 1, FALSE);
		}
		else
		{
			SetDlgItemText(m_hWnd, IDC_Open_StatusText, NULL);
		}
		break;
	}
}
Exemplo n.º 9
0
CDebugger::CDebugger(CPS2VM& virtualMachine)
: m_virtualMachine(virtualMachine)
{
	RegisterPreferences();

	if(!DoesWindowClassExist(CLSNAME))
	{
		WNDCLASSEX wc;
		memset(&wc, 0, sizeof(WNDCLASSEX));
		wc.cbSize			= sizeof(WNDCLASSEX);
		wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground	= (HBRUSH)GetStockObject(GRAY_BRUSH); 
		wc.hInstance		= GetModuleHandle(NULL);
		wc.lpszClassName	= CLSNAME;
		wc.lpfnWndProc		= CWindow::WndProc;
		RegisterClassEx(&wc);
	}
	
	Create(NULL, CLSNAME, _T(""), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, Framework::Win32::CRect(0, 0, 640, 480), NULL, NULL);
	SetClassPtr();

	SetMenu(LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_DEBUGGER)));

	CreateClient(NULL);

	//Show(SW_MAXIMIZE);

	//ELF View Initialization
	m_pELFView = new CELFView(m_pMDIClient->m_hWnd);
	m_pELFView->Show(SW_HIDE);

	//Functions View Initialization
	m_pFunctionsView = new CFunctionsView(m_pMDIClient->m_hWnd);
	m_pFunctionsView->Show(SW_HIDE);
	m_pFunctionsView->OnFunctionDblClick.connect(boost::bind(&CDebugger::OnFunctionsViewFunctionDblClick, this, _1));
	m_pFunctionsView->OnFunctionsStateChange.connect(boost::bind(&CDebugger::OnFunctionsViewFunctionsStateChange, this));

	//Threads View Initialization
	m_threadsView = new CThreadsViewWnd(m_pMDIClient->m_hWnd, m_virtualMachine);
	m_threadsView->Show(SW_HIDE);
	m_threadsView->OnGotoAddress.connect(boost::bind(&CDebugger::OnThreadsViewAddressDblClick, this, _1));

	//Debug Views Initialization
	m_nCurrentView = -1;

	memset(m_pView, 0, sizeof(m_pView));
	m_pView[DEBUGVIEW_EE]	= new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_ee->m_EE, 
		std::bind(&CPS2VM::StepEe, &m_virtualMachine), m_virtualMachine.m_ee->m_os, "EmotionEngine");
	m_pView[DEBUGVIEW_VU0]	= new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_ee->m_VU0, 
		std::bind(&CPS2VM::StepEe, &m_virtualMachine), nullptr, "Vector Unit 0", CDisAsmWnd::DISASM_VU);
	m_pView[DEBUGVIEW_VU1]	= new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_ee->m_VU1, 
		std::bind(&CPS2VM::StepVu1, &m_virtualMachine), nullptr, "Vector Unit 1", CDisAsmWnd::DISASM_VU);
	m_pView[DEBUGVIEW_IOP]  = new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_iop->m_cpu, 
		std::bind(&CPS2VM::StepIop, &m_virtualMachine), m_virtualMachine.m_iopOs.get(), "IO Processor");

	m_virtualMachine.m_ee->m_os->OnExecutableChange.connect(boost::bind(&CDebugger::OnExecutableChange, this));
	m_virtualMachine.m_ee->m_os->OnExecutableUnloading.connect(boost::bind(&CDebugger::OnExecutableUnloading, this));

	ActivateView(DEBUGVIEW_EE);
	LoadSettings();

	if(GetDisassemblyWindow()->IsVisible())
	{
		GetDisassemblyWindow()->SetFocus();
	}

	UpdateLoggingMenu();
	CreateAccelerators();
}
Exemplo n.º 10
0
/*
	PropSheetProc: Handles special messages pertaining to the property sheet.

	Note: See PropSheetProc in the Platform SDK docs for parameters and notes.
*/
int CALLBACK PropSheetProc(HWND sheet, UINT msgid, LPARAM lParam)
{
	switch (msgid)
	{
	case PSCB_PRECREATE:
		{
			DLGTEMPLATE *templ = (DLGTEMPLATE*)lParam;

			templ->cy += 5;

			//add a minimize box
			templ->style |= WS_MINIMIZEBOX;
		}
		break;

	case PSCB_INITIALIZED:
		{
			HWND tooltip;
			HICON icon;

			/* Add Menu. */
			propdata.menu = LoadMenu(aokts, (LPCSTR)IDM_MAIN);
			SetMenu(sheet, propdata.menu);
			//SetSaveState(sheet, MF_GRAYED);
	        scen.reset();
	        SendMessage(PropSheet_GetCurrentPageHwnd(sheet), AOKTS_Loading, 0, 0);
	        MapView_Reset(propdata.mapview, true);

			/* Enable appropriate recent file items. */
			UpdateRecentMenu(propdata.menu);

			/* Remove unused buttons. */
			for (int i = 0; i < sizeof(PropSheetButtons) / sizeof(WORD); i++)
			{
				HWND hWnd = GetDlgItem(sheet, PropSheetButtons[i]);
				if (hWnd != NULL)
				{
					ShowWindow(hWnd, SW_HIDE);
					EnableWindow(hWnd, FALSE);
				}
			}

			/* Add a tooltip window */
			tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "AOKTS Tooltip", WS_POPUP,
				CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
				sheet, NULL, aokts, NULL);
			TooltipInit(tooltip);

			/* Set the big icon */
			icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LOGO));
			Window_SetIcon(sheet, ICON_BIG, icon);

            if (setts.editall) {
                CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND | MF_CHECKED);
            } else {
                CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND);
            }
		}
		break;
	}
	return 0;
}
Exemplo n.º 11
0
int WINAPI WinMain(  HINSTANCE hinstance,
                     HINSTANCE hprevinstance,
                     LPSTR     lpcmdline,
                     int       ncmdshow)
{
   WNDCLASSEX  winclass;
   HWND        hwnd;
   MSG         msg;
   HDC         hdc;
   PAINTSTRUCT ps;
   
   main_instance = hinstance;
   
   winclass.cbSize         = sizeof(WNDCLASSEX);
   winclass.style          = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
   winclass.lpfnWndProc    = WindowProc;
   winclass.cbClsExtra     = 0;
   winclass.cbWndExtra     = 0;
   winclass.hInstance      = hinstance;
   winclass.hIcon          = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_KINGAPP));
   winclass.hCursor        = LoadCursor(NULL,IDC_ARROW);
   winclass.hbrBackground  = (HBRUSH) GetStockObject(BLACK_BRUSH);
   winclass.lpszMenuName   = NULL;
   winclass.lpszClassName  = WINDOW_CLASS_NAME;
   winclass.hIconSm		   = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_KINGAPP));
   
   if (!RegisterClassEx(&winclass))
   {
      return(0);
   }

    
   if (!(hwnd = CreateWindowEx( NULL,
                              WINDOW_CLASS_NAME,
                              "Sound As Resource Demo",
                              WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                              0, // X
                              0, // Y
                              400, // WIDTH (INITIAL)
                              400, // HEIGHT (INITIAL)
                              NULL, // HANDLE TO PARENT
                              NULL,
                              hinstance,
                              NULL )))
   {
      return(0);
   }
   
   HMENU hmenuhandle = LoadMenu(hinstance,MAKEINTRESOURCE(MainMenu));
   
   SetMenu(hwnd,hmenuhandle);
   
   //ShowCursor(FALSE);
   
   main_window_handle = hwnd;
   main_instance      = hinstance;
   
//   Game_Init();
   
   while(1)
   {
      if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
      {
         if (msg.message == WM_QUIT)
         {
            break;
         }
         
         TranslateMessage(&msg);
         
         DispatchMessage(&msg);
      }
       
   } // end while
   
   
   //ShowCursor(TRUE);
   
   return(msg.wParam);
   
} // end WinMain
Exemplo n.º 12
0
/***********************

 * WinMain: Main function for window
 * @parameter: HINSTANCE _hInstance, game instance
 *				HINSTANCE _hPrevInstance, previous instance
 *				LPSTR _lpCmdLine, command line
 *				int _nCmdShow, command show
 * @return:

 ********************/
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE _hPrevInstance,	LPSTR _lpCmdLine,	int _nCmdShow)
{
	// This will hold the class we create.
	WNDCLASSEX winclass; 
	MSG msg; // Generic message.
	HMENU Menu = LoadMenu(_hInstance, MAKEINTRESOURCE(IDR_MENU1));
	// Create const ints for window width and height
	const int WINDOW_WIDTH = 1300;
	const int WINDOW_HEIGHT = 1080;

	// Window class structure.
	winclass.cbSize = sizeof(WNDCLASSEX);
	winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
	winclass.lpfnWndProc = WindowProc;
	winclass.cbClsExtra = 0;
	winclass.cbWndExtra = 0;
	winclass.hInstance = _hInstance;
	winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
	winclass.hbrBackground = CreateSolidBrush(RGB(41,63,151));
	winclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
	winclass.lpszClassName = WINDOW_CLASS_NAME;
	winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

	// register the window class
	if (!RegisterClassEx(&winclass))
	{
		return (0);
	}

	// create the window
	hwnd =	CreateWindowEx(NULL,				// Extended style.
			WINDOW_CLASS_NAME,					// Class.
			"Solitare",						// Title.
			(WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME) | WS_VISIBLE,
			0, 0,								// Initial x,y.
			WINDOW_WIDTH, WINDOW_HEIGHT,		// Initial width, height.
			NULL,								// Handle to parent.
			Menu,								// Handle to menu.
			_hInstance,							// Instance of this application.
			NULL);								// Extra creation parameters.

	// If there is no window
	if (!(hwnd))
	{
		return (0);
	}

	//Get current monitor Height and Width
	HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
	MONITORINFO info;
	info.cbSize = sizeof(MONITORINFO);
	GetMonitorInfo(monitor, &info);
	int monitor_width = info.rcMonitor.right - info.rcMonitor.left;
	int monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
	//Resize the window to the height of the monitor
	SetWindowPos(hwnd,0,0,0,WINDOW_WIDTH,monitor_height-50,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);	
	
	// Seed random
	srand((unsigned int)time(0));

	//Run the initialization, set up the game
	CGame& Game = CGame::GetInstance();
	Game.Initialise(_hInstance, hwnd, WINDOW_WIDTH, monitor_height-50);
	
	// Enter main event loop
	while (true)
	{
		// Test if there is a message in queue, if so get it.
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			// Test if this is a quit.
			if (msg.message == WM_QUIT)
			{
				break;
			}
			// Translate any accelerator keys.
			TranslateMessage(&msg);
			// Send the message to the window proc.
			DispatchMessage(&msg);
		}
			// Main game processing goes here.
			Game.ExecuteOneFrame(); //One frame of game logic occurs here...
	}
	// Return to Windows like this...
	delete &Game;
	return (static_cast<int>(msg.wParam));
}
Exemplo n.º 13
0
BOOL InitInstance(HINSTANCE hInstance,int nCmdShow )
{
	HDC		hDC;
	int		i;

	sysInf.ScreenW = WIN_SIZEX;
	sysInf.ScreenH = WIN_SIZEY;
	sysInf.hInstance = hInstance;
	sysInf.hMenu = LoadMenu( NULL, MAKEINTRESOURCE(IDR_MAINMENU) );
	sysInf.bUseBPP24 = CheckScreenMode_BPP24();
	SetMyMenuItem();

retryCreateWin:
	if(0==sysInf.full_screen){
		if(GetSystemMetrics(SM_CXSCREEN)<=WIN_SIZEX || GetSystemMetrics(SM_CYSCREEN)<=WIN_SIZEY){
			if(IDYES!=MessageBox(NULL,"この解像度では、Windowモードでは起動できません。フルスクリーンモードでゲームを起動しますか?","カラーモード",MB_YESNO|MB_ICONWARNING)){
				return (FALSE);
			}else{
				sysInf.full_screen = 1;
				goto retryCreateWin;
			}
		}
		sysInf.hWnd = CreateWindowEx(
			0,className,TITLE_NAME,
			WINDOWMODE_STYLE ,
			(GetSystemMetrics(SM_CXSCREEN)-sysInf.ScreenW)/2,(GetSystemMetrics(SM_CYSCREEN)-sysInf.ScreenH)/2,
			sysInf.ScreenW +GetSystemMetrics(SM_CXDLGFRAME)*2,
			sysInf.ScreenH +GetSystemMetrics(SM_CYDLGFRAME)*2 +GetSystemMetrics(SM_CYBORDER) +GetSystemMetrics(SM_CYSIZE) +GetSystemMetrics(SM_CYMENU),
			NULL, sysInf.hMenu, hInstance, NULL);

	}else{
		int full_screen = 1;
		sysInf.full_screen = 0;
		for(i=0; i<DispFreqMax; i++){
			if(sysInf.refreshRate==DispFreq[i]){
				full_screen = i+1;
				break;
			}
		}
		if(i==DispFreqMax)sysInf.refreshRate = 0;
		sysInf.hWnd = CreateWindowEx(
			0,className,"鎖−クサリ−",
			FULLMODE_STYLE,
			0, 0, sysInf.ScreenW, sysInf.ScreenH,
			NULL, NULL, hInstance, NULL);
		sysInf.hMenuWnd = CreateWindow(className,"menuWnd",WS_POPUP,
			0,0,
			WIN_SIZEX,GetSystemMetrics(SM_CYMENUSIZE),sysInf.hWnd,sysInf.hMenu,sysInf.hInstance,NULL);
		ScreenChange(full_screen , sysInf.refreshRate);
	}
	if( !sysInf.hWnd )return FALSE;
	hDC = GetDC(sysInf.hWnd);
	sysInf.bpp = GetDeviceCaps(hDC,BITSPIXEL);
	ReleaseDC(sysInf.hWnd,hDC);
	if(sysInf.bpp<16){	
		MessageBox(sysInf.hWnd,"このゲームはHightColor(16Bit 65536色)モード以下のカラーモードでは動作しません。\nTrueColorかHightColorモードに切り替えて起動してください。","カラーモード",MB_OK|MB_ICONWARNING);
		return (FALSE);
	}
	SetCursor(LoadCursor(NULL,IDC_ARROW));
	return (TRUE);
} // InitInstance
Exemplo n.º 14
0
INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	RECT rc, pos;
	HWND button;
	HMENU hMenu, hMenu1;
	TCHAR str[4096];
	switch (msg) {
	case WM_INITDIALOG:
		opt_startup = TRUE;
		// set windows position, make it top-most
		GetWindowRect(hdlg, &rc);
		SetWindowPos(hdlg, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
		TranslateDialogDefault(hdlg);
		// generate the display text for variable list
		_tcscpy(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
		SetDlgItemText(hdlg, IDC_VARLIST, str);

		// make the more variable and other buttons flat
		SendMessage(GetDlgItem(hdlg, IDC_MORE), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM1), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM2), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM3), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM4), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM5), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM6), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM7), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_TM8), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg, IDC_RESET), BUTTONSETASFLATBTN, TRUE, 0);
		// load the settings
		LoadTextSettings(hdlg);
		opt_startup = FALSE;
		return TRUE;

	case WM_COMMAND:
		if (opt_startup)	return TRUE;
		switch (LOWORD(wParam)) {
		case IDC_CTEXT:
		case IDC_BTITLE:
		case IDC_BTEXT:
		case IDC_NTEXT:
		case IDC_XTEXT:
		case IDC_ETEXT:
		case IDC_HTEXT:
		case IDC_BTITLE2:
			if (HIWORD(wParam) == EN_CHANGE)
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_MORE:
			// display custom variables list
			MoreVarList();
			break;

		case IDC_TM1:
		case IDC_TM2:
		case IDC_TM3:
		case IDC_TM4:
		case IDC_TM5:
		case IDC_TM6:
		case IDC_TM7:
		case IDC_TM8:
			WEATHERINFO winfo;
			// display the menu
			button = GetDlgItem(hdlg, LOWORD(wParam));
			GetWindowRect(button, &pos);
			hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			TranslateMenu(hMenu1);
			switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) {
			case ID_MPREVIEW:
				// show the preview in a message box, using the weather data from the default station
				winfo = LoadWeatherInfo(opt.DefStn);
				GetDisplay(&winfo, *var[LOWORD(wParam) - IDC_TM1], str);
				MessageBox(NULL, str, TranslateT("Weather Protocol Text Preview"), MB_OK | MB_TOPMOST);
				break;

			case ID_MRESET:
				unsigned varo = LOWORD(wParam) - IDC_TM1;
				// remove the old setting from db and free memory
				TCHAR* vartmp = *var[varo];
				wfree(&vartmp);
				SetTextDefault(varname[varo]);
				SetDlgItemText(hdlg, cname[varo], *var[varo]);
				break;
			}
			DestroyMenu(hMenu);
			break;

		case IDC_RESET:
			// left click action selection menu
			button = GetDlgItem(hdlg, IDC_RESET);
			GetWindowRect(button, &pos);
			hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			TranslateMenu(hMenu1);
			switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) {
			case ID_T1:
				// reset to the strings in memory, discard all changes
				LoadTextSettings(hdlg);
				break;

			case ID_T2:
				// reset to the default setting
				FreeTextVar();
				SetTextDefault("CbBENHX");
				LoadTextSettings(hdlg);
				break;
			}
			DestroyMenu(hMenu);
			break;
		}
		return TRUE;
	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case PSN_APPLY:
			// save the option
			TCHAR textstr[MAX_TEXT_SIZE];
			// free memory for old settings
			FreeTextVar();
			// save new settings to memory
			GetDlgItemText(hdlg, IDC_CTEXT, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.cText, textstr);
			GetDlgItemText(hdlg, IDC_BTEXT, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.bText, textstr);
			GetDlgItemText(hdlg, IDC_BTITLE, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.bTitle, textstr);
			GetDlgItemText(hdlg, IDC_ETEXT, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.eText, textstr);
			GetDlgItemText(hdlg, IDC_NTEXT, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.nText, textstr);
			GetDlgItemText(hdlg, IDC_HTEXT, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.hText, textstr);
			GetDlgItemText(hdlg, IDC_XTEXT, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.xText, textstr);
			GetDlgItemText(hdlg, IDC_BTITLE2, textstr, MAX_TEXT_SIZE);
			wSetData(&opt.sText, textstr);
			SaveOptions();
			UpdateAllInfo(0, 0);
			break;
		}
		break;
	}
	return FALSE;
}
Exemplo n.º 15
0
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
	Q_UNUSED( hPrevInstance );
	Q_UNUSED( nShowCmd );
#if defined(_DEBUG)
	/*	AllocConsole();
		CONSOLE_SCREEN_BUFFER_INFO coninfo;
		GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
		coninfo.dwSize.Y = 500;
		SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
		int hConHandle;
		long lStdHandle;
		FILE *fp;
		lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
		hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
		fp = _fdopen( hConHandle, "w" );
		*stdout = *fp;
		setvbuf( stdout, NULL, _IONBF, 0 );
		lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
		hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
		fp = _fdopen( hConHandle, "w" );
		*stderr = *fp;
		setvbuf( stderr, NULL, _IONBF, 0 );
		QString consoleTitle = QString("%1 %2 %3 - Debug Console").arg(productString()).arg(productBeta()).arg(productVersion());
		SetConsoleTitle(consoleTitle.latin1());*/
#endif

	INITCOMMONCONTROLSEX initex;
	initex.dwICC = ICC_WIN95_CLASSES;
	initex.dwSize = sizeof( INITCOMMONCONTROLSEX );
	InitCommonControlsEx( &initex );
#pragma comment(lib, "comctl32.lib") // needed for InitCommonControlsEx call
	appInstance = hInstance;
	guiThread = GetCurrentThreadId();

	// Try to load riched20.dll
	HMODULE hRiched = LoadLibrary( "riched20.dll" );

	if ( !hRiched )
	{
		MessageBox( 0, "The riched20.dll library could not be found on your system.\nPlease install Microsoft Internet Explorer 4.0 or later.", "Missing DLL", MB_OK | MB_ICONERROR );
		return 1;
	}

	hbSeparator = CreateSolidBrush( RGB( 0xAF, 0xAF, 0xAF ) );
	hbBackground = CreateSolidBrush( RGB( 0, 64, 38 ) );
	iconGreen = ( HICON ) LoadImage( appInstance, MAKEINTRESOURCE( IDI_ICONGREEN ), IMAGE_ICON, 16, 16, 0 );
	iconRed = ( HICON ) LoadImage( appInstance, MAKEINTRESOURCE( IDI_ICONRED ), IMAGE_ICON, 16, 16, 0 );

	// Create the WindowClass
	WNDCLASSEX wpClass;
	ZeroMemory( &wpClass, sizeof( WNDCLASSEX ) );
	wpClass.cbSize = sizeof( WNDCLASSEX );
	wpClass.hInstance = hInstance;
	wpClass.lpfnWndProc = wpWindowProc;
	wpClass.hCursor = LoadCursor( NULL, MAKEINTRESOURCE( IDC_ARROW ) );
	wpClass.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_ICON1 ) );
	wpClass.hbrBackground = hbBackground;
	wpClass.lpszClassName = WOLFPACK_CLASS;
	wpClass.hIconSm = iconRed;
	wpClass.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;

	if ( !RegisterClassEx( &wpClass ) )
	{
		MessageBox( 0, "Couldn't register Window Class.", "Window Class", MB_OK | MB_ICONERROR );
		return 1;
	}

	// Create the Window itself
	hmMainMenu = LoadMenu( appInstance, MAKEINTRESOURCE( IDR_MAINMENU ) );
	mainWindow = CreateWindow( WOLFPACK_CLASS, "Wolfpack", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, hmMainMenu, hInstance, NULL );

	if ( mainWindow == 0 )
	{
		MessageBox( 0, QString( "Couldn't create the window: " + getErrorString() ).latin1(), "Wolfpack", MB_OK | MB_ICONERROR );
		return 1;
	}

	ShowWindow( mainWindow, SW_NORMAL );

	// Create the System Tray Icon
	ZeroMemory( &icondata, sizeof( icondata ) );
	icondata.cbSize = sizeof( icondata );
	icondata.hWnd = mainWindow;
	icondata.uID = 0;
	icondata.uFlags = NIF_MESSAGE | NIF_ICON;
	icondata.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_ICON1 ) );
	icondata.uCallbackMessage = WM_TRAY_NOTIFY;

#if !defined(TTS_BALLOON)
# define TTS_BALLOON			 0x40
#endif

	// This is "ported" from MFC
	tooltip = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, mainWindow, NULL, hInstance, NULL );

	if ( tooltip )
	{
		TOOLINFO info;
		info.cbSize = sizeof( info );
		info.uFlags = TTF_TRANSPARENT | TTF_CENTERTIP;
		info.hwnd = mainWindow;
		info.uId = 0;
		info.hinst = 0;
		info.lpszText = LPSTR_TEXTCALLBACK;
		GetClientRect( mainWindow, &info.rect );
		SendMessage( tooltip, TTM_ADDTOOL, 0, ( LPARAM ) & info );
	}
	Shell_NotifyIconA( NIM_ADD, ( PNOTIFYICONDATAA ) & icondata );

	cServerThread serverThread( lpCmdLine );
	serverThread.start();

	MSG msg;

	while ( GetMessage( &msg, 0, 0, 0 ) > 0 )
	{
		if ( msg.message == WM_CHAR && msg.hwnd == inputWindow && msg.wParam == '\r' )
		{
			if ( Server::instance()->getState() == RUNNING )
			{
				char command[512] =
				{
				0,
				};
				GetWindowText( inputWindow, command, 512 );
				SetWindowText( inputWindow, "" );

				// We are in a different Thread. Remember that.
				Console::instance()->queueCommand( command );
			}

			continue;
		}
		else if ( msg.message == WM_TIMER )
		{
			char message[512];

			unsigned int seconds, minutes, hours, days;
			days = Server::instance()->time() / 86400000;
			hours = ( Server::instance()->time() % 86400000 ) / 3600000;
			minutes = ( ( Server::instance()->time() % 86400000 ) % 3600000 ) / 60000;
			seconds = ( ( ( Server::instance()->time() % 86400000 ) % 3600000 ) % 60000 ) / 1000;

			sprintf( message, "Uptime: %u:%02u:%02u:%02u", days, hours, minutes, seconds );
			SetWindowText( lblUptime, message );

			// Update the icon
			static unsigned int lastState = 0xFFFFFFFF;

			if ( lastState != Server::instance()->getState() )
			{
				if ( Server::instance()->getState() == RUNNING )
				{
					SendMessage( mainWindow, WM_SETICON, ICON_SMALL, ( WPARAM ) iconGreen );
					SendMessage( statusIcon, STM_SETIMAGE, IMAGE_ICON, ( LPARAM ) iconGreen );
				}
				else
				{
					SendMessage( mainWindow, WM_SETICON, ICON_SMALL, ( WPARAM ) iconRed );
					SendMessage( statusIcon, STM_SETIMAGE, IMAGE_ICON, ( LPARAM ) iconRed );
				}
			}
			lastState = Server::instance()->getState();
		}

		TranslateMessage( &msg );
		DispatchMessage( &msg );
	}

	Shell_NotifyIconA( NIM_DELETE, ( PNOTIFYICONDATAA ) & icondata );

	Server::instance()->cancel();

	serverThread.wait();

	return serverThread.returnValue();
}
Exemplo n.º 16
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	WinProc_sub = hWnd;
	PAINTSTRUCT ps;
	HGDIOBJ hfDefault;
	RECT rt;
	RECT rt2;
	static char str[256];
	int xlnc, ylnc;
	int Lines;
	int nScroll;

	/* 하단 상태바 부분 */
	int SBPart[4];
	RECT prt;	
	SCROLLINFO si;

	/* 플로팅 팝업 메뉴 부분 */
	static COLORREF Color = RGB(255, 0, 0);
	BOOLEAN delresult;

	switch (iMessage) {
	case WM_CREATE:
		AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hPopup, "즐겨찾기목록");
		SetMenu(hWnd, hMenu);
		favorite_page_create(hWnd);
		EdittextBox = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", NULL, WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, 115, 10, 300, 21, hWnd, (HMENU)IDC_MAIN_EDIT, NULL, NULL);
		hfDefault = GetStockObject(DEFAULT_GUI_FONT);
		SendMessage(EdittextBox, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
		SendMessage(EdittextBox, WM_SETTEXT, NULL, (LPARAM)"주소입력창");
		button = CreateWindow("BUTTON", "이동", WS_VISIBLE | WS_CHILD | WS_BORDER, 415, 10, 100, 20, hWnd, (HMENU)IDC_MAIN_BUTTON, NULL, NULL);
		SendMessage(button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
		/* 디렉토리 버튼 */
		
		directory_button = CreateWindow("BUTTON", "방문기록보기", WS_VISIBLE | WS_CHILD | WS_BORDER, 520, 10, 100, 20, hWnd, (HMENU)IDC_VISITPAGE_BUTTON, NULL, NULL);
		SendMessage(directory_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
		back_button = CreateWindow("BUTTON", "<-", WS_VISIBLE | WS_CHILD | WS_BORDER, 10, 10, 20, 20, hWnd, (HMENU)BACK_BUTTON, NULL, NULL);
		front_button = CreateWindow("BUTTON", "->",WS_VISIBLE | WS_CHILD | WS_BORDER, 30, 10, 20, 20, hWnd, (HMENU)FRONT_BUTTON, NULL, NULL);
		refresh_button = CreateWindow("BUTTON", "새로고침", WS_VISIBLE | WS_CHILD | WS_BORDER, 50, 10, 60, 20, hWnd, (HMENU)REFRESH_BUTTON, NULL, NULL);
		SendMessage(refresh_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
		favorite_button = CreateWindow("BUTTON", "★", WS_VISIBLE | WS_CHILD | WS_BORDER, 622, 10, 20, 20, hWnd, (HMENU)FAVORITE_BUTTON, NULL, NULL);
		SendMessage(favorite_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
		SetFocus(EdittextBox);
		OldEditProc = (WNDPROC)SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)SubEditProc);

		/* 스크롤바 부분 시작*/
		xPos = 0;
		yPos = 0;
		xMax = 1024;
		yMax = 768;
		SetScrollRange(hWnd, SB_VERT, 0, yMax, TRUE);
		SetScrollPos(hWnd, SB_VERT, 0, TRUE);
		SetScrollRange(hWnd, SB_HORZ, 0, xMax, TRUE);
		SetScrollPos(hWnd, SB_HORZ, 0, TRUE);
		SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &Lines, 0);
		WheelUnit = WHEEL_DELTA / Lines;

		/* 하단 상태바 부분 시작*/
		InitCommonControls();
		hState = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", hWnd, 0);
		SBPart[0] = 200;
		SBPart[1] = 500;
		SBPart[2] = 700; //남는 공간 나머지 할당
		SBPart[3] = -1;
		
		SendMessage(hState, SB_SETPARTS, 4, (LPARAM)SBPart);
		SendMessage(hState, SB_SETTEXT, 0, (LPARAM) ""); //Progress bar
		SendMessage(hState, SB_SETTEXT, 1, (LPARAM) ""); //이미지 파일 이름 저장되는 공간
		SendMessage(hState, SB_SETTEXT, 2, (LPARAM) ""); //다운로드파일 버튼
		
		/* 프로그레스바 부분 시작 */
		if (Pos) return 0;
		SendMessage(hState, SB_GETRECT, 0, (LPARAM)&prt);
		hProg = CreateWindow(PROGRESS_CLASS, NULL, WS_CHILD | PBS_SMOOTH | WS_VISIBLE, prt.left, prt.top, prt.right - prt.left, prt.bottom - prt.top, hState, NULL, g_hInst, NULL);
		Pos = 0;
		SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
		SendMessage(hProg, PBM_SETPOS, Pos, 0);
		ShowWindow(hProg, SW_SHOW);
	

		//SendMessage(hState, SB_GETRECT, 2, (LPARAM)&prt); //두번째 빈칸 나중에 활용하기
		break;


		//This is where we change the color of the static to blue. If you only want the cursor
		//to change to a hand when the mouse passes over you don't need this stuff.
	case WM_CTLCOLORSTATIC:
		SetTextColor((HDC)wParam, RGB(0, 0, 255));
		SetBkMode((HDC)wParam, TRANSPARENT);
		return (LONG)GetStockObject(NULL_BRUSH);

		/* 하이퍼링크 부분*/
		/*
	case WM_SETCURSOR:
		if ((HWND)wParam == hwndStatic)
		{
			if (colormsg == 1) return TRUE;
			SendMessage(hwndStatus, SB_SETTEXT, 0, (LONG) "Email : [email protected]");
			SendMessage(hwndStatic, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 1);
			colormsg = 1;
			InvalidateRgn((HWND)hWnd, 0, 1);
			SetCursor(mycur);
			return TRUE;
		}
		//If not on the static, change the font back to normal. You don't have to worry
		//about the cursor, it will change back to the arrow automatically. I use the
		//'colormsg' flag so it doesn't continually set the font when the cursor is moving
		//around, because it causes it to flicker. If you only use the cursor change and
		//don't worry about the font change you don't have to worry.
		if (colormsg == 1)
		{
			colormsg = 0;
			SendMessage(hwndStatus, SB_SETTEXT, 0, 0);
			SendMessage(hwndStatic, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
			InvalidateRgn((HWND)hWnd, 0, 1);
		}
		
		break;
		*/

	/* 마우스 오른쪽 팝업 메뉴 */
	case WM_CONTEXTMENU:
		hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1));
		hPopup = GetSubMenu(hMenu, 0);
		TrackPopupMenu(hPopup, TPM_LEFTALIGN, (short)LOWORD(lParam), (short)HIWORD(lParam), 0, hWnd, NULL);
		DestroyMenu(hMenu);
		break;
		
	case WM_LBUTTONDOWN:
		

		//BitBlt(GetDC(hWnd), 0, 0, 1000, 1000, 0, 0, 0, WHITENESS); //그냥 화면을 하얗게만 할 뿐 뒤에 남아있음
		//image_hyperlink_maker(WinProc_sub, "www.daum.net");
		break;

	case WM_SIZE:
		SendMessage(hState, WM_SIZE, wParam, lParam);
		/* 스크롤바 부분 */
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case 50001:	favorite_clicked(50001);break; case 50002: favorite_clicked(50002);break; case 50003: favorite_clicked(50003);break;
		case 50004:	favorite_clicked(50004);break; case 50005: favorite_clicked(50005);break; case 50006: favorite_clicked(50006);break;
		case 50007:	favorite_clicked(50007);break; case 50008: favorite_clicked(50008);break; case 50009: favorite_clicked(50009);break;
		case 50010:	favorite_clicked(50010);break; case 50011: favorite_clicked(50011);break; case 50012: favorite_clicked(50012);break;

		case IDC_MAIN_BUTTON: // when button is clicked, this will happen: 버튼부분
			SendMessage(EdittextBox, WM_GETTEXT, sizeof(textbox_buffer) / sizeof(textbox_buffer[0]), reinterpret_cast<LPARAM>(textbox_buffer));
			if(input_valid_check(textbox_buffer) == 1) // 주소체크하고 dns 실행할지말지 결정
				Save_visit_page(textbox_buffer);
			InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND);
			UpdateWindow(Main_hWnd);
			break;

		case IDC_VISITPAGE_BUTTON:
			printf("방문기록보기 버튼 클릭!\n");
			Search_visit_page();
			SetWindowText(Main_hWnd, "방문기록보기");
			//ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL);
			InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND);
			UpdateWindow(Main_hWnd);
			break;

		case BACK_BUTTON:
			back_button_page(textbox_buffer);
			InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND);
			UpdateWindow(Main_hWnd);
			break;

		case FRONT_BUTTON:
			front_button_page(textbox_buffer);
			InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND);
			UpdateWindow(Main_hWnd);
			break;

		case REFRESH_BUTTON: //새로고침
			if (textbox_buffer[0] == NULL)
				break;
			input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정
			InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND);
			UpdateWindow(Main_hWnd);
			break;

		case FAVORITE_BUTTON: //즐겨찾기 등록
			favorite_page(textbox_buffer, strlen(textbox_buffer), hWnd);
			break;

		case ID_FILE_40001: //잘라내기
			
			break;
		case ID_FILE_40003: //복사
			
			break;
		case ID_FILE_40004: //삭제
			delresult = DeleteFile(image_file_name); //현재 미구현 디폴트상황
			if(delresult == TRUE)
				MessageBox(NULL, "파일삭제 성공!", "파일삭제!", MB_ICONINFORMATION);
			else
				MessageBox(NULL, "파일이 없습니다!(이미 삭제되거나 없는 파일)", "파일삭제실패!", MB_ICONINFORMATION);
			break;
		case ID_FILE_RENAME: //이름바꾸기
			
			break;
		case ID_FILE_PROPERTY: //속성
			
			break;
		}

		if ((HWND)lParam == hwndStatic) {
			cases = 2; //케이스 2번으로 하고 해야 계속해서 링크를 통해 이미지를 받아올 수 있음
			clientsocket(temp_addr2, temp_port2); //cases = 2이기 때문에 그냥 바로 요청하면 된다.
			InvalidateRect(Main_hWnd, NULL, TRUE);
			UpdateWindow(Main_hWnd);
		}
		break;
		/*
		case WM_CHAR: //사용자로부터 그냥 입력받을 때 동작
		len = strlen(str);
		str[len] = (TCHAR)wParam;
		str[len + 1] = 0;
		InvalidateRect(hWnd, NULL, FALSE);
		break;
		*/

	case WM_PAINT: //사용자로부터 입력받은 것을 화면에 뿌려줌
		hdc = BeginPaint(hWnd, &ps);
		si.cbSize = sizeof(SCROLLINFO);
		si.fMask = SIF_POS;
		GetScrollInfo(hWnd, SB_VERT, &si);
		rt2 = { 10-xPos,50-yPos,300,100 };
		DrawText(hdc, hypertext, -1, &rt2, DT_WORDBREAK | DT_NOCLIP);
		//for (i = 0; i < 1024; i += 50) {
		rt = { 100-xPos,100-yPos,1024,768 }; //for문 안돌려도 된다.
		DrawText(hdc, wow, -1, &rt, DT_CENTER | DT_WORDBREAK | DT_NOCLIP);
	

		//}
		if(image_exist == 1) //이미지가 있을 때만 보여준다.
			Draw_Image(hdc, image_file_name, 100 - xPos+200, 100 - yPos+200);

		SendMessage(hState, SB_SETTEXT, 1, (LPARAM)image_file_name); //하단 상태바에 받은 이미지 파일 이름 출력
		EndPaint(hWnd, &ps);
		break;
		

	case WM_MOUSEWHEEL:
		nScroll = 0;
		SumDelta += (short)HIWORD(wParam);
		while (abs(SumDelta) >= WheelUnit) {
			if (SumDelta > 0) {
				nScroll--;
				SumDelta -= WheelUnit;
			}
			else { //스크롤바 내려갈때
				nScroll++;
				SumDelta += WheelUnit;
			}
		}
		while (nScroll != 0) {
			if (nScroll > 0) {
				SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0), 0);
				nScroll--;
			}
			else {
				SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0), 0);
				nScroll++;
			}
		}

		break;

	case WM_HSCROLL: //가로스크롤
		xlnc = 0;
		switch (LOWORD(wParam)) {
		case SB_LINELEFT:
			xlnc = -1;
			break;
		case SB_LINERIGHT:
			xlnc = -20;
			break;
		case SB_PAGELEFT:
			xlnc = -20;
			break;
		case SB_PAGERIGHT:
			xlnc = 20;
			break;
		case SB_THUMBTRACK:
			xlnc = HIWORD(wParam) - xPos;
			break;
		default:
			//InvalidateRect(Main_hWnd, NULL, TRUE);
			//UpdateWindow(Main_hWnd);
			break;
		}
		//새로운 위치는 최소한 0 이상
		if (xPos + xlnc < 0)
			xlnc = -xPos;
		//새로운 위치는 최대한 xMax 이하
		if (xPos + xlnc > xMax)
			xlnc = xMax - xPos;
		//새로운 위치 계산
		xPos = xPos + xlnc;
		//스크롤 시키고 썸 위치를 다시 계산한다.
		ScrollWindow(hWnd, -xlnc, 0, NULL, NULL);
		SetScrollPos(hWnd, SB_HORZ, xPos, TRUE);
		break;

	case WM_VSCROLL: //세로 스크롤
		ylnc = 0;
		switch (LOWORD(wParam)) {
		case SB_LINEUP:
			ylnc = -1;
			break;
		case SB_LINEDOWN:
			ylnc = 1;
			break;
		case SB_PAGEUP:
			ylnc = -20;
			break;
		case SB_PAGEDOWN:
			ylnc = 20;
			break;
		case SB_THUMBTRACK:
			ylnc = HIWORD(wParam) - yPos;
			break;
		default:
			//InvalidateRect(Main_hWnd, NULL, TRUE);
			//UpdateWindow(Main_hWnd);
			break;
		}
		//새로운 위치는 최소한 0 이상
		if (yPos + ylnc < 0)
			ylnc = -yPos;
		//새로운 위치는 최대한 yMax 이하
		if (yPos + ylnc > yMax)
			ylnc = yMax - yPos;
		//새로운 위치 계산
		yPos = yPos + ylnc;
		//스크롤 시키고 썸 위치를 다시 계산한다.
		ScrollWindow(hWnd, 0, -ylnc, NULL, NULL);
		SetScrollPos(hWnd, SB_VERT, yPos, TRUE);
		MoveWindow(hState, xPos, yPos, LOWORD(lParam), HIWORD(lParam), TRUE); //하단 상태바 이동
		break;

	case WM_DESTROY:
		SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)OldEditProc);
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, iMessage, wParam, lParam);
	}
}
Exemplo n.º 17
0
int WINAPI WinMain(  HINSTANCE hinstance,
                     HINSTANCE hprevinstance,
                     LPSTR     lpcmdline,
                     int       ncmdshow)
{
    WNDCLASSEX  winclass;
    HWND        hwnd;
    MSG         msg;
    HDC         hdc;
    PAINTSTRUCT ps;
    ClockTick   *ticker = new ClockTick(250);

    main_instance = hinstance;

    winclass.cbSize         = sizeof(WNDCLASSEX);
    winclass.style          = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    winclass.lpfnWndProc    = WindowProc;
    winclass.cbClsExtra     = 0;
    winclass.cbWndExtra     = 0;
    winclass.hInstance      = hinstance;
    winclass.hIcon          = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_SMALL));
    winclass.hCursor        = LoadCursor(NULL,IDC_ARROW);
    winclass.hbrBackground  = (HBRUSH) GetStockObject(BLACK_BRUSH);
    winclass.lpszMenuName   = NULL;
    winclass.lpszClassName  = WINDOW_CLASS_NAME;
    winclass.hIconSm		   = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_SMALL));

    if (!RegisterClassEx(&winclass))
    {
        return(0);
    }


    if (!(hwnd = CreateWindowEx( NULL,
                                 WINDOW_CLASS_NAME,
                                 "Sound As Resource Demo",
                                 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                                 0, // X
                                 0, // Y
                                 WINDOW_WIDTH, // WIDTH (INITIAL)
                                 WINDOW_HEIGHT, // HEIGHT (INITIAL)
                                 NULL, // HANDLE TO PARENT
                                 NULL,
                                 hinstance,
                                 NULL )))
    {
        return(0);
    }

    HMENU hmenuhandle = LoadMenu(hinstance,MAKEINTRESOURCE(IDC_TEXTDEMOPG140));

    SetMenu(hwnd,hmenuhandle);

    //ShowCursor(FALSE);

    main_window_handle = hwnd;
    main_instance      = hinstance;

    hdc = GetDC(hwnd);


    while(1)
    {
        if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
            {
                break;
            }

            TranslateMessage(&msg);

            DispatchMessage(&msg);
        }
        if ( ticker->CheckTick())
        {
            SetTextColor(  hdc,
                           RGB(  rand()%256,
                                 rand()%256,
                                 rand()%256)
                        );
            SetBkColor(hdc,RGB(0,0,0));
            SetBkMode(hdc,TRANSPARENT);
            TextOut( hdc,
                     rand()%400,
                     rand()%400,
                     "GDI Text Demo!",
                     strlen("GDI Text Demo!"));
            ValidateRect(hwnd,0);
        }
        if (KEY_DOWN(VK_ESCAPE))
        {
            PostMessage(main_window_handle,WM_DESTROY,0,0);
        }
    } // end while

    ReleaseDC(hwnd,hdc);
    //ShowCursor(TRUE);
    delete ticker;
    return(msg.wParam);

} // end WinMain
Exemplo n.º 18
0
HMENU CFlashVideoDownloadsWnd::Plugin_GetViewMenu()
{
	return LoadMenu (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDM_FVDOWNLOADS_VIEW));
}
Exemplo n.º 19
0
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
	setCurrentThreadName("Main");

	CoInitializeEx(NULL, COINIT_MULTITHREADED);

#ifdef _DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
	PROFILE_INIT();

#if defined(_M_X64) && defined(_MSC_VER) && _MSC_VER < 1900
	// FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). Just disable it.
	_set_FMA3_enable(0);
#endif

	EnableCrashingOnCrashes();

#ifndef _DEBUG
	bool showLog = false;
#else
	bool showLog = true;
#endif

	const std::string &exePath = File::GetExeDirectory();
	VFSRegister("", new DirectoryAssetReader((exePath + "/assets/").c_str()));
	VFSRegister("", new DirectoryAssetReader(exePath.c_str()));

	langRegion = GetDefaultLangRegion();
	osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture();

	char configFilename[MAX_PATH] = { 0 };
	const std::wstring configOption = L"--config=";

	char controlsConfigFilename[MAX_PATH] = { 0 };
	const std::wstring controlsOption = L"--controlconfig=";

	std::vector<std::wstring> wideArgs = GetWideCmdLine();

	for (size_t i = 1; i < wideArgs.size(); ++i) {
		if (wideArgs[i][0] == L'\0')
			continue;
		if (wideArgs[i][0] == L'-') {
			if (wideArgs[i].find(configOption) != std::wstring::npos && wideArgs[i].size() > configOption.size()) {
				const std::wstring tempWide = wideArgs[i].substr(configOption.size());
				const std::string tempStr = ConvertWStringToUTF8(tempWide);
				std::strncpy(configFilename, tempStr.c_str(), MAX_PATH);
			}

			if (wideArgs[i].find(controlsOption) != std::wstring::npos && wideArgs[i].size() > controlsOption.size()) {
				const std::wstring tempWide = wideArgs[i].substr(controlsOption.size());
				const std::string tempStr = ConvertWStringToUTF8(tempWide);
				std::strncpy(controlsConfigFilename, tempStr.c_str(), MAX_PATH);
			}
		}
	}

	// On Win32 it makes more sense to initialize the system directories here 
	// because the next place it was called was in the EmuThread, and it's too late by then.
	InitSysDirectories();

	// Load config up here, because those changes below would be overwritten
	// if it's not loaded here first.
	g_Config.AddSearchPath("");
	g_Config.AddSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
	g_Config.SetDefaultPath(GetSysDirectory(DIRECTORY_SYSTEM));
	g_Config.Load(configFilename, controlsConfigFilename);

	bool debugLogLevel = false;

	const std::wstring gpuBackend = L"--graphics=";

	// The rest is handled in NativeInit().
	for (size_t i = 1; i < wideArgs.size(); ++i) {
		if (wideArgs[i][0] == L'\0')
			continue;

		if (wideArgs[i][0] == L'-') {
			switch (wideArgs[i][1]) {
			case L'l':
				showLog = true;
				g_Config.bEnableLogging = true;
				break;
			case L's':
				g_Config.bAutoRun = false;
				g_Config.bSaveSettings = false;
				break;
			case L'd':
				debugLogLevel = true;
				break;
			}

			if (wideArgs[i] == L"--fullscreen")
				g_Config.bFullScreen = true;

			if (wideArgs[i] == L"--windowed")
				g_Config.bFullScreen = false;

			if (wideArgs[i].find(gpuBackend) != std::wstring::npos && wideArgs[i].size() > gpuBackend.size()) {
				const std::wstring restOfOption = wideArgs[i].substr(gpuBackend.size());

				// Force software rendering off, as picking directx9 or gles implies HW acceleration.
				// Once software rendering supports Direct3D9/11, we can add more options for software,
				// such as "software-gles", "software-d3d9", and "software-d3d11", or something similar.
				// For now, software rendering force-activates OpenGL.
				if (restOfOption == L"directx9") {
					g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D9;
					g_Config.bSoftwareRendering = false;
				} else if (restOfOption == L"gles") {
					g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
					g_Config.bSoftwareRendering = false;
				} else if (restOfOption == L"software") {
					g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
					g_Config.bSoftwareRendering = true;
				}
			}
		}
	}
#ifdef _DEBUG
	g_Config.bEnableLogging = true;
#endif

	if (iCmdShow == SW_MAXIMIZE) {
		// Consider this to mean --fullscreen.
		g_Config.bFullScreen = true;
	}

	LogManager::Init();
	// Consider at least the following cases before changing this code:
	//   - By default in Release, the console should be hidden by default even if logging is enabled.
	//   - By default in Debug, the console should be shown by default.
	//   - The -l switch is expected to show the log console, REGARDLESS of config settings.
	//   - It should be possible to log to a file without showing the console.
	LogManager::GetInstance()->GetConsoleListener()->Init(showLog, 150, 120, "PPSSPP Debug Console");
	
	if (debugLogLevel)
		LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG);

	//Windows, API init stuff
	INITCOMMONCONTROLSEX comm;
	comm.dwSize = sizeof(comm);
	comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES;
	InitCommonControlsEx(&comm);
	timeBeginPeriod(1);
	MainWindow::Init(_hInstance);

	g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS);

	MainWindow::Show(_hInstance);

	HWND hwndMain = MainWindow::GetHWND();
	HWND hwndDisplay = MainWindow::GetDisplayHWND();
	
	//initialize custom controls
	CtrlDisAsmView::init();
	CtrlMemView::init();
	CtrlRegisterList::init();
	CGEDebugger::Init();

	DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));

	host = new WindowsHost(_hInstance, hwndMain, hwndDisplay);
	host->SetWindowTitle(0);

	MainWindow::CreateDebugWindows();

	const bool minimized = iCmdShow == SW_MINIMIZE || iCmdShow == SW_SHOWMINIMIZED || iCmdShow == SW_SHOWMINNOACTIVE;
	if (minimized) {
		MainWindow::Minimize();
	}

	// Emu thread is always running!
	EmuThread_Start();
	InputDevice::BeginPolling();

	HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
	HACCEL hDebugAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_DEBUGACCELS);

	//so.. we're at the message pump of the GUI thread
	for (MSG msg; GetMessage(&msg, NULL, 0, 0); )	// for no quit
	{
		if (msg.message == WM_KEYDOWN)
		{
			//hack to enable/disable menu command accelerate keys
			MainWindow::UpdateCommands();
			 
			//hack to make it possible to get to main window from floating windows with Esc
			if (msg.hwnd != hwndMain && msg.wParam == VK_ESCAPE)
				BringWindowToTop(hwndMain);
		}

		//Translate accelerators and dialog messages...
		HWND wnd;
		HACCEL accel;
		switch (g_activeWindow)
		{
		case WINDOW_MAINWINDOW:
			wnd = hwndMain;
			accel = hAccelTable;
			break;
		case WINDOW_CPUDEBUGGER:
			wnd = disasmWindow[0] ? disasmWindow[0]->GetDlgHandle() : 0;
			accel = hDebugAccelTable;
			break;
		case WINDOW_GEDEBUGGER:
		default:
			wnd = 0;
			accel = 0;
			break;
		}

		if (!TranslateAccelerator(wnd, accel, &msg))
		{
			if (!DialogManager::IsDialogMessage(&msg))
			{
				//and finally translate and dispatch
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
	}

	VFSShutdown();

	InputDevice::StopPolling();
	EmuThread_Stop();

	MainWindow::DestroyDebugWindows();
	DialogManager::DestroyAll();
	timeEndPeriod(1);
	delete host;

	g_Config.Save();
	LogManager::Shutdown();

	if (g_Config.bRestartRequired) {
		W32Util::ExitAndRestart();
	}

	CoUninitialize();

	return 0;
}
Exemplo n.º 20
0
/************************************************************************
* dasm                                                                  *
* - dasm is the application main window.                                *
* - everything the main window does is in this routine (for now) and    *
*   where a response is quick it appears in one of its helper functions *
*   later in this file, otherwise it has been substantial enough to     *
*   warrant its own file and routines........                           *
* - this is long                                                        *
************************************************************************/
LRESULT CALLBACK MainWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	HDC hdc;
	TEXTMETRIC tm;
	POINT point;
	lptr scrll;
	int killcount;
	g_hMainWnd=hwnd;
	RECT tmp_rect;
	switch(message)
	{
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case file_exit:
			SendMessage(g_hMainWnd,WM_CLOSE,0,0);
			break;
		case file_save:
			savefile_text(hwnd,true,false);
			break;
		case get_comment:
			getcomment();
			break;
		case jump_to:
			jumpto();
			break;
		case change_oep:
			changeoep();
			break;
		case save_database:
			savedb();
			break;
		case load_database:
			loaddb();
			break;
		case save_asm:
			savefile_text(hwnd,false,false);
			break;
		case block_saveasm:
			savefile_text(hwnd,false,true);
			break;
		case block_savetext:
			savefile_text(hwnd,true,true);
			break;
		case cm_decrypt:
			decrypterdialog();
			break;
		case file_open:
			newfile();
			break;
		case view_segment:
			segviewer();
			break;
		case view_names:
			namesviewer();
			break;
		case view_imports:
			importsviewer();
			break;
		case view_exports:
			exportsviewer();
			break;
		case view_xrefs:
			xrefsviewer();
			break;
		case make_code:
			g_scheduler.addtask(user_makecode,priority_userrequest,nlptr,NULL);
			break;
		case make_dword:
			g_scheduler.addtask(user_makedword,priority_userrequest,nlptr,NULL);
			break;
		case float_single:
			g_scheduler.addtask(user_makesingle,priority_userrequest,nlptr,NULL);
			break;
		case float_double:
			g_scheduler.addtask(user_makedouble,priority_userrequest,nlptr,NULL);
			break;
		case float_longdouble:
			g_scheduler.addtask(user_makelongdouble,priority_userrequest,nlptr,NULL);
			break;
		case make_word:
			g_scheduler.addtask(user_makeword,priority_userrequest,nlptr,NULL);
			break;
		case make_string:
			g_scheduler.addtask(user_makestring,priority_userrequest,nlptr,NULL);
			break;
		case pascal_string:
			g_scheduler.addtask(user_pascalstring,priority_userrequest,nlptr,NULL);
			break;
		case uc_string:
			g_scheduler.addtask(user_ucstring,priority_userrequest,nlptr,NULL);
			break;
		case up_string:
			g_scheduler.addtask(user_upstring,priority_userrequest,nlptr,NULL);
			break;
		case dos_string:
			g_scheduler.addtask(user_dosstring,priority_userrequest,nlptr,NULL);
			break;
		case general_string:
			g_scheduler.addtask(user_generalstring,priority_userrequest,nlptr,NULL);
			break;
		case argover_dec:
			g_scheduler.addtask(user_argoverdec,priority_userrequest,nlptr,NULL);
			break;
		case arg_single:
			g_scheduler.addtask(user_argsingle,priority_userrequest,nlptr,NULL);
			break;
		case argover_hex:
			g_scheduler.addtask(user_argoverhex,priority_userrequest,nlptr,NULL);
			break;
		case argnegate:
			g_scheduler.addtask(user_argnegate,priority_userrequest,nlptr,NULL);
			break;
		case offset_dseg:
			g_scheduler.addtask(user_argoveroffsetdseg,priority_userrequest,nlptr,NULL);
			break;
		case argover_char:
			g_scheduler.addtask(user_argoverchar,priority_userrequest,nlptr,NULL);
			break;
		case undefine_line:
			g_scheduler.addtask(user_undefineline,priority_userrequest,nlptr,NULL);
			break;
		case undefine_lines:
			g_scheduler.addtask(user_undefinelines,priority_userrequest,nlptr,NULL);
			break;
		case undefine_lines_long:
			g_scheduler.addtask(user_undefinelines_long,priority_userrequest,nlptr,NULL);
			break;
		case block_undefine:
			g_scheduler.addtask(user_undefineblock,priority_userrequest,nlptr,NULL);
			break;
		case block_view:
			blockview();
			break;
		case block_top:
			g_scheduler.addtask(user_marktopblock,priority_userrequest,nlptr,NULL);
			break;
		case block_bottom:
			g_scheduler.addtask(user_markbottomblock,priority_userrequest,nlptr,NULL);
			break;
		case line_jumpto:
			g_scheduler.addtask(user_jumpto,priority_userrequest,nlptr,NULL);
			break;
		case line_jumptoarg2:
			g_scheduler.addtask(user_jumptoarg2,priority_userrequest,nlptr,NULL);
			break;
		case Name_Location:
			namelocation();
			break;
		case help_short:
			DialogBox(g_hInst,MAKEINTRESOURCE(help_shortcuts),hwnd,(DLGPROC)helpshortcuts);
			break;
		case help_about:
			DialogBox(g_hInst,MAKEINTRESOURCE(D_help_about),hwnd,(DLGPROC)habox);
			break;
		case Jump_Back:
			g_scheduler.addtask(user_jumpback,priority_userrequest,nlptr,NULL);
			break;
		case main_search:
			searchengine();
			break;
		case search_again:
			searchmore();
			break;
		case set_bg_color:
			g_options.bgcolor=choosecolour(g_options.bgcolor);
			GetClientRect(g_hMainWnd,&tmp_rect);
			InvalidateRect(g_hMainWnd,&tmp_rect,true);
			g_scheduler.addtask(windowupdate,priority_window,nlptr,NULL);
			break;
		case set_high_color:
			g_options.highcolor=choosecolour(g_options.highcolor);
			GetClientRect(g_hMainWnd,&tmp_rect);
			InvalidateRect(g_hMainWnd,&tmp_rect,true);
			g_scheduler.addtask(windowupdate,priority_window,nlptr,NULL);
			break;
		case set_text_color:
			g_options.textcolor=choosecolour(g_options.textcolor);
			GetClientRect(g_hMainWnd,&tmp_rect);
			InvalidateRect(g_hMainWnd,&tmp_rect,true);
			g_scheduler.addtask(windowupdate,priority_window,nlptr,NULL);
			break;
		case font_system:
			g_options.font=systemfont;
			setupfont();
			break;
		case font_courier:
			g_options.font=courierfont;
			setupfont();
			break;
		case font_courier10:
			g_options.font=courierfont10;
			setupfont();
			break;
		case font_courier12:
			g_options.font=courierfont12;
			setupfont();
			break;
		case font_ansi:
			g_options.font=ansifont;
			setupfont();
			break;
		default:
			return DefWindowProc(hwnd,message,wParam,lParam);
		}
		break;
	case WM_CHAR:
		if(charinputenabled)
			switch(wParam)
		{
			case 'c':
				g_scheduler.addtask(user_makecode,priority_userrequest,nlptr,NULL);
				break;
			case 'C':
				g_scheduler.addtask(user_argoverchar,priority_userrequest,nlptr,NULL);
				break;
			case 'd':
				g_scheduler.addtask(user_makedword,priority_userrequest,nlptr,NULL);
				break;
			case 'D':
				g_scheduler.addtask(user_argoverdec,priority_userrequest,nlptr,NULL);
				break;
			case 'H':
				g_scheduler.addtask(user_argoverhex,priority_userrequest,nlptr,NULL);
				break;
			case '-':
				g_scheduler.addtask(user_argnegate,priority_userrequest,nlptr,NULL);
				break;
			case 'n':
				namelocation();
				break;
			case ';':
				getcomment();
				break;
			case 'o':
				g_scheduler.addtask(user_argoveroffsetdseg,priority_userrequest,nlptr,NULL);
				break;
			case 'p':
				g_scheduler.addtask(user_pascalstring,priority_userrequest,nlptr,NULL);
				break;
			case 's':
				g_scheduler.addtask(user_makestring,priority_userrequest,nlptr,NULL);
				break;
			case 'u':
				g_scheduler.addtask(user_undefineline,priority_userrequest,nlptr,NULL);
				break;
			case 'U':
				g_scheduler.addtask(user_undefinelines,priority_userrequest,nlptr,NULL);
				break;
			case 'w':
				g_scheduler.addtask(user_makeword,priority_userrequest,nlptr,NULL);
				break;
			case 't':
				g_scheduler.addtask(user_marktopblock,priority_userrequest,nlptr,NULL);
				break;
			case 'b':
				g_scheduler.addtask(user_markbottomblock,priority_userrequest,nlptr,NULL);
				break;
			default:
				break;
		}
		break;
	case WM_LBUTTONDOWN:
		dio.setpos(HIWORD(lParam));
		break;
	case WM_RBUTTONDOWN:
		dio.setpos(HIWORD(lParam));
		point.x=LOWORD(lParam);
		point.y=HIWORD(lParam);
		ClientToScreen(g_hMainWnd,&point);
		TrackPopupMenu(rmenu,0,point.x,point.y,0,g_hMainWnd,NULL);
		break;
	case WM_PAINT:
		if(!KillThread)
			DoPaint(hwnd,cxChar,cyChar);
		else
			PaintBack(hwnd);
		ValidateRect(g_hMainWnd,NULL);
		break;
	case WM_CLOSE:
		if(MessageBox(g_hMainWnd,"Are you sure that you want to exit Borg ?\n\rHit Yes To Exit\n\rHit No to Stay","Borg Disassembler",
			MB_ICONEXCLAMATION|MB_YESNO)==IDNO)
			break;
		g_scheduler.stopthread();
		g_scheduler.addtask(quitborg,priority_quit,nlptr,NULL);
		KillThread=true;
		if(InThread)
			SetThreadPriority(ThreadHandle,THREAD_PRIORITY_TIME_CRITICAL);
		DestroyWindow(g_hMainWnd);
		return 0;
	case WM_DESTROY:
		save_reg_entries();
		KillThread=true;
		killcount=0;
		Sleep(0);
		SetPriorityClass(ThreadHandle,HIGH_PRIORITY_CLASS);
		if(InThread)
			while(TestThread())
			{
				killcount++;
				if(killcount>2)
				{
					// this is a nasty way of getting out.
					// sometimes the thread just will not exit nicely when its busy.
					if(TerminateThread(ThreadHandle,1))
					{
						CloseHandle(ThreadHandle);
						break;
					}
				}
			}
			DeleteCriticalSection(&g_hCs);
			PostQuitMessage(0);
			break;
	case WM_SIZE:
		if(wParam==SIZE_MAXIMIZED)
			g_options.winmax=true;
		else if (wParam==SIZE_RESTORED)
			g_options.winmax=false;
		mainwndsize.top=0;
		mainwndsize.left=0;
		mainwndsize.right=LOWORD(lParam);
		mainwndsize.bottom=HIWORD(lParam);
		GetWindowRect(hwndStatusBar,&StatusWindowSize);
		GetWindowRect(g_hMainWnd,&mainwnd);
		MoveWindow(hwndStatusBar,0,mainwndsize.bottom-StatusWindowSize.bottom+StatusWindowSize.top,
			mainwndsize.right,StatusWindowSize.bottom-StatusWindowSize.top,true);
		break;
	case WM_MOUSEWHEEL:
		if (GET_KEYSTATE_WPARAM(wParam) & MK_SHIFT)
		{
			scrll.assign(0,GET_WHEEL_DELTA_WPARAM(wParam)/WHEEL_DELTA);
			g_scheduler.addtask(hscroll,priority_userrequest,scrll,NULL);
		} 
		else
		{
			scrll.assign(0,-GET_WHEEL_DELTA_WPARAM(wParam)/WHEEL_DELTA);
			if(InThread)
				g_scheduler.addtask(scrolling,priority_userrequest,scrll,NULL);
		}
		break;
	case WM_VSCROLL:
		switch(LOWORD(wParam))
		{
		case SB_TOP:
			break;
		case SB_BOTTOM:
			break;
		case SB_LINEUP:
			scrll.assign(0,-1);
			if(InThread)
				g_scheduler.addtask(scrolling,priority_userrequest,scrll,NULL);
			break;
		case SB_LINEDOWN:
			scrll.assign(0,1);
			if(InThread)
				g_scheduler.addtask(scrolling,priority_userrequest,scrll,NULL);
			break;
		case SB_PAGEUP:
			scrll.assign(0,-mainwndsize.bottom/cyChar+1);
			if(InThread)
				g_scheduler.addtask(scrolling,priority_userrequest,scrll,NULL);
			break;
		case SB_PAGEDOWN:
			scrll.assign(0,mainwndsize.bottom/cyChar-1);
			if(InThread)
				g_scheduler.addtask(scrolling,priority_userrequest,scrll,NULL);
			break;
		case SB_THUMBPOSITION:
			scrll.assign(0,HIWORD(wParam));
			if(InThread)
				g_scheduler.addtask(vthumbposition,priority_userrequest,scrll,NULL);
			break;
		default:
			break;
		}
		break;
	case WM_HSCROLL:
		switch(LOWORD(wParam))
		{
		case SB_LINEUP:
			scrll.assign(0,-1);
			g_scheduler.addtask(hscroll,priority_userrequest,scrll,NULL);
			break;
		case SB_LINEDOWN:
			scrll.assign(0,1);
			g_scheduler.addtask(hscroll,priority_userrequest,scrll,NULL);
			break;
		case SB_PAGEUP:
			scrll.assign(0,-8);
			g_scheduler.addtask(hscroll,priority_userrequest,scrll,NULL);
			break;
		case SB_PAGEDOWN:
			scrll.assign(0,8);
			g_scheduler.addtask(hscroll,priority_userrequest,scrll,NULL);
			break;
		case SB_THUMBPOSITION:
			scrll.assign(0,HIWORD(wParam));
			if(InThread)
				g_scheduler.addtask(hthumbposition,priority_userrequest,scrll,NULL);
			break;
		default:
			break;
		}
		break;
	case WM_REPEATNAMEVIEW:
		namesviewer();
		break;
	case WM_REPEATXREFVIEW:
		xrefsviewer();
		break;
		// maximises window, used when the reg is read in at the start to maximise
		// the main window after initialisation of it
	case WM_MAXITOUT:
		ShowWindow(g_hMainWnd,SW_MAXIMIZE);
		break;
	case WM_CREATE:
		optionsinit();
		hdc=GetDC(hwnd);
		SelectObject(hdc,GetStockObject(ANSI_FIXED_FONT));
		GetTextMetrics(hdc,&tm);
		cxChar=tm.tmAveCharWidth;
		cyChar=tm.tmHeight+tm.tmExternalLeading;
		ReleaseDC(hwnd,hdc);
		InitializeCriticalSection(&g_hCs);
		hwndStatusBar=CreateStatusWindow(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|CCS_BOTTOM,
			"No File Loaded",hwnd,2);
		GetWindowRect(hwndStatusBar,&StatusWindowSize);
		GetWindowRect(g_hMainWnd,&mainwnd);
		SetScrollRange(hwnd,SB_VERT,0,VERTSCROLLRANGE,false);
		SetScrollPos(hwnd,SB_VERT,0,false);
		KillThread=false;
		InThread=false;
		rmenu=LoadMenu(g_hInst,MAKEINTRESOURCE(right_click_menu));
		rmenu=GetSubMenu(rmenu,0);
		load_reg_entries();
		setupfont();
		break;
	case WM_KEYDOWN:
		if(!charinputenabled) break;
		switch(wParam)
		{
		case VK_HOME:
			SendMessage(hwnd,WM_VSCROLL,SB_TOP,0L);
			break;
		case VK_PRIOR:
			SendMessage(hwnd,WM_VSCROLL,SB_PAGEUP,0L);
			break;
		case VK_NEXT:
			SendMessage(hwnd,WM_VSCROLL,SB_PAGEDOWN,0L);
			break;
		case VK_DOWN:
			SendMessage(hwnd,WM_VSCROLL,SB_LINEDOWN,0L);
			break;
		case VK_UP:
			SendMessage(hwnd,WM_VSCROLL,SB_LINEUP,0L);
			break;
		case VK_LEFT:
			SendMessage(hwnd,WM_HSCROLL,SB_PAGEUP,0L);
			break;
		case VK_RIGHT:
			SendMessage(hwnd,WM_HSCROLL,SB_PAGEDOWN,0L);
			break;
		case VK_RETURN:
			if(GetKeyState(VK_SHIFT)&0x8000)
				g_scheduler.addtask(user_jumptoarg2,priority_userrequest,nlptr,NULL);
			else
				g_scheduler.addtask(user_jumpto,priority_userrequest,nlptr,NULL);
			break;
		case VK_ESCAPE:
			g_scheduler.addtask(user_jumpback,priority_userrequest,nlptr,NULL);
			break;
		case VK_F1:
			DialogBox(g_hInst,MAKEINTRESOURCE(help_shortcuts),hwnd,(DLGPROC)helpshortcuts);
			break;
		case VK_F3:
			searchmore();
			break;
		default:
			break;
		}
		break;
	default:
		return DefWindowProc(hwnd,message,wParam,lParam);
	}
	return 0;
}
Exemplo n.º 21
0
INT_PTR SWELLAppMain(int msg, INT_PTR parm1, INT_PTR parm2)
{
  switch (msg)
  {
    case SWELLAPP_ONLOAD:
    break;
    case SWELLAPP_LOADED:
      
      if (SWELL_app_stocksysmenu) // set the SWELL default menu, using the .nib'd menu as the default settings
      {
        HMENU menu = CreatePopupMenu();    
        HMENU nm=SWELL_DuplicateMenu(SWELL_app_stocksysmenu);
        if (nm)
        {
          MENUITEMINFO mi={sizeof(mi),MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE,MFT_STRING,0,0,nm,NULL,NULL,0,"SampleApp"};
          InsertMenuItem(menu,0,TRUE,&mi);           
        }    
        SWELL_SetDefaultModalWindowMenu(menu);
      }      
      
      {
        HMENU menu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU1));
        {
          HMENU sm=GetSubMenu(menu,0);
          DeleteMenu(sm,ID_QUIT,MF_BYCOMMAND); // remove QUIT from our file menu, since it is in the system menu on OSX
        
          // remove any trailing separators
          int a= GetMenuItemCount(sm);
          while (a > 0 && GetMenuItemID(sm,a-1)==0) DeleteMenu(sm,--a,MF_BYPOSITION);
        }
        // delete help menu from Windows menu (since we only use it for "About", which is in the system menu
        DeleteMenu(menu,GetMenuItemCount(menu)-1,MF_BYPOSITION);
      
        if (SWELL_app_stocksysmenu) // insert the stock system menu
        {
          HMENU nm=SWELL_DuplicateMenu(SWELL_app_stocksysmenu);
          if (nm)
          {
            MENUITEMINFO mi={sizeof(mi),MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE,MFT_STRING,0,0,nm,NULL,NULL,0,"SampleApp"};
            InsertMenuItem(menu,0,TRUE,&mi);           
          }
        }  
        
        // if we want to set any default modifiers for items in the menus, we can use:
        // SetMenuItemModifier(menu,commandID,MF_BYCOMMAND,'A',FCONTROL) etc.
        
        
        HWND hwnd = CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_DIALOG1),NULL,MainDlgProc);
        
        SetMenu(hwnd,menu); // set the menu for the dialog to our menu (on Windows that menu is set from the .rc, but on SWELL
                            // we need to set it manually (and obviously we've edited the menu anyway)
      }
    break;
    case SWELLAPP_ONCOMMAND:
      // this is to catch commands coming from the system menu etc
      if (g_hwnd && (parm1&0xffff)) SendMessage(g_hwnd,WM_COMMAND,parm1&0xffff,0);
    break;
    case SWELLAPP_DESTROY:
      if (g_hwnd) DestroyWindow(g_hwnd);
    break;
    case SWELLAPP_PROCESSMESSAGE:
      // parm1 = (MSG*), should we want it -- look in swell.h to see what the return values refer to
     break;
  }
  return 0;
}
Exemplo n.º 22
0
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
	Common::EnableCrashingOnCrashes();

	wchar_t modulePath[MAX_PATH];
	GetModuleFileName(NULL, modulePath, MAX_PATH);
	for (size_t i = wcslen(modulePath) - 1; i > 0; i--) {
		if (modulePath[i] == '\\') {
			modulePath[i] = 0;
			break;
		}
	}
	SetCurrentDirectory(modulePath);
	// GetCurrentDirectory(MAX_PATH, modulePath);  // for checking in the debugger

#ifndef _DEBUG
	bool hideLog = true;
#else
	bool hideLog = false;
#endif

	VFSRegister("", new DirectoryAssetReader("assets/"));
	VFSRegister("", new DirectoryAssetReader(""));

	wchar_t lcCountry[256];

	// LOCALE_SNAME is only available in WinVista+
	// Really should find a way to do this in XP too :/
	if (0 != GetLocaleInfo(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcCountry, 256)) {
		langRegion = ConvertWStringToUTF8(lcCountry);
		for (size_t i = 0; i < langRegion.size(); i++) {
			if (langRegion[i] == '-')
				langRegion[i] = '_';
		}
	} else {
		langRegion = "en_US";
	}

	osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture();

	const char *configFilename = NULL;
	const char *configOption = "--config=";

	const char *controlsConfigFilename = NULL;
	const char *controlsOption = "--controlconfig=";

	for (int i = 1; i < __argc; ++i)
	{
		if (__argv[i][0] == '\0')
			continue;
		if (__argv[i][0] == '-')
		{
			if (!strncmp(__argv[i], configOption, strlen(configOption)) && strlen(__argv[i]) > strlen(configOption)) {
				configFilename = __argv[i] + strlen(configOption);
			}
			if (!strncmp(__argv[i], controlsOption, strlen(controlsOption)) && strlen(__argv[i]) > strlen(controlsOption)) {
				controlsConfigFilename = __argv[i] + strlen(controlsOption);
			}
		}
	}

	std::string memstickpath, flash0path;
	GetSysDirectories(memstickpath, flash0path);

	// Load config up here, because those changes below would be overwritten
	// if it's not loaded here first.
	g_Config.AddSearchPath("");
	g_Config.AddSearchPath(memstickpath + "PSP/SYSTEM/");
	g_Config.SetDefaultPath(memstickpath + "PSP/SYSTEM/");
	g_Config.Load(configFilename, controlsConfigFilename);

	// The rest is handled in NativeInit().
	for (int i = 1; i < __argc; ++i)
	{
		if (__argv[i][0] == '\0')
			continue;

		if (__argv[i][0] == '-')
		{
			switch (__argv[i][1])
			{
			case 'l':
				hideLog = false;
				g_Config.bEnableLogging = true;
				break;
			case 's':
				g_Config.bAutoRun = false;
				g_Config.bSaveSettings = false;
				break;
			}

			if (!strncmp(__argv[i], "--fullscreen", strlen("--fullscreen")))
				g_Config.bFullScreen = true;

			if (!strncmp(__argv[i], "--windowed", strlen("--windowed")))
				g_Config.bFullScreen = false;
		}
	}
#ifdef _DEBUG
	g_Config.bEnableLogging = true;
#endif

	LogManager::Init();
	// Consider at least the following cases before changing this code:
	//   - By default in Release, the console should be hidden by default even if logging is enabled.
	//   - By default in Debug, the console should be shown by default.
	//   - The -l switch is expected to show the log console, REGARDLESS of config settings.
	//   - It should be possible to log to a file without showing the console.
	LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");


	//Windows, API init stuff
	INITCOMMONCONTROLSEX comm;
	comm.dwSize = sizeof(comm);
	comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES;
	InitCommonControlsEx(&comm);
	timeBeginPeriod(1);
	MainWindow::Init(_hInstance);

	g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS);

	MainWindow::Show(_hInstance, iCmdShow);

	HWND hwndMain = MainWindow::GetHWND();
	HWND hwndDisplay = MainWindow::GetDisplayHWND();
	
	//initialize custom controls
	CtrlDisAsmView::init();
	CtrlMemView::init();
	CtrlRegisterList::init();
	CGEDebugger::Init();

	DialogManager::AddDlg(memoryWindow[0] = new CMemoryDlg(_hInstance, hwndMain, currentDebugMIPS));
	DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));

	host = new WindowsHost(hwndMain, hwndDisplay);
	host->SetWindowTitle(0);

	MainWindow::CreateDebugWindows();

	// Emu thread is always running!
	EmuThread_Start();

	HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
	HACCEL hDebugAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_DEBUGACCELS);

	//so.. we're at the message pump of the GUI thread
	for (MSG msg; GetMessage(&msg, NULL, 0, 0); )	// for no quit
	{
		//DSound_UpdateSound();

		if (msg.message == WM_KEYDOWN)
		{
			//hack to enable/disable menu command accelerate keys
			MainWindow::UpdateCommands();

			//hack to make it possible to get to main window from floating windows with Esc
			if (msg.hwnd != hwndMain && msg.wParam == VK_ESCAPE)
				BringWindowToTop(hwndMain);
		}

		//Translate accelerators and dialog messages...
		HWND wnd;
		HACCEL accel;
		switch (g_activeWindow)
		{
		case WINDOW_MAINWINDOW:
			wnd = hwndMain;
			accel = hAccelTable;
			break;
		case WINDOW_CPUDEBUGGER:
			wnd = disasmWindow[0]->GetDlgHandle();
			accel = hDebugAccelTable;
			break;
		case WINDOW_GEDEBUGGER:
		default:
			wnd = 0;
			accel = 0;
			break;
		}

		if (!TranslateAccelerator(wnd, accel, &msg))
		{
			if (!DialogManager::IsDialogMessage(&msg))
			{
				//and finally translate and dispatch
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
	}

	VFSShutdown();

	EmuThread_Stop();

	DialogManager::DestroyAll();
	timeEndPeriod(1);
	delete host;
	g_Config.Save();
	LogManager::Shutdown();
	return 0;
}
Exemplo n.º 23
0
Arquivo: main.cpp Projeto: Gxsghsn/xy2
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX wndClass = { 0 };							//用WINDCLASSEX定义了一个窗口类
	wndClass.cbSize = sizeof(WNDCLASSEX);			//设置结构体的字节数大小
	wndClass.style = CS_HREDRAW | CS_VREDRAW;	//设置窗口的样式
	wndClass.lpfnWndProc = WndProc;					//设置指向窗口过程函数的指针
	wndClass.cbClsExtra = 0;								//窗口类的附加内存,取0就可以了
	wndClass.cbWndExtra = 0;							//窗口的附加内存,依然取0就行了
	wndClass.hInstance = hInstance;						//指定包含窗口过程的程序的实例句柄。
	wndClass.hIcon = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);  //本地加载自定义ico图标
	wndClass.hCursor = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);    //指定窗口类的光标句柄。
	wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);  //为hbrBackground成员指定一个白色画刷句柄	
	wndClass.lpszMenuName = NULL;						//用一个以空终止的字符串,指定菜单资源的名字。
	wndClass.lpszClassName = L"ForTheDreamOfGameDevelop";		//用一个以空终止的字符串,指定窗口类的名字。

	if (!RegisterClassEx(&wndClass))				//设计完窗口后,需要对窗口类进行注册,这样才能创建该类型的窗口
		return -1;

	HWND hwnd = CreateWindow(L"ForTheDreamOfGameDevelop", WINDOW_TITLE,				//喜闻乐见的创建窗口函数CreateWindow
		WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH,
		WINDOW_HEIGHT, NULL, NULL, hInstance, NULL);

	MoveWindow(hwnd, 250, 80, WINDOW_WIDTH, WINDOW_HEIGHT, true);		//调整窗口显示时的位置,使窗口左上角位于(250,80)处
	ShowWindow(hwnd, nShowCmd);    //调用ShowWindow函数来显示窗口
	UpdateWindow(hwnd);						//对窗口进行更新,就像我们买了新房子要装修一样

	//游戏资源的初始化,若初始化失败,弹出一个消息框,并返回FALSE
	if (!Game_Init(hwnd))
	{
		MessageBox(hwnd, L"资源初始化失败", L"消息窗口", 0); //使用MessageBox函数,创建一个消息窗口
		return FALSE;
	}
	PlaySound(L"GameMedia\\梦幻西游原声-战斗1-森林.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); //循环播放背景音乐 

	hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(123));
	SetMenu(hwnd, hMenu);

	MSG msg = { 0 };				//定义并初始化msg
	while (msg.message != WM_QUIT)		//使用while循环,如果消息不是WM_QUIT消息,就继续循环
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))   //查看应用程序消息队列,有消息时将队列中的消息派发出去。
		{
			TranslateMessage(&msg);		//将虚拟键消息转换为字符消息
			DispatchMessage(&msg);			//分发一个消息给窗口程序。
		}
		else
		{
			g_tNow = GetTickCount();   //获取当前系统时间
			if (g_tNow - g_tPre >= 60){
				if (nowscen == 1)
					Game_Fight(hwnd);
				else{
					Game_Paint(hwnd);
				}
			}
		}
	}

	UnregisterClass(L"ForTheDreamOfGameDevelop", wndClass.hInstance);  //程序准备结束,注销窗口类
	return 0;
}
Exemplo n.º 24
0
CMainWindow::CMainWindow(CPsfVm& virtualMachine)
    : Framework::Win32::CDialog(MAKEINTRESOURCE(IDD_MAINWINDOW))
    , m_virtualMachine(virtualMachine)
    , m_ready(false)
    , m_frames(0)
    , m_lastUpdateTime(~0)
    , m_selectedAudioPlugin(DEFAULT_SOUND_HANDLER_ID)
    , m_selectedCharEncoding(DEFAULT_CHAR_ENCODING_ID)
    , m_playlistPanel(NULL)
    , m_fileInformationPanel(NULL)
    , m_spu0RegViewPanel(NULL)
    , m_spu1RegViewPanel(NULL)
    , m_currentPlaylistItem(0)
    , m_repeatMode(DEFAULT_REPEAT_MODE)
    , m_trackLength(0)
    , m_accel(CreateAccelerators())
    , m_reverbEnabled(true)
    , m_playListOnceIcon(NULL)
    , m_repeatListIcon(NULL)
    , m_shuffleListIcon(NULL)
    , m_repeatTrackIcon(NULL)
    , m_toolTip(NULL)
    , m_trayPopupMenu(NULL)
    , m_configPopupMenu(NULL)
    , m_useTrayIcon(false)
    , m_trayIconServer(NULL)
    , m_taskBarList(NULL)
    , m_randomSeed(0)
{
	OSVERSIONINFO versionInfo;
	memset(&versionInfo, 0, sizeof(OSVERSIONINFO));
	versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&versionInfo);
	if(versionInfo.dwMajorVersion > 6)
	{
		m_useTrayIcon = false;
	}
	else if(versionInfo.dwMajorVersion == 6)
	{
		m_useTrayIcon = versionInfo.dwMinorVersion < 1;
	}
	else
	{
		m_useTrayIcon = true;
	}
#ifdef FORCE_ENABLE_TRAYICON
	m_useTrayIcon = true;
#endif

	if(!m_useTrayIcon)
	{
		m_taskBarList = new Framework::Win32::CTaskBarList();
	}

	{
		srand(static_cast<unsigned int>(time(NULL)) * 0x13579ACD);
		float delta = (static_cast<float>(rand()) / static_cast<float>(RAND_MAX));
		m_randomSeed = delta * static_cast<float>(0xCAFECAFE) + 0xDAEBB042;
	}

	CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_REVERB_ENABLED, true);
	CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_SOUNDHANDLER_ID, DEFAULT_SOUND_HANDLER_ID);
	CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_CHAR_ENCODING_ID, DEFAULT_CHAR_ENCODING_ID);
	CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_REPEAT_MODE, DEFAULT_REPEAT_MODE);

	m_reverbEnabled = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_REVERB_ENABLED);
	m_repeatMode = static_cast<REPEAT_MODE>(CAppConfig::GetInstance().GetPreferenceInteger(PREF_REPEAT_MODE));

	LoadAudioPluginPreferences();
	LoadCharEncodingPreferences();

	for(unsigned int i = 0; i < MAX_PANELS; i++)
	{
		m_panels[i] = NULL;
	}

	SetClassPtr();

	SetTimer(m_hWnd, TIMER_UPDATE_CLOCK, 200, NULL);
	SetTimer(m_hWnd, TIMER_UPDATE_FADE, 50, NULL);
	SetTimer(m_hWnd, TIMER_UPDATE_DISCOVERIES, 100, NULL);

	{
		int smallIconSizeX = GetSystemMetrics(SM_CXSMICON);
		int smallIconSizeY = GetSystemMetrics(SM_CYSMICON);
		int bigIconSizeX = GetSystemMetrics(SM_CXICON);
		int bigIconSizeY = GetSystemMetrics(SM_CYICON);

		HICON smallIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, smallIconSizeX, smallIconSizeY, 0));
		HICON bigIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, bigIconSizeX, bigIconSizeY, 0));

		SetIcon(ICON_SMALL, smallIcon);
		SetIcon(ICON_BIG, bigIcon);
	}

	m_trayPopupMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TRAY_POPUP));
	m_configPopupMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_CONFIG_POPUP));

	m_virtualMachine.OnNewFrame.connect(std::bind(&CMainWindow::OnNewFrame, this));

	m_toolTip = new Framework::Win32::CToolTip(m_hWnd);
	m_toolTip->Activate(true);

	ChangeAudioPlugin(FindAudioPlugin(m_selectedAudioPlugin));

	m_playListOnceIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PLAYONCE), IMAGE_ICON, 16, 16, 0));
	m_repeatListIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_REPEAT_LIST), IMAGE_ICON, 16, 16, 0));
	m_shuffleListIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SHUFFLE_LIST), IMAGE_ICON, 16, 16, 0));
	m_repeatTrackIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_REPEAT_TRACK), IMAGE_ICON, 16, 16, 0));
	m_configIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_CONFIG), IMAGE_ICON, 16, 16, 0));
	m_playIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PLAY), IMAGE_ICON, 16, 16, 0));
	m_pauseIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PAUSE), IMAGE_ICON, 16, 16, 0));
	m_prevTrackIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PREV_TRACK), IMAGE_ICON, 16, 16, 0));
	m_nextTrackIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NEXT_TRACK), IMAGE_ICON, 16, 16, 0));

	m_timerLabel = Framework::Win32::CStatic(GetItem(IDC_TIMER_LABEL));
	m_titleLabel = Framework::Win32::CStatic(GetItem(IDC_TITLE_LABEL));

	m_placeHolder = Framework::Win32::CStatic(GetItem(IDC_PLACEHOLDER));

	m_configButton = Framework::Win32::CButton(GetItem(IDC_CONFIG_BUTTON));
	m_toolTip->AddTool(m_configButton.m_hWnd, _T("Configuration"));
	m_configButton.SetIcon(m_configIcon);

	m_repeatButton = Framework::Win32::CButton(GetItem(IDC_REPEAT_BUTTON));
	m_toolTip->AddTool(m_repeatButton.m_hWnd, _T(""));
	UpdateRepeatButton();

	m_pauseButton = Framework::Win32::CButton(GetItem(IDC_PAUSE_BUTTON));

	//Initialize symbol fonts
	CreateSymbolFonts();

	{
		m_pauseButton.SetFont(m_webdingsFont);
		SendMessage(GetItem(ID_FILE_PREVIOUSTRACK), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0);
		SendMessage(GetItem(ID_FILE_NEXTTRACK), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0);
		SendMessage(GetItem(IDC_PREVTAB_BUTTON), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0);
		SendMessage(GetItem(IDC_NEXTTAB_BUTTON), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0);
	}

	if(m_segoeUiSymbolFont.IsValid())
	{
		SendMessage(GetItem(IDC_EJECT_BUTTON), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_segoeUiSymbolFont)), 0);
		SendMessage(GetItem(IDC_EJECT_BUTTON), WM_SETTEXT, NULL, reinterpret_cast<LPARAM>(_T("\u23CF")));
	}

	//Create tray icon
	if(m_useTrayIcon)
	{
		m_trayIconServer = new Framework::Win32::CTrayIconServer();

		Framework::Win32::CTrayIcon* trayIcon = m_trayIconServer->Insert();
		trayIcon->SetIcon(LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN)));
		trayIcon->SetTip(_T("PsfPlayer"));

		m_trayIconServer->RegisterHandler(std::bind(&CMainWindow::OnTrayIconEvent, this,
		                                            std::placeholders::_1, std::placeholders::_2));
	}

	//Create play list panel
	m_playlistPanel = new CPlaylistPanel(m_hWnd, m_playlist);
	m_playlistPanel->OnItemDblClick.connect(std::bind(&CMainWindow::OnPlaylistItemDblClick, this, std::placeholders::_1));
	m_playlistPanel->OnAddClick.connect(std::bind(&CMainWindow::OnPlaylistAddClick, this));
	m_playlistPanel->OnRemoveClick.connect(std::bind(&CMainWindow::OnPlaylistRemoveClick, this, std::placeholders::_1));
	m_playlistPanel->OnSaveClick.connect(std::bind(&CMainWindow::OnPlaylistSaveClick, this));

	//Create file information panel
	m_fileInformationPanel = new CFileInformationPanel(m_hWnd);

	//Create RegView panels
	m_spu0RegViewPanel = new CSpuRegViewPanel(m_hWnd, _T("SPU0"));
	m_spu1RegViewPanel = new CSpuRegViewPanel(m_hWnd, _T("SPU1"));

	//Initialize panels
	m_panels[0] = m_playlistPanel;
	m_panels[1] = m_fileInformationPanel;
	m_panels[2] = m_spu0RegViewPanel;
	m_panels[3] = m_spu1RegViewPanel;

	CreateAudioPluginMenu();
	UpdateAudioPluginMenu();

	CreateCharEncodingMenu();
	UpdateCharEncodingMenu();

	UpdateClock();
	UpdateTitle();
	UpdatePlaybackButtons();
	UpdateConfigMenu();

	m_currentPanel = -1;
	ActivatePanel(0);
}
Exemplo n.º 25
0
Arquivo: gui.c Projeto: djs55/stunnel
static int win_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR command_line, int nCmdShow) {
#ifdef _WIN32_WCE
    WNDCLASS wc;
#else
    WNDCLASSEX wc;
#endif
    MSG msg;
    LPTSTR classname=win32_name;

    /* register the class */
#ifndef _WIN32_WCE
    wc.cbSize=sizeof(WNDCLASSEX);
#endif
    wc.style=CS_VREDRAW|CS_HREDRAW;
    wc.lpfnWndProc=wndProc;
    wc.cbClsExtra=wc.cbWndExtra=0;
    wc.hInstance=hInstance;
    wc.hIcon=LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
    wc.hCursor=LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground=(HBRUSH)(COLOR_WINDOW + 1);
    wc.lpszMenuName=NULL;
    wc.lpszClassName=classname;
    small_icon=LoadImage(hInstance, MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON,
        GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
#ifdef _WIN32_WCE
    RegisterClass(&wc);
#else
    wc.hIconSm=small_icon; /* 16x16 icon */
    RegisterClassEx(&wc);
#endif

    /* create main window */
    if(options.option.taskbar) {/* save menu resources */
        htraymenu=LoadMenu(ghInst, MAKEINTRESOURCE(IDM_TRAYMENU));
        hpopup=GetSubMenu(htraymenu, 0);
    }

#ifdef _WIN32_WCE
    hwnd=CreateWindow(classname, win32_name, 0,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
        NULL, NULL, hInstance, NULL);
#else
    hmainmenu=LoadMenu(ghInst, MAKEINTRESOURCE(IDM_MAINMENU));
    hwnd=CreateWindow(classname, win32_name, WS_TILEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
        NULL, hmainmenu, hInstance, NULL);
#endif

    if(error_mode) /* log window is hidden by default */
        set_visible(1);
    else /* create the main thread */
        _beginthread(ThreadFunc, 0, NULL);

    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return msg.wParam;
}
Exemplo n.º 26
0
// IDocHostUIHandler
STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, IDispatch *pdispReserved) {
    IOleCommandTarget * pOleCommandTarget;
    IOleWindow * pOleWindow;
    HWND hSPWnd;
    if (builder == NULL) {
        return S_OK;
    }
    if (SUCCEEDED(pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&pOleCommandTarget))) {
        if (SUCCEEDED(pOleCommandTarget->QueryInterface(IID_IOleWindow, (void**)&pOleWindow))) {
            pOleWindow->GetWindow(&hSPWnd);
            HMENU hMenu;
            hMenu = GetSubMenu(LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXTMENU)),0);
            CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)hMenu,0);
            if (dwID == 5) { // anchor
                EnableMenuItem(hMenu, ID_MENU_COPYLINK, MF_BYCOMMAND | MF_ENABLED);
            }
            if (dwID == 4) { // text select
                EnableMenuItem(hMenu, ID_MENU_COPY, MF_BYCOMMAND | MF_ENABLED);
            }
            if (builder!=NULL) {

            }
            int iSelection = TrackPopupMenu(hMenu,
                                            TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
                                            ppt->x,
                                            ppt->y,
                                            0,
                                            hwnd,
                                            (RECT*)NULL);
            DestroyMenu(hMenu);
            if (iSelection == ID_MENU_CLEARLOG) {
                /*
                IEVIEWEVENT event;
                event.cbSize = sizeof(IEVIEWEVENT);
                event.dwFlags=0;
                event.codepage = CP_ACP;
                BSTR selection = (BSTR)getSelection(&event);
                if (selection == NULL) {
                	MessageBoxW(NULL, L"", L"NULL SELECTION", MB_OK);
                } else if (wcslen(selection)==0) {
                	MessageBoxW(NULL, selection, L"EMPTY SELECTION", MB_OK);
                } else {
                	MessageBoxW(NULL, selection, L"SELECTION", MB_OK);
                }
                event.dwFlags=IEEF_NO_UNICODE;
                char *selectionA = (char *)getSelection(&event);
                if (selectionA == NULL) {
                	MessageBoxA(NULL, "", "NULL SELECTION", MB_OK);
                } else if (strlen(selectionA)==0) {
                	MessageBoxA(NULL, selectionA, "EMPTY SELECTION", MB_OK);
                } else {
                	MessageBoxA(NULL, selectionA, "SELECTION", MB_OK);
                }
                */
                clear();
            } else {
                SendMessage(hSPWnd, WM_COMMAND, iSelection, (LPARAM) NULL);
            }
            pOleWindow->Release();
        }
        pOleCommandTarget->Release();
    }
    return S_OK;
}
Exemplo n.º 27
0
BOOL CALLBACK ViewFSNitroProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
			{
				fs = new FS_NITRO();

				if (!fs)
				{
					msgbox->error("Error reading FS from ROM");
					SendMessage(hWnd, WM_CLOSE, 0, 0);
					return TRUE;
				}

				HWND tree = GetDlgItem(hWnd, IDC_FILES_TREE);
				SendMessage(tree, WM_SETREDRAW, (WPARAM)false, 0);

				//HBITMAP hBmp;
				HICON hIcon = NULL;
				HIMAGELIST hIml = ImageList_Create(16, 16, ILC_COLORDDB | ILC_HIGHQUALITYSCALE, 3, 0);
				// Open folder icon
				hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_FOLDER_OPEN));
				int iFolderOpen = ImageList_AddIcon(hIml, hIcon);
				DeleteObject(hIcon);
				// Closed folder icon
				hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_FOLDER_CLOSED));
				int iFolderClosed = ImageList_AddIcon(hIml, hIcon);
				DeleteObject(hIcon);
				// Binary file icon
				hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_FILE_BINARY));
				int iFileBinary = ImageList_AddIcon(hIml, hIcon);
				DeleteObject(hIcon);

				TreeView_SetImageList(tree, hIml, TVSIL_NORMAL);
				
				const u32 numDirs = fs->getNumDirs();
				const u32 numFiles = fs->getNumFiles();
				HTREEITEM *dirs = new HTREEITEM[numDirs];
				memset(dirs, 0, sizeof(HTREEITEM) * numDirs);

				//printf("Dirs: %d\n", numDirs);
				//printf("Files: %d\n", numFiles);

				TVINSERTSTRUCT item;
				// data folder
				memset(&item, 0, sizeof(TVINSERTSTRUCT));
				item.hParent = TVI_ROOT;
				item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;;
				item.item.pszText = (LPSTR)"data";
				item.item.iImage = iFolderOpen;
				item.item.iSelectedImage = iFolderClosed;
				item.item.lParam = 0xFFFF;
				HTREEITEM hData = TreeView_InsertItem(tree, &item);
				
				// overlay folder
				memset(&item, 0, sizeof(TVINSERTSTRUCT));
				item.hParent = TVI_ROOT;
				item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;;
				item.item.pszText = (LPSTR)"overlay";
				item.item.iImage = iFolderOpen;
				item.item.iSelectedImage = iFolderClosed;
				item.item.lParam = 0xFFFE;
				HTREEITEM hOverlay = TreeView_InsertItem(tree, &item);

				for (u32 i = 1; i < numDirs; i++)
				{
					u16 id = (i | 0xF000);
					u16 parent = fs->getDirParrentByID(id) & 0x0FFF;

					string name = fs->getDirNameByID(id);
					//printf("%s\n", name.c_str());
					TVINSERTSTRUCT item;
					memset(&item, 0, sizeof(item));
					if (parent == 0)
						item.hParent = hData;
					else
						item.hParent = dirs[parent];

					item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
					item.item.pszText = (LPSTR)name.c_str();
					item.item.iImage = iFolderOpen;
					item.item.iSelectedImage = iFolderClosed;
					item.item.lParam = id;

					dirs[i] = TreeView_InsertItem(tree, &item);
				}

				for (u32 i = 0; i < numFiles; i++)
				{
					u16 parent = fs->getFileParentById(i);
					if (parent == 0xFFFF) continue;

					parent &= 0x0FFF;
					
					string name = fs->getFileNameByID(i);
					TVINSERTSTRUCT item;
					memset(&item, 0, sizeof(item));
					if (fs->isOverlay(i))
					{
						item.hParent = hOverlay;
					}
					else
					{
						if (parent == 0)
							item.hParent = hData;
						else
							item.hParent = dirs[parent];
					}

					item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
					item.item.pszText = (LPSTR)name.c_str();
					item.item.iImage = iFileBinary;
					item.item.iSelectedImage = iFileBinary;
					item.item.lParam = i;
					TreeView_InsertItem(tree, &item);
				}
				delete [] dirs;
				SendMessage(tree, WM_SETREDRAW, (WPARAM)true, 0);

				popupMenu = LoadMenu(hAppInst, MAKEINTRESOURCE(MENU_FSNITRO));
			}
		return FALSE;

		case WM_CLOSE:
			if (fs)
			{
				delete fs;
				fs = NULL;
			}
			if (popupMenu)
			{
				DestroyMenu(popupMenu);
				popupMenu = NULL;
			}
			PostQuitMessage(0);
		return TRUE;

		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDCANCEL:
					SendMessage(hWnd, WM_CLOSE, 0, 0);
				return TRUE;

				case ID_FSNITRO_VIEW:
					if (currentFileID < 0xF000)
					{
						if (RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*)))
							OpenToolWindow(new CMemView(MEMVIEW_ROM, fs->getStartAddrById(currentFileID)));
						return TRUE;
					}
				return FALSE;

				case ID_EXTRACTFILE:
				case ID_EXTRACTALL:
					{
						char tmp_path[MAX_PATH] = {0};
						
						BROWSEINFO bp={0};
						memset(&bp, 0, sizeof(bp));
						bp.hwndOwner = hWnd;
						bp.pidlRoot = NULL;
						bp.pszDisplayName = NULL;
						bp.lpszTitle = "Select destination directory";
						bp.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_USENEWUI;
						bp.lpfn = BrowseCallbackProc;
		
						LPITEMIDLIST tmp = SHBrowseForFolder((LPBROWSEINFO)&bp);
						if (tmp)
						{
							memset(tmp_path, 0, sizeof(tmp_path));
							SHGetPathFromIDList(tmp, tmp_path);
							if (tmp_path[strlen(tmp_path)-1] != '\\')
								tmp_path[strlen(tmp_path)] = '\\';

							if (LOWORD(wParam) == ID_EXTRACTALL)
							{
								string tmp = (string)tmp_path + (string)path.GetRomNameWithoutExtension() + (string)"\\";
								mkdir(tmp.c_str(),0777);
								HWND progress = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_PROGRESS_WND), NULL, (DLGPROC)ProgressWnd);
								ShowWindow(progress, SW_SHOW);
								UpdateWindow(progress);
								fs->extractAll(tmp, extractCallback);
								DestroyWindow(progress);
							}
							else
							{
								if (currentFileID < 0xF000)
									fs->extractFile(currentFileID, (string)tmp_path);
							}
						}
					}
				return TRUE;
			}
		return FALSE;

		case WM_NOTIFY:
			{
				LPNMHDR notify = (LPNMHDR)lParam;
				if (wParam == IDC_FILES_TREE)
				{
					switch (notify->code)
					{
						case NM_DBLCLK:
							if (currentFileID < 0xF000)
							{
								if (RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*)))
									OpenToolWindow(new CMemView(MEMVIEW_ROM, fs->getStartAddrById(currentFileID)));
								return TRUE;
							}
							return FALSE;

						case NM_RCLICK:
							{
								DWORD tmp = GetMessagePos();
								POINTS pos = MAKEPOINTS(tmp);
								HTREEITEM hItem = TreeView_GetNextItem(notify->hwndFrom, 0, TVGN_DROPHILITE);
								if(hItem)
									TreeView_SelectItem(notify->hwndFrom, hItem);
								TVITEM pitem;
								HTREEITEM item = TreeView_GetSelection(GetDlgItem(hWnd, IDC_FILES_TREE));

								memset(&pitem, 0, sizeof(pitem));
								pitem.hItem = item;
								pitem.mask = TVIF_PARAM;
								TreeView_GetItem(GetDlgItem(hWnd, IDC_FILES_TREE), &pitem);
								
								currentFileID = pitem.lParam;
								refreshQView(hWnd, currentFileID);
								EnableMenuItem(popupMenu, ID_EXTRACTFILE, MF_BYCOMMAND | ((currentFileID < 0xF000)?MF_ENABLED:MF_GRAYED));
								EnableMenuItem(popupMenu, ID_FSNITRO_VIEW, MF_BYCOMMAND | ((currentFileID < 0xF000)?MF_ENABLED:MF_GRAYED));
								SetMenuDefaultItem(GetSubMenu(popupMenu, 0), ID_FSNITRO_VIEW, FALSE);
								TrackPopupMenu(GetSubMenu(popupMenu, 0), TPM_LEFTALIGN | TPM_RIGHTBUTTON, pos.x, pos.y, NULL, hWnd, NULL);
							}
						break;

						case TVN_SELCHANGED:
							{
								LPNMTREEVIEW sel = (LPNMTREEVIEW)lParam;
								char buf[256] = {0};
								
								currentFileID = sel->itemNew.lParam;
								refreshQView(hWnd, currentFileID);

								if ((currentFileID & 0xF000) == 0xF000)
								{
									SetWindowText(GetDlgItem(hWnd, IDC_FILE_INFO), "");
								}
								else
								{
									u32 start = fs->getStartAddrById(currentFileID);
									u32 end = fs->getEndAddrById(currentFileID);
									u32 size = (end - start);
									sprintf(buf, "[%08X-%08X] size %u", start, end, size);
									SetWindowText(GetDlgItem(hWnd, IDC_FILE_INFO), buf);
								}
							}
						break;
					}
				}
			}
		return FALSE;
	}
	return FALSE;
}
Exemplo n.º 28
0
//
//	Main window procedure
//
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	int width, height, heightsb;
	HIMAGELIST hImgList;
	RECT rect;
	HDWP hdwp;
	NMHDR *nmhdr;
	TCHAR msgstr[MAX_PATH+200];

	switch(msg)
	{
	case WM_CREATE:
		g_hwndTextView  = CreateTextView(hwnd);
		g_hwndStatusbar = CreateStatusBar(hwnd);

		TextView_SetContextMenu(g_hwndTextView, GetSubMenu(LoadMenu(GetModuleHandle(0),
			MAKEINTRESOURCE(IDR_MENU2)), 0));

		// load the image list
		hImgList = ImageList_LoadImage(
			GetModuleHandle(0), 
			MAKEINTRESOURCE(IDB_BITMAP1), 
			16, 0, 
			RGB(255,0,255),
			IMAGE_BITMAP,
			LR_LOADTRANSPARENT|LR_CREATEDIBSECTION
			);
		
		TextView_SetImageList(g_hwndTextView, hImgList);

		// highlight specific lines with image-index "1"
		//TextView_SetLineImage(g_hwndTextView, 16, 1);
		//TextView_SetLineImage(g_hwndTextView, 5,  1);
		//TextView_SetLineImage(g_hwndTextView, 36, 1);
		//TextView_SetLineImage(g_hwndTextView, 11, 1);

		// tell windows that we can handle drag+drop'd files
		DragAcceptFiles(hwnd, TRUE);
		return 0;

	case WM_DROPFILES:
		HandleDropFiles(hwnd, (HDROP)wParam);
		return 0;

	case WM_DESTROY:
		SaveFileData(g_szFileName, hwnd);
		PostQuitMessage(0);
		DeleteObject(g_hFont);
		return 0;

	//case WM_NCCALCSIZE:
	//	return NcCalcSize(hwnd, wParam, lParam);

	case WM_INITMENU:
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_LINENUMBERS,	g_fLineNumbers);
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_LONGLINES,		g_fLongLines);
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_SAVEEXIT,		g_fSaveOnExit);
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_STATUSBAR,		g_fShowStatusbar);
		//CheckMenuCommand((HMENU)wParam, IDM_VIEW_SEARCHBAR,		g_hwndSearchBar ? TRUE : FALSE);

		EnableMenuCommand((HMENU)wParam, IDM_EDIT_UNDO,		TextView_CanUndo(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_REDO,		TextView_CanRedo(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_PASTE,	IsClipboardFormatAvailable(CF_TEXT));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_COPY,		TextView_GetSelSize(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_CUT,		TextView_GetSelSize(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_DELETE,	TextView_GetSelSize(g_hwndTextView));

		return 0;

	//case WM_USER:
	//	wsprintf(msgstr, _T("%s\n\nThis file has been modified outside of Neatpad.")
	//					 _T("Do you wish to reload it?"), g_szFileName);
	//	MessageBox(hwnd, msgstr, _T("Neatpad"), MB_ICONQUESTION|MB_YESNO);
	//
	//	return 0;

	case WM_ENABLE:

		// keep the modeless find/replace dialog in the same enabled state as the main window
		EnableWindow(g_hwndSearchDlg, (BOOL)wParam);
		return 0;

	case WM_MENUSELECT:
		StatusBarMenuSelect(hwnd, g_hwndStatusbar, wParam, lParam);
		return 0;

	case WM_NOTIFY:
		nmhdr = (NMHDR *)lParam;
		
		if(nmhdr->hwndFrom == g_hwndTextView)
			return TextViewNotifyHandler(hwnd, nmhdr);
		else
			return NotifyHandler(hwnd, nmhdr);

	case WM_COMMAND:
		return CommandHandler(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);

	case WM_SETFOCUS:
		SetFocus(g_hwndTextView);
		return 0;

	case WM_CLOSE:
		
		// does the file need saving?
		if(TextView_CanUndo(g_hwndTextView))
		{
			UINT r;
			wsprintf(msgstr, _T("Do you want to save changes to\r\n%s?"), g_szFileName);
			r = MessageBox(hwnd, msgstr, APP_TITLE, MB_YESNOCANCEL | MB_ICONQUESTION);

			if(r == IDCANCEL)
				return 0;
		}

		DestroyWindow(hwnd);
		return 0;

	case WM_SIZE:

		// resize the TextView and StatusBar to fit within the main window's client area
		width  = (short)LOWORD(lParam);
		height = (short)HIWORD(lParam);
		
		GetWindowRect(g_hwndStatusbar, &rect);
		heightsb = rect.bottom-rect.top;

		hdwp = BeginDeferWindowPos(3);
		
		if(g_fShowStatusbar)
		{
			DeferWindowPos(hdwp, g_hwndStatusbar, 0, 0, height - heightsb, width, heightsb, SWP_SHOWWINDOW);
		//	MoveWindow(g_hwndStatusbar, 0, height - heightsb, width, heightsb, TRUE);
			height -= heightsb;
		}

		DeferWindowPos(hdwp, g_hwndTextView, 0,  0, 0, width, height, SWP_SHOWWINDOW);
		//MoveWindow(g_hwndTextView, 0, 0, width, height, TRUE);

		EndDeferWindowPos(hdwp);

		SetStatusBarParts(g_hwndStatusbar);

		return 0;

	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
Exemplo n.º 29
0
// WINMAIN ////////////////////////////////////////////////
int WINAPI WinMain(	HINSTANCE hinstance,
					HINSTANCE hprevinstance,
					LPSTR lpcmdline,
					int ncmdshow)
{

WNDCLASSEX winclass; // this will hold the class we create
HWND	   hwnd;	 // generic window handle
MSG		   msg;		 // generic message

// first fill in the window class stucture
winclass.cbSize         = sizeof(WNDCLASSEX);
winclass.style			= CS_DBLCLKS | CS_OWNDC | 
                          CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc	= WindowProc;
winclass.cbClsExtra		= 0;
winclass.cbWndExtra		= 0;
winclass.hInstance		= hinstance;
winclass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor		= LoadCursor(NULL, IDC_ARROW); 
winclass.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName	= NULL;
winclass.lpszClassName	= WINDOW_CLASS_NAME;
winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);

// save hinstance in global
hinstance_app = hinstance;

// register the window class
if (!RegisterClassEx(&winclass))
	return(0);

// create the window
if (!(hwnd = CreateWindowEx(NULL,                  // extended style
                            WINDOW_CLASS_NAME,     // class
						    "Menu Resource Demo", // title
						    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
					 	    0,0,	  // initial x,y
						    400,400,  // initial width, height
						    NULL,	  // handle to parent 
						    NULL,	  // handle to menu, note it's null
						    hinstance,// instance of this application
						    NULL)))	// extra creation parms
return(0);

// save main window handle
main_window_handle = hwnd;

// load the menu resource
HMENU hmenuhandle = LoadMenu(hinstance, "MainMenu");

// attach the menu to the window
SetMenu(hwnd, hmenuhandle);


// enter main event loop, but this time we use PeekMessage()
// instead of GetMessage() to retrieve messages
while(TRUE)
	{
    // test if there is a message in queue, if so get it
	if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
	   { 
	   // test if this is a quit
       if (msg.message == WM_QUIT)
           break;
	
	   // translate any accelerator keys
	   TranslateMessage(&msg);

	   // send the message to the window proc
	   DispatchMessage(&msg);
	   } // end if
    
    // main game processing goes here
	// Game_Main(); // or whatever your loop is called
	} // end while

// return to Windows like this
return(msg.wParam);

} // end WinMain
Exemplo n.º 30
0
INT_PTR CALLBACK Manager::ManagerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
    {
        TranslateDialogDefault(hwndDlg);

        SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
        SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONSETASFLATBTN, 0, 0);
        SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_TICK));
        SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select All"), BATF_TCHAR);
        SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONSETASFLATBTN, 0, 0);
        SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_NOTICK));
        SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear All"), BATF_TCHAR);
        SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONSETASFLATBTN, 0, 0);
        SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("clear"));
        SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from List"), BATF_TCHAR);
        SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONSETASFLATBTN, 0, 0);
        SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("delete"));
        SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from FTP"), BATF_TCHAR);
        SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONSETASFLATBTN, 0, 0);
        SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_EXIT));
        SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close"), BATF_TCHAR);

        return TRUE;
    }
    case WM_COMMAND:
    {
        if (HIWORD(wParam) == BN_CLICKED)
        {
            switch (LOWORD(wParam))
            {
            case IDC_BTN_DELETE:
            {
                for (UINT i = 0; i < manDlg->items.size(); i++)
                {
                    TreeItem *item = manDlg->items[i];
                    if (item->getState() == STATE_CHECKED)
                    {
                        DeleteJob *job = new DeleteJob(DBEntry::get(item->fileID), item);
                        job->start();
                    }
                }
                break;
            }
            case IDC_BTN_DELETEFROMLIST:
            {
                for (UINT i = 0; i < manDlg->items.size(); i++)
                {
                    TreeItem *item = manDlg->items[i];
                    if (item->getState() == STATE_CHECKED)
                        item->remove();
                }
                break;
            }
            case IDC_BTN_SELECTALL:
            case IDC_BTN_DESELECTALL:
            {
                UINT newState = (LOWORD(wParam) == IDC_BTN_SELECTALL) ?
                                TreeItem::_CHECKED() : TreeItem::_UNCHECKED();

                for (UINT i = 0; i < manDlg->items.size(); i++)
                    manDlg->items[i]->setState(newState);

                break;
            }
            case IDC_BTN_CLOSE:
            {
                DestroyWindow(hwndDlg);
                break;
            }
            }
        }

        break;
    }
    case WM_NOTIFY:
    {
        if (((LPNMHDR)lParam)->idFrom == IDC_FILELIST)
        {
            switch(((LPNMHDR)lParam)->code)
            {
            case TVN_KEYDOWN:
                if (((LPNMTVKEYDOWN)lParam)->wVKey != VK_SPACE)
                    break;
            case NM_CLICK:
            {
                HTREEITEM hItem;
                TVHITTESTINFO hti = {0};
                hti.pt.x = (short)LOWORD(GetMessagePos());
                hti.pt.y = (short)HIWORD(GetMessagePos());
                ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
                if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN)
                {
                    if (((LPNMHDR)lParam)->code == TVN_KEYDOWN)
                    {
                        hti.flags |= TVHT_ONITEMSTATEICON;
                        hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
                    }
                    else
                    {
                        hItem = hti.hItem;
                    }

                    TreeItem *item = manDlg->getItem(hItem);
                    if (item && (hti.flags & TVHT_ONITEMSTATEICON))
                    {
                        if (item->isRoot())
                        {
                            for (UINT i = 0; i < manDlg->items.size(); i++)
                            {
                                if (manDlg->items[i]->parent == item->handle)
                                    manDlg->items[i]->toggleState();
                            }
                        }
                        else
                        {
                            item->toggleState();
                        }
                    }
                }
                return TRUE;
            }
            case NM_RCLICK:
            {
                TVHITTESTINFO hti;
                hti.pt.x = (short)LOWORD(GetMessagePos());
                hti.pt.y = (short)HIWORD(GetMessagePos());
                ScreenToClient(manDlg->hwndFileTree, &hti.pt);
                if (TreeView_HitTest(manDlg->hwndFileTree, &hti))
                {
                    HTREEITEM hItem = hti.hItem;
                    TreeItem *item = manDlg->getItem(hItem);
                    if (item && !item->isRoot())
                    {
                        POINT pt;
                        GetCursorPos(&pt);
                        SetForegroundWindow(hwndDlg);
                        HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_MANAGER));
                        if (hMenu)
                        {
                            HMENU hPopupMenu = GetSubMenu(hMenu, 0);
                            TranslateMenu(hPopupMenu);
                            int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
                            switch (command)
                            {

                            case IDM_DELETEFROMLIST:
                            {
                                item->remove();
                                break;
                            }
                            case IDM_DELETEFROMFTP:
                            {
                                DeleteJob *job = new DeleteJob(DBEntry::get(item->fileID), item);
                                job->start();
                                break;
                            }
                            case IDM_COPYLINK:
                            case IDM_DOWNLOAD:
                            {
                                int ftpNum = manDlg->indexOf(item->parent);
                                if (ftpNum != -1)
                                {
                                    char buff[256];

                                    DBEntry *entry = DBEntry::get(item->fileID);
                                    Utils::createFileDownloadLink(ftpList[ftpNum]->szUrl, entry->szFileName, buff, sizeof(buff));
                                    delete entry;

                                    if (command == IDM_COPYLINK)
                                        Utils::copyToClipboard(buff);
                                    else
                                        ShellExecuteA(NULL, "open", buff, NULL, NULL, SW_SHOWNORMAL);
                                }
                                break;
                            }
                            }
                            DestroyMenu(hMenu);
                        }
                    }
                }
                return TRUE;
            }
            case TVN_GETINFOTIP:
            {
                NMTVGETINFOTIP *tvInfoTip = (NMTVGETINFOTIP *)lParam;
                TreeItem *item = manDlg->getItem(tvInfoTip->hItem);

                if (item)
                {
                    if (item->stzToolTip[0])
                    {
                        _tcsncpy(tvInfoTip->pszText, item->stzToolTip, tvInfoTip->cchTextMax - 1);
                        tvInfoTip->pszText[tvInfoTip->cchTextMax - 1] = 0;
                    }
                }

                return TRUE;
            }
            }
        }

        break;
    }
    case WM_CLOSE:
    {
        DestroyWindow(hwndDlg);
        return TRUE;
    }
    case WM_DESTROY:
    {
        delete manDlg;
        return TRUE;
    }
    }

    return FALSE;
}