示例#1
0
BOOL DlgURLProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
	static DialogURL * dlgURL;
	switch(nMsg)
	{
		case WM_INITDIALOG:
		{
			RECT rc;

			SHINITDLGINFO l_ShIDI;
			l_ShIDI.dwMask = SHIDIM_FLAGS;
			l_ShIDI.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
			l_ShIDI.hDlg = hWnd;
			SHInitDialog(&l_ShIDI);

			// MenuBar
			SHMENUBARINFO mbi;
			memset ( &mbi, 0, sizeof ( mbi ) );
			mbi.cbSize = sizeof ( mbi );
			mbi.hwndParent = hWnd;
			mbi.nToolBarId = IDR_MENU_OK_CANCEL;
			mbi.hInstRes = g_hInst;
			mbi.dwFlags |= SHCMBF_HMENU;
			SHCreateMenuBar ( &mbi );

			GetClientRect(hWnd, &rc);
			// Size the listbox control to the size of the window
			SetWindowPos(GetDlgItem(hWnd, IDC_URL_LIST), 
				0, 
				rc.left, 
				rc.top, 
				rc.right - rc.left, 
				rc.bottom - rc.top+1, 
				0);

			dlgURL = (DialogURL *)lParam;
			dlgURL->Message = wcsstr(dlgURL->Message, TEXT("http://"));
			while(dlgURL->Message)
			{
				wcscpy(dlgURL->szURL, dlgURL->Message);
				dlgURL->szURL = wcstok(dlgURL->szURL, TEXT(" \n;\,<>*\"\'\[\]\{\}"));
				dlgURL->szURL[wcslen(dlgURL->szURL)-1]='\0';
				SendMessage(GetDlgItem(hWnd, IDC_URL_LIST), LB_ADDSTRING, 0, (LPARAM)dlgURL->szURL);
				memset(dlgURL->Message, 20, 2);
				dlgURL->Message = wcsstr(dlgURL->Message, TEXT("http://"));
			}
			SendMessage(GetDlgItem(hWnd, IDC_URL_LIST), LB_SETCURSEL, 0,0);
		}
		return TRUE;
		case WM_COMMAND:
			{
				switch(LOWORD(wParam))
				{
				case IDCANCEL:
					EndDialog (hWnd, 1);
					delete dlgURL;
					return TRUE;
				case IDOK:
					{
L_OPEN_URL:
						int nSelected = SendMessage(GetDlgItem(hWnd, IDC_URL_LIST), LB_GETCURSEL, 0, 0);
						int szURLLen = SendMessage(GetDlgItem(hWnd, IDC_URL_LIST), LB_GETTEXTLEN, nSelected, 0);
						if(szURLLen)
						{
							delete dlgURL->szURL;
							dlgURL->szURL = new WCHAR[szURLLen + 1];
							SendMessage(GetDlgItem(hWnd, IDC_URL_LIST), LB_GETTEXT, nSelected, (LPARAM)dlgURL->szURL);
							
							SHELLEXECUTEINFO info;
							info.cbSize = sizeof(info);
							info.fMask = SEE_MASK_FLAG_NO_UI;
							info.hwnd = NULL;
							info.lpVerb = TEXT("open");
							info.lpFile = dlgURL->szURL;
							info.lpParameters = TEXT("");
							info.lpDirectory = TEXT("");
							info.nShow = SW_SHOW;
							ShellExecuteEx(&info);
						}
						EndDialog (hWnd, 1);
						delete dlgURL;
					}
					return TRUE;
					case IDC_URL_LIST:
					{
						switch (HIWORD (wParam))
						{
							case LBN_DBLCLK:
							{
								goto L_OPEN_URL;
							}
						}
					}
					return FALSE;
				}
			}
        break;
	}
	return FALSE;
}
示例#2
0
/*************************************
 * Show
 *************************************/
void SHVMenuCommandBarPocketPC::SetMenu(HWND parent, SHVMenuContainerPocketPC* menu)
{

	if (menu && Menu == menu)
		return;

	if (!Menu.IsNull())
	{
	SHMENUBARINFO mbi;

		// Reset the command bar
		SHVVERIFY(::DestroyWindow(hCmdWnd));
		memset(&mbi, 0, sizeof(SHMENUBARINFO));
		mbi.cbSize     = sizeof(SHMENUBARINFO);
		mbi.hwndParent = parent;
		mbi.nToolBarId = 100;
		mbi.hInstRes   = hInstance;
		mbi.nBmpId     = 0;
		mbi.cBmpImages = 0;
		mbi.dwFlags    = SHCMBF_EMPTYBAR;

		SHCreateMenuBar(&mbi);
		hCmdWnd = mbi.hwndMB;


		// Remove the old menu stuff, thus destroying it
		Menu = NULL; // rely on the SHVMenuContainerPocketPC destructor to delete everything
	}

	Menu = menu;

	if (!Menu.IsNull())
	{
	TBBUTTON tbButton;
#if defined(UNICODE) && __SHVSTRINGDEFAULT == 16
	const SHVStringC btn1NameT(Menu->Button1MenuName);
	const SHVStringC btn2NameT(Menu->Button2MenuName);
#elif !defined(UNICODE) && __SHVSTRINGDEFAULT == 8
	const SHVStringC btn1NameT(Menu->Button1MenuName);
	const SHVStringC btn2NameT(Menu->Button2MenuName);
#elif defined(UNICODE)
	SHVString16 btn1NameT(Menu->Button1MenuName.ToStr16());
	SHVString16 btn2NameT(Menu->Button2MenuName.ToStr16());
#else
	SHVString8 btn1NameT(Menu->Button1MenuName.ToStr8());
	SHVString8 btn2NameT(Menu->Button2MenuName.ToStr8());
#endif

		///\todo figure out why the buttons don't get shown on older pocket pc's

		memset(&tbButton, 0, sizeof(TBBUTTON));
		tbButton.iBitmap   = I_IMAGENONE;
		tbButton.fsState   = (!Menu->Button1MenuName.IsNull() && Menu->Button1Enabled ? TBSTATE_ENABLED : 0);
		tbButton.fsStyle   = TBSTYLE_BUTTON|TBSTYLE_AUTOSIZE;
		tbButton.dwData    = 0;
		tbButton.idCommand = 0;
		tbButton.iString   = ::SendMessage(hCmdWnd, TB_ADDSTRING,NULL,(LPARAM)(Menu->Button1MenuName.IsEmpty() ? TEXT(" ") : btn1NameT.GetSafeBufferWin32()));
		::SendMessage(hCmdWnd,TB_INSERTBUTTON,::SendMessage(hCmdWnd,TB_BUTTONCOUNT,0,0),(LPARAM)&tbButton);

		memset(&tbButton, 0, sizeof(TBBUTTON));
		tbButton.iBitmap   = I_IMAGENONE;
		tbButton.fsState   = (!Menu->Button2MenuName.IsNull() && Menu->Button2Enabled ? TBSTATE_ENABLED : 0);
		tbButton.fsStyle   = TBSTYLE_BUTTON|TBSTYLE_AUTOSIZE;
		tbButton.dwData    = 0;
		tbButton.idCommand = 1;
		tbButton.iString   = ::SendMessage(hCmdWnd, TB_ADDSTRING,NULL,(LPARAM)(Menu->Button2MenuName.IsEmpty() ? TEXT(" ") : btn2NameT.GetSafeBufferWin32()));
		::SendMessage(hCmdWnd,TB_INSERTBUTTON,::SendMessage(hCmdWnd,TB_BUTTONCOUNT,0,0),(LPARAM)&tbButton);

	}
}
/* Set a "Menu Bar" on the given frame.
 * PocketPC places menubars at the bottom, which are non-dynamic 
 * so we have a place holder menu item, which takes one to the menu-bar 
 */
WCECOMPAT_API HWND __cdecl
wceSetMenuBar(HWND frame, HWND cmdBarWnd, HMENU menu)
{
#ifdef POCKETPC_MENUS 
    static HMENU javaMenu = NULL;
    HMENU hMenuBar, subMenu;
    SHMENUBARINFO mb;

    /* What we have to do here is pretty bad */
    if (!theInstance) {
	return NULL;
    } 
    if (!frame) {
	return NULL;
    }
    if (1)  {
	/* Only way of creating a menubar is by loading it from a resouce */
	/* This load is a sanity check */
	javaMenu = LoadMenu(theInstance, MAKEINTRESOURCE(IDR_MENUBAR1));
        if (!javaMenu) {
	    return NULL;
	}

	memset(&mb, 0, sizeof(SHMENUBARINFO));
	mb.cbSize = sizeof(SHMENUBARINFO);
	mb.hwndParent = frame;
	mb.dwFlags = 0;
	mb.nToolBarId = IDR_MENUBAR1;
	mb.nBmpId = 0;
	mb.hInstRes =  theInstance;
	mb.cBmpImages =  0;
	/* If this fails,  we're toast */
	if (!SHCreateMenuBar(&mb)) {
	    return NULL;
	}
	cmdBarWnd = mb.hwndMB;
	if (!cmdBarWnd) {
	    return NULL;
	}
    }

    theCmdBarWnd = cmdBarWnd;
    javaMenu = SHGetMenu(cmdBarWnd);
    subMenu = GetSubMenu(javaMenu, 0);
    if (!subMenu) {
	return NULL;
    }
    
    /* Now, we simply cannot set the commandbar menu */
    /* but we can set its submenu, by sending it the */
    /* SHCMBM_SETSUBMENU message */

    SHSetSubMenu(cmdBarWnd, JAVA_MENU_ID, menu); /* this is a marco, defined above */
#else  /* ! POCKETPC_MENUS */
    #define ID_CMDBAR 199
    cmdBarWnd = CommandBar_Create(GetModuleHandle(NULL), frame, ID_CMDBAR);
    if (!CommandBar_InsertMenubarEx(cmdBarWnd,
				    NULL,// No instance implies handle
				    (LPTSTR) menu,
				    0)) {
	// Failure
	return (NULL);
    }
#endif POCKETPC_MENUS
#ifdef OBSOLOLETE
    theFrameWnd = frame;
#endif
    return cmdBarWnd;
    
}
示例#4
0
文件: main.c 项目: altopal/VMusage
BOOL CALLBACK DlgProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) 
{
	VIRTUALDATA *pvd;
	pvd=(VIRTUALDATA *)GetWindowLong (hWnd, GWL_USERDATA);

	switch (wMsg) 
	{
		case WM_INITDIALOG:
		{
			SHMENUBARINFO mbi;
			SHINITDLGINFO shidi;

			SetWindowLong(hWnd,GWL_USERDATA,lParam);

			pvd=(VIRTUALDATA *)lParam;

			memset(&shidi,0x00,sizeof(SHINITDLGINFO));
			shidi.dwMask = SHIDIM_FLAGS;
			shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
			shidi.hDlg = hWnd;
			SHInitDialog (&shidi);

			memset(&mbi, 0x00, sizeof(SHMENUBARINFO));
			mbi.cbSize     = sizeof(SHMENUBARINFO);
			mbi.hwndParent = hWnd;
			mbi.nToolBarId = IDR_MENU1;
			mbi.dwFlags	   = SHCMBF_HMENU;
			mbi.hInstRes   = g_hinst;
			SHCreateMenuBar(&mbi); 

			SetWindowText(hWnd,APPNAME);

			LH_SIPCreate(hWnd,&(pvd->sai));

			SetDlgItemText(hWnd,IDC_SLOTTEXT,pvd->szExeName[pvd->focusSlot]);
			return TRUE;
		}
		case WM_ACTIVATE:
			LH_SIPActivate(hWnd, wParam, lParam, &(pvd->sai));
			break;
		case WM_SETTINGCHANGE:
			LH_SIPSettingChange(hWnd, wParam, lParam, &(pvd->sai));
			break;
		case WM_KEYUP:
		{
			switch (wParam) 
			{
				case VK_LEFT :
				case VK_RIGHT :
					pvd->focusSlot=pvd->focusSlot+NUMBARS;
					if(wParam==VK_LEFT)
						pvd->focusSlot--;
					else
						pvd->focusSlot++;
					pvd->focusSlot=pvd->focusSlot%NUMBARS;
					SetDlgItemText(hWnd,IDC_SLOTTEXT,pvd->szExeName[pvd->focusSlot]);
					InvalidateRect(hWnd,NULL,FALSE); // Don't flash
					break;
			}
			break;
		}
		case WM_SIZE:
		{
			RECT rc,rcItem;
			int sizeWidth,sizeHeight;

			GetClientRect(hWnd,&rc);

			GetWindowRect(GetDlgItem(hWnd,IDC_SLOTTEXT),&rcItem);
			MapWindowPoints (NULL, hWnd, (LPPOINT)&rcItem, 2);
			MoveWindow(GetDlgItem(hWnd,IDC_SLOTTEXT),rcItem.left,rcItem.top,
				rc.right-rcItem.left,rcItem.bottom-rcItem.top,TRUE);

			sizeWidth=rc.right-rc.left;
			sizeHeight=rc.bottom-rcItem.bottom;

			if((sizeWidth!=pvd->screenWidth)||(sizeHeight!=pvd->screenHeight))
			{
				HCURSOR oldCursor;

				oldCursor=SetCursor(LoadCursor(NULL, IDC_WAIT)); 
				pvd->screenWidth=sizeWidth;
				pvd->screenHeight=sizeHeight;
				CreateVirtualMemoryGraph(pvd);
				SetCursor(oldCursor);

				InvalidateRect(hWnd,NULL,TRUE);
			}
			break;
		}
        case WM_PAINT:
		{
			RECT rc,rcItem,rcFocus;
			HDC hdc,hdcMem;
			HBITMAP hOldBmp;
			PAINTSTRUCT ps;
			int origx,origy;

			if(pvd->hBmp==NULL)
				break;

			GetClientRect(hWnd,&rc);

			GetWindowRect(GetDlgItem(hWnd,IDC_SLOTTEXT),&rcItem);
			MapWindowPoints (NULL, hWnd, (LPPOINT)&rcItem, 2);

			origx=rc.left+(rc.right-rc.left-pvd->chartWidth)/2;
			origy=rcItem.bottom+(rc.bottom-rcItem.bottom-pvd->chartHeight)/2;

			hdc = BeginPaint(hWnd, &ps);

			hdcMem = CreateCompatibleDC (hdc);
			if(hdcMem!=NULL)
			{
				hOldBmp=(HBITMAP)SelectObject(hdcMem,pvd->hBmp);
				BitBlt(hdc,origx,origy,pvd->chartWidth,pvd->chartHeight,hdcMem,0,0,SRCCOPY);
				SelectObject(hdcMem,hOldBmp);
				DeleteDC(hdcMem);
			}

			rcFocus.left=origx+(pvd->barWidth*pvd->focusSlot);
			rcFocus.right=rcFocus.left+pvd->barWidth-1;
			rcFocus.top=origy;
			rcFocus.bottom=rcFocus.top+pvd->chartHeight;
			DrawFocusRect (hdc, &rcFocus);

            EndPaint(hWnd, &ps);
            break;
		}
		case WM_CLOSE:
		{
			EndDialog(hWnd, TRUE);
			break;
		}
		case WM_COMMAND:
		{
			switch (LOWORD (wParam)) 
			{		
				case IDC_SNAPSHOT:
				{
					HCURSOR oldCursor;
					SetDlgItemText(hWnd,IDC_SLOTTEXT,TEXT("Taking snapshot..."));
					UpdateWindow(hWnd);
					oldCursor=SetCursor(LoadCursor(NULL, IDC_WAIT)); 
					GetVirtualMemoryStatus(pvd);
					GetProcessNames(pvd);
					CreateVirtualMemoryGraph(pvd);
					SetDlgItemText(hWnd,IDC_SLOTTEXT,pvd->szExeName[pvd->focusSlot]);
					SetCursor(oldCursor); 
					InvalidateRect(hWnd,NULL,TRUE);
					break;
				}
				case IDC_EXIT: // From our menubar
					EndDialog(hWnd, TRUE);
					break;
			}
			break;
		}
	}
	return FALSE;
}
示例#5
0
pj_status_t GuiInit()
{
    WNDCLASS wc;
    HWND hWnd = NULL;	
    RECT r;
    DWORD dwStyle;
    enum { LABEL_HEIGHT = 30 };
    enum { MENU_ID_EXIT = 50000 };
    BITMAP bmp;
    HMENU hRootMenu;
    SHMENUBARINFO mbi;

    pj_status_t status  = PJ_SUCCESS;
    
    /* Check if app is running. If it's running then focus on the window */
    hWnd = FindWindow(MAINWINDOWCLASS, MAINWINDOWTITLE);

    if (NULL != hWnd) {
	SetForegroundWindow(hWnd);    
	return status;
    }

    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = (WNDPROC)DialogProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = g_hInst;
    wc.hIcon = 0;
    wc.hCursor = 0;
    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wc.lpszMenuName	= 0;
    wc.lpszClassName = MAINWINDOWCLASS;
    
    if (!RegisterClass(&wc) != 0) {
	DWORD err = GetLastError();
	return PJ_RETURN_OS_ERROR(err);
    }

    /* Create the app. window */
    g_hWndMain = CreateWindow(MAINWINDOWCLASS, MAINWINDOWTITLE,
			      WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 
			      CW_USEDEFAULT, CW_USEDEFAULT,
			      (HWND)NULL, NULL, g_hInst, (LPSTR)NULL);
    if (g_hWndMain == NULL) {
	DWORD err = GetLastError();
	return PJ_RETURN_OS_ERROR(err);
    }

    /* Create exit menu */
    hRootMenu = CreateMenu();
    AppendMenu(hRootMenu, MF_STRING, MENU_ID_EXIT, L"Exit");

    /* Initialize menubar */
    ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
    mbi.cbSize      = sizeof(SHMENUBARINFO);
    mbi.hwndParent  = g_hWndMain;
    mbi.dwFlags	    = SHCMBF_HIDESIPBUTTON|SHCMBF_HMENU;
    mbi.nToolBarId  = (UINT)hRootMenu;
    mbi.hInstRes    = g_hInst;

    if (FALSE == SHCreateMenuBar(&mbi)) {
	DWORD err = GetLastError();
        return PJ_RETURN_OS_ERROR(err);
    }

    /* Store menu window handle */
    g_hWndMenuBar = mbi.hwndMB;

    /* Show the menu */
    DrawMenuBar(g_hWndMain);
    ShowWindow(g_hWndMenuBar, SW_SHOW);

    /* Override back button */
    SendMessage(g_hWndMenuBar, SHCMBM_OVERRIDEKEY, VK_TBACK,
	    MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
	    SHMBOF_NODEFAULT | SHMBOF_NOTIFY));

    /* Get main window size */
    GetClientRect(g_hWndMain, &r);
#if defined(WIN32_PLATFORM_PSPC) && WIN32_PLATFORM_PSPC != 0
    /* Adjust the height for PocketPC platform */
    r.bottom -= GetSystemMetrics(SM_CYMENU);
#endif

    /* Create logo */
    g_hBmp = SHLoadDIBitmap(LOGO_PATH); /* for jpeg, uses SHLoadImageFile() */
    if (g_hBmp == NULL) {
	DWORD err = GetLastError();
	return PJ_RETURN_OS_ERROR(err);
    }
    GetObject(g_hBmp, sizeof(bmp), &bmp);

    dwStyle = SS_CENTERIMAGE | SS_REALSIZEIMAGE | SS_BITMAP |
	      WS_CHILD | WS_VISIBLE;
    g_hWndImg = CreateWindow(TEXT("STATIC"), NULL, dwStyle,
			     (r.right-r.left-bmp.bmWidth)/2,
			     (r.bottom-r.top-bmp.bmHeight)/2,
			     bmp.bmWidth, bmp.bmHeight,
			     g_hWndMain, (HMENU)0, g_hInst, NULL);
    if (g_hWndImg == NULL) {
	DWORD err = GetLastError();
	return PJ_RETURN_OS_ERROR(err);
    }
    SendMessage(g_hWndImg, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g_hBmp);

    /* Create label */
    dwStyle = WS_CHILD | WS_VISIBLE | ES_CENTER;
    g_hWndLbl = CreateWindow(TEXT("STATIC"), NULL, dwStyle,
		0, r.bottom-LABEL_HEIGHT, r.right-r.left, LABEL_HEIGHT,
                g_hWndMain, (HMENU)0, g_hInst, NULL);
    if (g_hWndLbl == NULL) {
	DWORD err = GetLastError();
	return PJ_RETURN_OS_ERROR(err);
    }
    SetWindowText(g_hWndLbl, _T("Please wait.."));

    return status;
}
void CNetSettingPage_Tools_PingView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.


	RETAILMSG(1, (TEXT("[NETUI] CNetSettingPage_Tools_PingDlg Oninit \r\n") ));

	// Empty MenuBar
	
	m_mbi.cbSize = sizeof( SHMENUBARINFO );
	m_mbi.hwndParent = m_hWnd;
	m_mbi.dwFlags = SHCMBF_EMPTYBAR;
	m_mbi.hInstRes = AfxGetInstanceHandle();
	SHCreateMenuBar( &m_mbi );


	m_dwScreenRate = (GetSystemMetrics(SM_CXSCREEN) == 480)? 2 : 1;

	// EditBox Initialize
	m_editPingResult.SetFont(NULL, FALSE);
	m_fontPingResult.DeleteObject();
	m_fontPingResult.CreateFont(11 * m_dwScreenRate, 0, 0, 0, FW_DONTCARE, FALSE /*italic*/, FALSE /*underline*/, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Tahoma")) ;
	m_editPingResult.SetFont(&m_fontPingResult);

	// 문자제한 무제한
	m_editPingResult.SetLimitText(-1);


	// Set Default Value

	m_pingOption.dwSendBufSize = DEFAULT_SEND_SIZE;
	m_pingOption.dwTimeOut = DEFAULT_TIMEOUT;
	m_pingOption.ucTos = DEFAULT_TOS;
	m_pingOption.ucTtl = DEFAULT_TTL;

	SetDlgItemInt(IDC_EDIT_PING_SENDSIZE, m_pingOption.dwSendBufSize, FALSE);
	SetDlgItemInt(IDC_EDIT_PING_TTL, m_pingOption.ucTtl, FALSE);
	SetDlgItemInt(IDC_EDIT_PING_TOS, m_pingOption.ucTos, FALSE);
	SetDlgItemInt(IDC_EDIT_PING_TIMEOUT, m_pingOption.dwTimeOut, FALSE);

	
	// Set default Gateway
	GetWlanDefaultInformation(&m_adapterInfo);
	SetDlgItemText(IDC_EDIT_PING_DEST_ADDRESS, m_adapterInfo.tszDefaultGateWay);




	// For File Log

	// File Log Path
	TCHAR tszPSName[128] = L"";

	GetFlashStoreName(tszPSName);


	m_strLogFilePath = tszPSName;
	m_strLogFilePath += L"\\";
	m_strLogFilePath += L"System";
	m_strLogFilePath += L"\\";
	m_strLogFilePath += L"Log";
	m_strLogFilePath += L"\\";
	m_strLogFilePath += DEFAULT_LOG_FILE_NAME;

	
	SetDlgItemText(IDC_EDIT_PING_FILELOG_PATH, m_strLogFilePath.GetBuffer());


}
示例#7
0
LRESULT CDlgFileAssoc::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {

	switch (uMsg) {
		
		case WM_INITDIALOG: {

#ifdef SHELL_AYGSHELL
			// Initializes menubar		
			SHMENUBARINFO mbi;
			memset(&mbi, 0, sizeof(SHMENUBARINFO));
			mbi.cbSize = sizeof(SHMENUBARINFO);
			mbi.hwndParent = hWnd;
			mbi.nToolBarId = MNU_OKCANCEL;
			mbi.hInstRes = player()->hInstance;
			mbi.nBmpId = 0;
			mbi.cBmpImages = 0;
			if (SHCreateMenuBar(&mbi)) {
				hWndMenuBar = mbi.hwndMB;
				SetSoftkeyText(hWndMenuBar, 0, _str(STR_CANCEL));
				SetSoftkeyText(hWndMenuBar, 1, _str(STR_OK));
			} else {
				hWndMenuBar = NULL;
			}
#else
            hWndMenuBar = NULL;
#endif

#ifdef SHELL_AYGSHELL
			// Initializes fullscreen dialog
			SHINITDLGINFO shidi;
			shidi.dwMask = SHIDIM_FLAGS;
			shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN|SHIDIF_DONEBUTTON|SHIDIF_WANTSCROLLBAR;
			shidi.hDlg = hWnd;
			SHInitDialog(&shidi);
#endif

			SetWindowText(hWnd, _str(STR_FILEASSOCIATIONS));
			SetDlgItemText(hWnd, LBL_USETOOPEN, _str(STR_USENITROGENTOOPE));
			SetDlgItemText(hWnd, BTN_SELALL, _str(STR_SELECTALL));
			SetDlgItemText(hWnd, BTN_SELNONE, _str(STR_SELECTNONE));
			SetDlgItemText(hWnd, LBL_NOTRUNNING, _str(STR_IFTHEPLAYERISNOT));
			SetDlgItemText(hWnd, LBL_RUNNING, _str(STR_IFTHEPLAYERISALR));

			int rActions[3] = {STR_SETFILEASPLAYLIS, STR_ADDFILETOPLAYLIS, STR_SETFOLDERASPLAYL};
			for (int i = 0; i < 3; i++) {
				SendDlgItemMessage(hWnd, CBB_NOTRUNNING, CB_ADDSTRING, 0, (LPARAM)_str(rActions[i]));
				SendDlgItemMessage(hWnd, CBB_RUNNING, CB_ADDSTRING, 0, (LPARAM)_str(rActions[i]));
			}

			SendDlgItemMessage(hWnd, CBB_NOTRUNNING, CB_SETCURSEL, (WPARAM)player()->lpConfig->cf.FileAssNotRunning, 0);
			SendDlgItemMessage(hWnd, CBB_RUNNING, CB_SETCURSEL, (WPARAM)player()->lpConfig->cf.FileAssRunning, 0);

			ListView_SetExtendedListViewStyle(GetDlgItem(hWnd, LST_EXTENSIONS), LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
		
			LVCOLUMN nCol;
			memset(&nCol, 0, sizeof(LVCOLUMN));
			nCol.mask = LVCF_TEXT;
			nCol.pszText = NULL;
			ListView_InsertColumn(GetDlgItem(hWnd, LST_EXTENSIONS), 0, &nCol);

			LPWSTR assc[4] = {L"Skin files (*.sk2)", L"MPEG Layer-3 files (*.mp3)", L"Ogg Vorbis files (*.ogg)", L"Wave Audio files (*.wav)"};
			LPWSTR exts[4] = {L"sk2", L"mp3", L"ogg", L"wav"};

			int y = 0;

			for (int i = 0; i < 4; i++) {
				LVITEM nItem;
				memset(&nItem, 0, sizeof(LVITEM));
				nItem.mask = LVIF_TEXT;
				nItem.iSubItem = 0;
				nItem.pszText = assc[i];
				nItem.iItem = y;
				ListView_InsertItem(GetDlgItem(hWnd, LST_EXTENSIONS), &nItem);
				PrevAssoc[y] = IsExtAssignedDyn(exts[i]);
				if (PrevAssoc[y]) {
					ListView_SetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), y, true);
				}
				y++;
			}
			for (int i = 0; i < MAP_GetDecoderPlugInCount(player()->MAP); i++) {

				MAP_DEC_PLUGIN * mplug = MAP_GetDecoderPlugIn(player()->MAP, i);
				
				for (int x = 0; x < mplug->GetFileExtCount(); x++) {

					TCHAR ExtName[MAX_PATH];
					TCHAR ExtDesc[MAX_PATH];
					mplug->GetFileExt(x, ExtName, ExtDesc);
					LVITEM nItem;
					memset(&nItem, 0, sizeof(LVITEM));
					nItem.mask = LVIF_TEXT;
					nItem.iSubItem = 0;
					nItem.pszText = ExtDesc;
					nItem.iItem = y;
					
					ListView_InsertItem(GetDlgItem(hWnd, LST_EXTENSIONS), &nItem);	
					PrevAssoc[y] = IsExtAssignedDyn(ExtName);
					if (PrevAssoc[y]) {
						ListView_SetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), y, true);
					}

					y++;
				}
			}

			RECT rc;
			GetClientRect(GetDlgItem(hWnd, LST_EXTENSIONS), &rc);
			ListView_SetColumnWidth(GetDlgItem(hWnd, LST_EXTENSIONS), 0, rc.right-rc.left);

			break;

		}

 		case WM_COMMAND: {

			int wmId = LOWORD(wParam); 
			if ((wmId == IDM_OK) || (wmId == IDOK)) {

				player()->lpConfig->cf.FileAssNotRunning = SendDlgItemMessage(hWnd, CBB_NOTRUNNING, CB_GETCURSEL, 0, 0);
				player()->lpConfig->cf.FileAssRunning = SendDlgItemMessage(hWnd, CBB_RUNNING, CB_GETCURSEL, 0, 0);
				
				LPWSTR exts[4] = {L"sk2", L"mp3", L"ogg", L"wav"};
				for (int i = 0; i < 4; i++) {
					
					bool NewAssoc = ListView_GetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), i);

					if (NewAssoc && !PrevAssoc[i]) {
						ExtAssignDyn(exts[i], L"\"%1\"", 102+(int)(i == 0));
					}

					if (!NewAssoc && PrevAssoc[i]) {
						ExtUnassignDyn(exts[i]);
					}

				}

				int y = 4;

				for (int i = 0; i < MAP_GetDecoderPlugInCount(player()->MAP); i++) {
		
					MAP_DEC_PLUGIN * mplug = MAP_GetDecoderPlugIn(player()->MAP, i);
				
					for (int x = 0; x < mplug->GetFileExtCount(); x++) {

						bool NewAssoc = ListView_GetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), y);
	
						TCHAR ExtName[MAX_PATH];
						TCHAR ExtDesc[MAX_PATH];
						mplug->GetFileExt(x, ExtName, ExtDesc);
						
						if (NewAssoc && !PrevAssoc[y]) {
							ExtAssignDyn(ExtName, L"\"%1\"", 102);
						}

						if (!NewAssoc && PrevAssoc[y]) {
							ExtUnassignDyn(ExtName);
						}

						y++;
					}
				}

				EndDialog(hWnd, 0);

			} else if (wmId == BTN_SELALL) {
		
				HWND ls = GetDlgItem(hWnd, LST_EXTENSIONS);
				for (int i = 0; i < ListView_GetItemCount(ls); i++) {
					ListView_SetCheckState(ls, i, true);
				}

			} else if (wmId == BTN_SELNONE) {
		
				HWND ls = GetDlgItem(hWnd, LST_EXTENSIONS);
				for (int i = 0; i < ListView_GetItemCount(ls); i++) {
					ListView_SetCheckState(ls, i, false);
				}

			} else if (wmId == IDM_CANCEL) {
			
				EndDialog(hWnd, 0);
			
			}

			break;
		}

		case WM_DESTROY:
			CommandBar_Destroy(hWndMenuBar);
			break;

		case WM_ACTIVATE:
			
			if ((wParam == WA_INACTIVE) && ((HWND)lParam == player()->lpWndMain->hWnd)) {
				EndDialog(hWnd, 0);
			} else {
				return DefWindowProc(hWnd, uMsg, wParam, lParam);
			}
			break;

		default:
			DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	return 0;
}
示例#8
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)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

#if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP)
    static SHACTIVATEINFO s_sai;
#endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP
	
    switch (message) 
    {
        case WM_COMMAND:
            wmId    = LOWORD(wParam); 
            wmEvent = HIWORD(wParam); 
            // Parse the menu selections:
            switch (wmId)
            {
#ifndef WIN32_PLATFORM_WFSP
                case IDM_HELP_ABOUT:
                    DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
                    break;
#endif // !WIN32_PLATFORM_WFSP
#ifndef SHELL_AYGSHELL
                case IDM_FILE_EXIT:
                    DestroyWindow(hWnd);
                    break;
#endif // !SHELL_AYGSHELL
#ifdef WIN32_PLATFORM_WFSP
                case IDM_OK:
                    DestroyWindow(hWnd);
                    break;
#endif // WIN32_PLATFORM_WFSP
#ifdef WIN32_PLATFORM_PSPC
                case IDM_OK:
                    SendMessage (hWnd, WM_CLOSE, 0, 0);				
                    break;
#endif // WIN32_PLATFORM_PSPC
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;
        case WM_CREATE:
#ifndef SHELL_AYGSHELL
            g_hWndCommandBar = CommandBar_Create(g_hInst, hWnd, 1);
            CommandBar_InsertMenubar(g_hWndCommandBar, g_hInst, IDR_MENU, 0);
            CommandBar_AddAdornments(g_hWndCommandBar, 0, 0);
#endif // !SHELL_AYGSHELL
#ifdef SHELL_AYGSHELL
            SHMENUBARINFO mbi;

            memset(&mbi, 0, sizeof(SHMENUBARINFO));
            mbi.cbSize     = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hWnd;
            mbi.nToolBarId = IDR_MENU;
            mbi.hInstRes   = g_hInst;

            if (!SHCreateMenuBar(&mbi)) 
            {
                g_hWndMenuBar = NULL;
            }
            else
            {
                g_hWndMenuBar = mbi.hwndMB;
            }

#ifndef WIN32_PLATFORM_WFSP
            // Initialize the shell activate info structure
            memset(&s_sai, 0, sizeof (s_sai));
            s_sai.cbSize = sizeof (s_sai);
#endif // !WIN32_PLATFORM_WFSP
#endif // SHELL_AYGSHELL
            break;
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            
            // TODO: Add any drawing code here...
            
            EndPaint(hWnd, &ps);
            break;
        case WM_DESTROY:
#ifndef SHELL_AYGSHELL
            CommandBar_Destroy(g_hWndCommandBar);
#endif // !SHELL_AYGSHELL
#ifdef SHELL_AYGSHELL
            CommandBar_Destroy(g_hWndMenuBar);
#endif // SHELL_AYGSHELL
            PostQuitMessage(0);
            break;

#if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP)
        case WM_ACTIVATE:
            // Notify shell of our activate message
            SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
            break;
        case WM_SETTINGCHANGE:
            SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
            break;
#endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}