Ejemplo n.º 1
0
HACCEL CPpcMainWnd::GetAccelHandle()
{
	if (!m_hAccel) {
		ACCEL accel[] = {
			{FVIRTKEY | FCONTROL, 'Z', IDM_PLAY_PLAYPAUSE},		// Play/Pause
			{FVIRTKEY | FCONTROL, 'X', IDM_PLAY_STOP},				// Stop
			{FVIRTKEY | FCONTROL, 'C', IDM_PLAY_PREV},				// Prev
			{FVIRTKEY | FCONTROL, 'V', IDM_PLAY_REW},				// Rew
			{FVIRTKEY | FCONTROL, 'B', IDM_PLAY_FF},				// FF
			{FVIRTKEY | FCONTROL, 'N', IDM_PLAY_NEXT},				// Next
			{FVIRTKEY | FCONTROL, 'R', IDM_PLAY_REPEAT},			// Repeat
			{FVIRTKEY | FCONTROL, 'H', IDM_PLAY_SHUFFLE},			// Shuffle
			{FVIRTKEY | FCONTROL, 'O', IDM_FILE_OPEN},				// Open
			{FVIRTKEY | FCONTROL, 'U', IDM_FILE_OPEN_LOCATION},	// Open Location
			{FVIRTKEY | FCONTROL, 'A', IDM_FILE_ADD},				// Add
			{FVIRTKEY | FCONTROL, 'F', IDM_FILE_FIND},				// Find
			{FVIRTKEY | FCONTROL, 'L', IDM_FILE_LIST},				// List
			{FVIRTKEY | FCONTROL, 'S', IDM_FILE_SAVE_LIST},		// Save List
			{FVIRTKEY | FCONTROL, 'E', IDM_TOOL_EFFECT},			// Effect
			{FVIRTKEY | FCONTROL, 'Y', IDM_TOOL_VOLUP},			// Volume Up
			{FVIRTKEY | FCONTROL, 'T', IDM_TOOL_VOLDOWN},		// Volume Down
			{FVIRTKEY | FCONTROL, 'Q', IDM_APP_EXIT},	// Exit
		};
		m_hAccel = CreateAcceleratorTable(accel, sizeof(accel) / sizeof(ACCEL));
	}
	return m_hAccel;
}
Ejemplo n.º 2
0
// -------------------------------------------------------------------------------- //
// guAlListBox
// -------------------------------------------------------------------------------- //
guAlListBox::guAlListBox( wxWindow * parent, guLibPanel * libpanel, guDbLibrary * db, const wxString &label ) :
    guListView( parent, wxLB_MULTIPLE | guLISTVIEW_ALLOWDRAG | guLISTVIEW_HIDE_HEADER )
{
    m_Db = db;
    m_Items = new guAlbumItems();
    m_LibPanel = libpanel;

    guConfig * Config = ( guConfig * ) guConfig::Get();
    Config->RegisterObject( this );

    m_ConfigPath = libpanel->GetMediaViewer()->ConfigPath();
    m_AlbumsOrder = Config->ReadNum( wxT( "AlbumsOrder" ), 0, m_ConfigPath );
    m_Db->SetAlbumsOrder( m_AlbumsOrder );

    guListViewColumn * Column = new guListViewColumn( label, 0 );
    InsertColumn( Column );

    Bind( wxEVT_MENU, &guAlListBox::OnSearchLinkClicked, this, ID_LINKS_BASE, ID_LINKS_BASE + guLINKS_MAXCOUNT );
    Bind( wxEVT_MENU, &guAlListBox::OnCommandClicked, this, ID_COMMANDS_BASE, ID_COMMANDS_BASE + guCOMMANDS_MAXCOUNT );
    Bind( wxEVT_MENU, &guAlListBox::OnOrderSelected, this, ID_ALBUM_ORDER_NAME, ID_ALBUM_ORDER_ARTIST_YEAR_REVERSE );

    Bind( guConfigUpdatedEvent, &guAlListBox::OnConfigUpdated, this, ID_CONFIG_UPDATED );

    CreateAcceleratorTable();

    ReloadItems();
}
Ejemplo n.º 3
0
// -------------------------------------------------------------------------------- //
void guAlListBox::OnConfigUpdated( wxCommandEvent &event )
{
    int Flags = event.GetInt();
    if( Flags & guPREFERENCE_PAGE_FLAG_ACCELERATORS )
    {
        CreateAcceleratorTable();
    }
}
Ejemplo n.º 4
0
//
// Build the Accelerators Table
// 
AccelKeys::AccelKeys()
{
	ACCEL AccelTable[16];
	int i = 0;
	m_hWnd = 0;

	/*
	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F3;
	AccelTable[i++].cmd = ID_CONN_CTLESC;
	*/

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F3;
	AccelTable[i++].cmd = ID_VIEWONLYTOGGLE;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F4;
	AccelTable[i++].cmd = ID_CONN_CTLALTDEL;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F5;
	AccelTable[i++].cmd = ID_CONN_SAVE_AS;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F6;
	AccelTable[i++].cmd = IDC_OPTIONBUTTON;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F7;
	AccelTable[i++].cmd = ID_FILETRANSFER;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F8;
	AccelTable[i++].cmd = ID_TEXTCHAT;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F9;
	AccelTable[i++].cmd = ID_DBUTTON;  // Toolbar Toggle

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F10;
	AccelTable[i++].cmd = ID_AUTOSCALING;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FNOINVERT;
	AccelTable[i].key = VK_F11;
	AccelTable[i++].cmd = ID_NORMALSCREEN2;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F11;
	AccelTable[i++].cmd = ID_HALFSCREEN;

	AccelTable[i].fVirt = FVIRTKEY | FCONTROL | FALT | FNOINVERT;
	AccelTable[i].key = VK_F12;
	AccelTable[i++].cmd = ID_FULLSCREEN;

	m_hAccelTable = CreateAcceleratorTable((LPACCEL)AccelTable, i);
}
Ejemplo n.º 5
0
// -------------------------------------------------------------------------------- //
guCoListBox::guCoListBox( wxWindow * parent, guLibPanel * libpanel, guDbLibrary * db, const wxString &label ) :
             guAccelListBox( parent, db, label )
{
    m_LibPanel = libpanel;

    CreateAcceleratorTable();

    ReloadItems();
}
Ejemplo n.º 6
0
// -------------------------------------------------------------------------------- //
guPLSoListBox::guPLSoListBox( wxWindow * parent, guMediaViewer * mediaviewer, wxString confname, int style ) :
             guSoListBox( parent, mediaviewer, confname, style | guLISTVIEW_ALLOWDRAG | guLISTVIEW_ALLOWDROP | guLISTVIEW_DRAGSELFITEMS | guLISTVIEW_COLUMN_SORTING )
{
    m_TracksOrder = wxNOT_FOUND;
    m_DisableSorting = false;

    Bind( wxEVT_MENU, &guPLSoListBox::OnRandomizeTracks, this, ID_TRACKS_RANDOMIZE );

    CreateAcceleratorTable();

    ReloadItems();
}
Ejemplo n.º 7
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
{
	MSG msg;
	WNDCLASS wndclass = {
		0,
		WndProc,
		0,
		0,
		hInstance,
		LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)),
		LoadCursor(0, IDC_ARROW),
		0,
		0,
		szClassName
	};
	RegisterClass(&wndclass);
	hWnd = CreateWindow(
		szClassName,
		TEXT("二角取り"),
		WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT,
		0,
		WINDOW_WIDTH + GetSystemMetrics(SM_CXEDGE) +
		GetSystemMetrics(SM_CXBORDER) +
		GetSystemMetrics(SM_CXDLGFRAME),
		WINDOW_HEIGHT + GetSystemMetrics(SM_CYEDGE) +
		GetSystemMetrics(SM_CYBORDER) +
		GetSystemMetrics(SM_CYDLGFRAME) +
		GetSystemMetrics(SM_CYCAPTION),
		0,
		0,
		hInstance,
		0);
	ShowWindow(hWnd, SW_SHOWDEFAULT);
	UpdateWindow(hWnd);
	ACCEL Accel[] = {
		{ FVIRTKEY, VK_F2, ID_NEWGAME },
		{ FVIRTKEY, VK_F1, ID_HINT }
	};
	HACCEL hAccel = CreateAcceleratorTable(Accel, 2);
	while (GetMessage(&msg, 0, 0, 0))
	{
		if (!TranslateAccelerator(hWnd, hAccel, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	DestroyAcceleratorTable(hAccel);
	return msg.wParam;
}
Ejemplo n.º 8
0
void CRunView::ShowPictureComplete(LPCTSTR lpszPicture)
{
	IDispatch* pMenuObject = GetMainMenu();

	if (pMenuObject != NULL)
	{
		m_arrAccels.RemoveAll();

		if (m_menu.m_hMenu != NULL)
			m_menu.DestroyMenu();

		m_menu.CreateMenu();
		
		CComQIPtr<IDrawMenu, &IID_IDrawMenu> spDrawMenu(pMenuObject);
		long lCount;
		spDrawMenu->get_ItemCount(&lCount);
		
		int nIndex = 0;
		AddMenuItems(m_menu.m_hMenu, spDrawMenu, nIndex, lCount, 0);
		
		if (m_pMenu == NULL)
		{
			CMenu* pMenu = AfxGetMainWnd()->GetMenu();
			if (pMenu != NULL)
				m_hAltMenu = pMenu->GetSafeHmenu();
		}

		AfxGetMainWnd()->SetMenu(&m_menu);
		
		m_pMenu = spDrawMenu;

		m_bLockMenu = FALSE;
	
		pMenuObject->Release();

		if (m_arrAccels.GetSize() > 0)
			m_hAccelTable = CreateAcceleratorTable(m_arrAccels.GetData(), m_arrAccels.GetSize());
	}
	else
	{
		if (m_pMenu != NULL)
		{
			::SetMenu(AfxGetMainWnd()->GetSafeHwnd(), m_hAltMenu);
			
			m_hAltMenu = NULL;
			m_pMenu = NULL;
		}
	}
}
Ejemplo n.º 9
0
HotKeys::HotKeys()
{
	m_hwnd = 0;

	const int MAX_ACCELS = 16;
	ACCEL accel[MAX_ACCELS];
	int i = 0;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x4f;	// "O"
	accel[i++].cmd = IDC_OPTIONBUTTON;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x49;	// "I"
	accel[i++].cmd = ID_CONN_ABOUT;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x46;	// "F"
	accel[i++].cmd = ID_FULLSCREEN;

	accel[i].fVirt = FVIRTKEY | FCONTROL |  FNOINVERT;
	accel[i].key = 0x47;	// "G"
	accel[i++].cmd = ID_LOCK_MOUSE;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x52;	// "R"
	accel[i++].cmd = ID_REQUEST_REFRESH;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x4e;	// "N"
	accel[i++].cmd = ID_NEWCONN;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x53;	// "S"
	accel[i++].cmd = ID_CONN_SAVE_AS;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x54;	// "T"
	accel[i++].cmd = ID_TOOLBAR;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 0x45;	// "E"
	accel[i++].cmd = IDD_FILETRANSFER;

	int numKeys = i;
	assert(numKeys <= MAX_ACCELS);

	m_hAccel = CreateAcceleratorTable((LPACCEL)accel, numKeys);
}
BOOL CPPageAccelTbl::OnApply()
{
	AfxGetMyApp()->UnregisterHotkeys();
	UpdateData();

	AppSettings& s = AfxGetAppSettings();

	s.wmcmds.RemoveAll();
	s.wmcmds.AddTail(&m_wmcmds);

	CAtlArray<ACCEL> pAccel;
	pAccel.SetCount(m_wmcmds.GetCount());
	POSITION pos = m_wmcmds.GetHeadPosition();
	for (int i = 0; pos; i++) {
		pAccel[i] = m_wmcmds.GetNext(pos);
	}
	if (s.hAccel) {
		DestroyAcceleratorTable(s.hAccel);
	}
	s.hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());

	GetParentFrame()->m_hAccelTable = s.hAccel;

	s.fWinLirc = !!m_fWinLirc;
	s.strWinLircAddr = m_WinLircAddr;
	if (s.fWinLirc) {
		s.WinLircClient.Connect(m_WinLircAddr);
	}
	s.fUIce = !!m_fUIce;
	s.strUIceAddr = m_UIceAddr;
	if (s.fUIce) {
		s.UIceClient.Connect(m_UIceAddr);
	}
	s.fGlobalMedia = !!m_fGlobalMedia;

	AfxGetMyApp()->RegisterHotkeys();

	s.AccelTblColWidth.bEnable = true;
	s.AccelTblColWidth.cmd		= m_list.GetColumnWidth(COL_CMD);
	s.AccelTblColWidth.key		= m_list.GetColumnWidth(COL_KEY);
	s.AccelTblColWidth.id		= m_list.GetColumnWidth(COL_ID);
	s.AccelTblColWidth.mwnd		= m_list.GetColumnWidth(COL_MOUSE);
	s.AccelTblColWidth.mfs		= m_list.GetColumnWidth(COL_MOUSE_FS);
	s.AccelTblColWidth.appcmd	= m_list.GetColumnWidth(COL_APPCMD);
	s.AccelTblColWidth.remcmd	= m_list.GetColumnWidth(COL_RMCMD);
	s.AccelTblColWidth.repcnt	= m_list.GetColumnWidth(COL_RMREPCNT);

	return __super::OnApply();
}
Ejemplo n.º 11
0
HotKeys::HotKeys()
{
	m_hwnd = 0;

	const int MAX_ACCELS = 16;
	ACCEL accel[MAX_ACCELS];
	int i = 0;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'O';
	accel[i++].cmd = IDC_OPTIONBUTTON;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'I';
	accel[i++].cmd = ID_CONN_ABOUT;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'F';
	accel[i++].cmd = ID_FULLSCREEN;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'R';
	accel[i++].cmd = ID_REQUEST_REFRESH;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'N';
	accel[i++].cmd = ID_NEWCONN;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'S';
	accel[i++].cmd = ID_CONN_SAVE_AS;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'T';
	accel[i++].cmd = ID_TOOLBAR;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = 'E';
	accel[i++].cmd = IDD_FILETRANSFER;

	accel[i].fVirt = FVIRTKEY | FALT | FCONTROL | FSHIFT | FNOINVERT;
	accel[i].key = VK_DELETE;
	accel[i++].cmd = ID_CONN_CTLALTDEL;

	int numKeys = i;
	assert(numKeys <= MAX_ACCELS);

	m_hAccel = CreateAcceleratorTable((LPACCEL)accel, numKeys);
}
Ejemplo n.º 12
0
void Menu::release()
{
 if (!m_form) return;
 m_form->set_menu(HMENU(m_handle));
 m_form->add_handler(m_menu_handler);
 if (m_accel_list->size()) {
	 ACCEL *accels = new ACCEL[m_accel_list->size()];
	 AccelList::iterator ali;
	 int i = 0;
	 for(ali = m_accel_list->begin(); ali != m_accel_list->end(); ++ali)
		 accels[i++] = *ali;
	 HACCEL hAccel = CreateAcceleratorTable(accels,i);
	 m_form->add_accelerator(hAccel);
 }
}
Ejemplo n.º 13
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
{
	MSG msg;
	WNDCLASS wndclass = {
		CS_HREDRAW | CS_VREDRAW,
		WndProc,
		0,
		DLGWINDOWEXTRA,
		hInstance,
		0,
		LoadCursor(0, IDC_ARROW),
		(HBRUSH)(COLOR_WINDOW + 1),
		0,
		szClassName
	};
	RegisterClass(&wndclass);
	HWND hWnd = CreateWindow(
		szClassName,
		TEXT("Calc SHA-1"),
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		0,
		CW_USEDEFAULT,
		0,
		0,
		0,
		hInstance,
		0
		);
	ShowWindow(hWnd, SW_SHOWDEFAULT);
	UpdateWindow(hWnd);
	ACCEL Accel[] = { { FVIRTKEY, VK_DELETE, ID_DELETE },
	{ FVIRTKEY | FCONTROL, 'A', ID_SELECTALL },
	{ FVIRTKEY | FCONTROL, 'C', ID_COPYTOCLIPBOARD },
	};
	HACCEL hAccel = CreateAcceleratorTable(Accel, sizeof(Accel) / sizeof(ACCEL));
	while (GetMessage(&msg, 0, 0, 0))
	{
		if (!TranslateAccelerator(hWnd, hAccel, &msg) && !IsDialogMessage(hWnd, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	DestroyAcceleratorTable(hAccel);
	return msg.wParam;
}
Ejemplo n.º 14
0
void CAccelerator::Setup()
{
	// Translate key table -> windows accelerator table

	if (m_hAccel) {
		DestroyAcceleratorTable(m_hAccel);
		m_hAccel = NULL;
	}

	m_pAccelTable.clear();		// // //
	for (const auto &x : m_pEntriesTable) {
		ACCEL a;
		a.fVirt = FVIRTKEY | GetMod(x.mod);
		a.key = x.key;
		a.cmd = x.id;
		m_pAccelTable.push_back(a);
	}
	m_hAccel = CreateAcceleratorTable(m_pAccelTable.data(), ACCEL_COUNT);
}
Ejemplo n.º 15
0
LRESULT	CGitProgressDlg::OnCmdEnd(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
    RefreshCursor();

    DialogEnableWindow(IDCANCEL, FALSE);
    DialogEnableWindow(IDOK, TRUE);

    m_PostCmdList.clear();
    if (m_ProgList.m_Command->m_PostCmdCallback)
        m_ProgList.m_Command->m_PostCmdCallback(m_ProgList.DidErrorsOccur() ? 1 : 0, m_PostCmdList);

    if (!m_PostCmdList.empty())
    {
        int i = 0;
        for (const auto& entry : m_PostCmdList)
        {
            ++i;
            m_cMenuButton.AddEntry(entry.icon, entry.label);
            TCHAR accellerator = CStringUtils::GetAccellerator(entry.label);
            if (accellerator == L'\0')
                continue;
            ++m_accellerators[accellerator].cnt;
            if (m_accellerators[accellerator].cnt > 1)
                m_accellerators[accellerator].id = -1;
            else
                m_accellerators[accellerator].id = i - 1;
        }

        if (m_accellerators.size())
        {
            LPACCEL lpaccelNew = (LPACCEL)LocalAlloc(LPTR, m_accellerators.size() * sizeof(ACCEL));
            SCOPE_EXIT { LocalFree(lpaccelNew); };
            i = 0;
            for (auto& entry : m_accellerators)
            {
                lpaccelNew[i].cmd = (WORD)(WM_USER + 1 + entry.second.id);
                lpaccelNew[i].fVirt = FVIRTKEY | FALT;
                lpaccelNew[i].key = entry.first;
                entry.second.wmid = lpaccelNew[i].cmd;
                ++i;
            }
            m_hAccel = CreateAcceleratorTable(lpaccelNew, (int)m_accellerators.size());
        }
Ejemplo n.º 16
0
void CAccelerator::Setup()
{
	// Translate key table -> windows accelerator table

	if (m_hAccel) {
		DestroyAcceleratorTable(m_hAccel);
		m_hAccel = NULL;
	}

	memset(AccelTable, 0, sizeof(ACCEL) * ACCEL_COUNT);

	for (int i = 0; i < ACCEL_COUNT; ++i) {
		AccelTable[i].cmd = EntriesTable[i].id;
		AccelTable[i].fVirt = FVIRTKEY | GetMod(EntriesTable[i].mod);
		AccelTable[i].key = EntriesTable[i].key;
	}

	m_hAccel = CreateAcceleratorTable(AccelTable, ACCEL_COUNT);
}
Ejemplo n.º 17
0
void configwnd_create()
{
	WNDCLASS wc;
	HWND wnd;
	MSG msg;
	HACCEL acctable = CreateAcceleratorTable((LPACCEL)&c_AccelTable, sizeof(c_AccelTable) / sizeof(ACCEL));
	InitCommonControls();
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hIcon = LoadIcon(g_hInstance, OPTWND_ICON_NAME);
	wc.hInstance = g_hInstance;
	wc.lpszMenuName = NULL;
	wc.style = CS_PARENTDC | CS_DBLCLKS;
	wc.lpfnWndProc = configwnd_msgproc;
	wc.lpszClassName = OPTWND_CLASS_NAME;
	RegisterClass(&wc);
	g_hFont = CreateFont(-10, 0, 0, 0, FW_NORMAL, 0,
				0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
				DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, OPTWND_FONT_NAME);
	wnd = CreateWindowEx(0, OPTWND_CLASS_NAME, OPTWND_WINDOW_NAME, WS_VISIBLE | WS_SYSMENU | WS_OVERLAPPED | DS_SYSMODAL,
			(GetSystemMetrics(SM_CXSCREEN) - OPTWND_WINDOW_WIDTH) / 2,
			(GetSystemMetrics(SM_CYSCREEN) - OPTWND_WINDOW_HEIGHT) / 2,
			OPTWND_WINDOW_WIDTH, OPTWND_WINDOW_HEIGHT, g_hwndOlly, NULL, g_hInstance, NULL);
	ShowWindow(wnd, SW_SHOWNORMAL);
	UpdateWindow(wnd);
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(wnd, acctable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	DeleteObject(g_hFont);
	UnregisterClass(OPTWND_CLASS_NAME, g_hInstance);
	DestroyAcceleratorTable(acctable);
}
Ejemplo n.º 18
0
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_OSISP1, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);
	MyChildRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = CreateAcceleratorTable(TableAccel(),4);

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	DestroyAcceleratorTable(hAccelTable);
	return (int) msg.wParam;
}
Ejemplo n.º 19
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
{
	MSG msg;
	const WNDCLASS wndclass = { 0, WndProc, 0, 0, hInstance, 0, LoadCursor(0, IDC_ARROW), 0, 0, szClassName };
	RegisterClass(&wndclass);
	RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
	const DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
	AdjustWindowRect(&rect, dwStyle, 0);
	const HWND hWnd = CreateWindow(szClassName, 0, dwStyle, CW_USEDEFAULT, 0, rect.right - rect.left, rect.bottom - rect.top, 0, 0, hInstance, 0);
	ShowWindow(hWnd, SW_SHOWDEFAULT);
	UpdateWindow(hWnd);
	ACCEL Accel[] = { { FVIRTKEY, VK_ESCAPE, ID_EDITSHOW }, { FVIRTKEY | FCONTROL, 'A', ID_SELECTALL } };
	const HACCEL hAccel = CreateAcceleratorTable(Accel, sizeof(Accel) / sizeof(ACCEL));
	BOOL done = 0;
	while (!done)
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
			{
				done = TRUE;
			}
			else if (!TranslateAccelerator(hWnd, hAccel, &msg))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else if (active)
		{
			DrawGLScene();
			SwapBuffers(hDC);
		}
	}
	DestroyAcceleratorTable(hAccel);
	return msg.wParam;
}
Ejemplo n.º 20
0
CHtmlPanelUIHandlerBase::CHtmlPanelUIHandlerBase()
{
  m_blockedAcceleratorsTable = CreateAcceleratorTable(blockedAccelerators, _countof(blockedAccelerators));
}
Ejemplo n.º 21
0
LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
{
	if(wParam == MSG_PROGRESSDLG_START)
	{
		m_BufStart = 0 ;
		m_Animate.Play(0, INT_MAX, INT_MAX);
		DialogEnableWindow(IDCANCEL, TRUE);
		if (m_pTaskbarList)
		{
			m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
			m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
		}
	}
	if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
	{
		CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": got message: %d\n"), wParam);
		ULONGLONG tickSpent = GetTickCount64() - m_startTick;
		CString strEndTime = CLoglistUtils::FormatDateAndTime(CTime::GetCurrentTime(), DATE_SHORTDATE, true, false);

		if(m_bBufferAll)
		{
			m_Databuf.m_critSec.Lock();
			m_Databuf.push_back(0);
			m_Log.SetWindowText(Convert2UnionCode((char*)&m_Databuf[0]));
			m_Databuf.m_critSec.Unlock();
		}
		m_BufStart=0;
		m_Databuf.m_critSec.Lock();
		this->m_Databuf.clear();
		m_Databuf.m_critSec.Unlock();

		m_bDone = true;
		m_Animate.Stop();
		m_Progress.SetPos(100);
		this->DialogEnableWindow(IDOK,TRUE);

		m_GitStatus = (DWORD)lParam;
		if (m_GitCmd.IsEmpty() && m_GitCmdList.empty())
			m_GitStatus = (DWORD)-1;

		// detect crashes of perl when performing git svn actions
		if (m_GitStatus == 0 && m_GitCmd.Find(_T(" svn ")) > 1)
		{
			CString log;
			m_Log.GetWindowText(log);
			if (log.GetLength() > 18 && log.Mid(log.GetLength() - 18) == _T("perl.exe.stackdump"))
				m_GitStatus = (DWORD)-1;
		}

		if (m_PostExecCallback)
		{
			CString extraMsg;
			m_PostExecCallback(m_GitStatus, extraMsg);
			if (!extraMsg.IsEmpty())
			{
				int start = m_Log.GetTextLength();
				m_Log.SetSel(start, start);
				m_Log.ReplaceSel(extraMsg);
			}
		}

		if(this->m_GitStatus)
		{
			if (m_pTaskbarList)
			{
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
				m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
			}
			CString log;
			log.Format(IDS_PROC_PROGRESS_GITUNCLEANEXIT, m_GitStatus);
			CString err;
			if (CRegDWORD(_T("Software\\TortoiseGit\\ShowGitexeTimings"), TRUE))
				err.Format(_T("\r\n\r\n%s (%I64u ms @ %s)\r\n"), (LPCTSTR)log, tickSpent, (LPCTSTR)strEndTime);
			else
				err.Format(_T("\r\n\r\n%s\r\n"), (LPCTSTR)log);
			if (!m_GitCmd.IsEmpty() || !m_GitCmdList.empty())
				InsertColorText(this->m_Log, err, RGB(255,0,0));
			if (CRegDWORD(_T("Software\\TortoiseGit\\NoSounds"), FALSE) == FALSE)
				PlaySound((LPCTSTR)SND_ALIAS_SYSTEMEXCLAMATION, nullptr, SND_ALIAS_ID | SND_ASYNC);
		}
		else {
			if (m_pTaskbarList)
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
			CString temp;
			temp.LoadString(IDS_SUCCESS);
			CString log;
			if (CRegDWORD(_T("Software\\TortoiseGit\\ShowGitexeTimings"), TRUE))
				log.Format(_T("\r\n%s (%I64u ms @ %s)\r\n"), (LPCTSTR)temp, tickSpent, (LPCTSTR)strEndTime);
			else
				log.Format(_T("\r\n%s\r\n"), (LPCTSTR)temp);
			InsertColorText(this->m_Log, log, RGB(0,0,255));
			this->DialogEnableWindow(IDCANCEL,FALSE);
		}

		m_Log.PostMessage(WM_VSCROLL, SB_BOTTOM, 0);

		if (wParam == MSG_PROGRESSDLG_END)
		{
			if (m_PostCmdCallback)	// new handling method using callback
			{
				m_PostCmdCallback(m_GitStatus, m_PostCmdList);

				if (!m_PostCmdList.empty())
				{
					int i = 0;
					for (const auto& entry : m_PostCmdList)
					{
						++i;
						m_ctrlPostCmd.AddEntry(entry.icon, entry.label);
						TCHAR accellerator = CStringUtils::GetAccellerator(entry.label);
						if (accellerator == L'\0')
							continue;
						++m_accellerators[accellerator].cnt;
						if (m_accellerators[accellerator].cnt > 1)
							m_accellerators[accellerator].id = -1;
						else
							m_accellerators[accellerator].id = i - 1;
					}

					if (m_accellerators.size())
					{
						LPACCEL lpaccelNew = (LPACCEL)LocalAlloc(LPTR, m_accellerators.size() * sizeof(ACCEL));
						SCOPE_EXIT { LocalFree(lpaccelNew); };
						i = 0;
						for (auto& entry : m_accellerators)
						{
							lpaccelNew[i].cmd = (WORD)(WM_USER + 1 + entry.second.id);
							lpaccelNew[i].fVirt = FVIRTKEY | FALT;
							lpaccelNew[i].key = entry.first;
							entry.second.wmid = lpaccelNew[i].cmd;
							++i;
						}
						m_hAccel = CreateAcceleratorTable(lpaccelNew, (int)m_accellerators.size());
					}
					GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
				}
			}
//////////////////////////////////////////////////////////////////////
// Update the application's ACCELs table
//
bool CAcceleratorManager::UpdateWndTable()
{
	int iLoop = 0;
	CTypedPtrArray<CPtrArray, LPACCEL> arrayACCEL;

	CCmdAccelOb*pCmdAccel;
	WORD        wKey;
	LPACCEL     pACCEL;
	CAccelsOb*  pAccelOb;
	POSITION    pos = m_mapAccelTable.GetStartPosition();
	while (pos != NULL)
	{
		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
		while (pos != NULL)
		{
			pAccelOb = pCmdAccel->m_Accels.GetNext(pos);

			pACCEL = new ACCEL;
			ASSERT(pACCEL != NULL);
			pACCEL->fVirt = pAccelOb->m_cVirt;
			pACCEL->key   = pAccelOb->m_wKey;
			pACCEL->cmd   = pCmdAccel->m_wIDCommand;
			arrayACCEL.Add(pACCEL);
		}
	}

	int     nAccel  = arrayACCEL.GetSize();
	LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
	if (!lpAccel)
	{
		for (iLoop = 0; iLoop < nAccel; iLoop++)
			delete arrayACCEL.GetAt(iLoop);
		arrayACCEL.RemoveAll();

		return false;
	}

	for (iLoop = 0; iLoop < nAccel; iLoop++)
	{
		pACCEL = arrayACCEL.GetAt(iLoop);
		lpAccel[iLoop].fVirt = pACCEL->fVirt;
		lpAccel[iLoop].key   = pACCEL->key;
		lpAccel[iLoop].cmd   = pACCEL->cmd;

		delete pACCEL;
	}
	arrayACCEL.RemoveAll();

	HACCEL hNewTable = CreateAcceleratorTable(lpAccel, nAccel);
	if (!hNewTable)
	{
		::LocalFree(lpAccel);
		return false;
	}
	HACCEL hOldTable = theApp.hAccel;
	if (!::DestroyAcceleratorTable(hOldTable))
	{
		::LocalFree(lpAccel);
		return false;
	}
	theApp.hAccel = hNewTable;
	::LocalFree(lpAccel);

	UpdateMenu(GetMenu(*AfxGetApp()->m_pMainWnd));

	return true;
}
Ejemplo n.º 23
0
static void test_accel1(void)
{
    UINT r, n;
    HACCEL hAccel;
    ACCEL ac[10];

    /* now create our own valid accelerator table */
    n = 0;
    ac[n].cmd = 1000;
    ac[n].key = 'A';
    ac[n++].fVirt = FVIRTKEY | FNOINVERT;

    ac[n].cmd = 1001;
    ac[n].key = 'B';
    ac[n++].fVirt = FNOINVERT;

    ac[n].cmd = 0;
    ac[n].key = 0;
    ac[n++].fVirt = 0;

    hAccel = CreateAcceleratorTable( &ac[0], n );
    ok( hAccel != NULL, "create accelerator table\n");

    r = DestroyAcceleratorTable( hAccel );
    ok( r, "destroy accelerator table\n");

    /* now try create an invalid one */
    n = 0;
    ac[n].cmd = 1000;
    ac[n].key = 'A';
    ac[n++].fVirt = FVIRTKEY | FNOINVERT;

    ac[n].cmd = 0xffff;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0xffff;

    ac[n].cmd = 0xfff0;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0xfff0;

    ac[n].cmd = 0xfff0;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0x0000;

    ac[n].cmd = 0xfff0;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0x0001;

    hAccel = CreateAcceleratorTable( &ac[0], n );
    ok( hAccel != NULL, "create accelerator table\n");

    r = CopyAcceleratorTable( hAccel, NULL, 0 );
    ok( r == n, "two entries in table\n");

    r = CopyAcceleratorTable( hAccel, &ac[0], r );
    ok( r == n, "still should be two entries in table\n");

    n=0;
    ok( ac[n].cmd == 1000, "cmd 0 not preserved\n");
    ok( ac[n].key == 'A', "key 0 not preserved\n");
    ok( ac[n].fVirt == (FVIRTKEY | FNOINVERT), "fVirt 0 not preserved\n");

    n++;
    ok( ac[n].cmd == 0xffff, "cmd 1 not preserved\n");
    ok( ac[n].key == 0xffff, "key 1 not preserved\n");
    ok( ac[n].fVirt == 0x007f, "fVirt 1 not changed\n");

    n++;
    ok( ac[n].cmd == 0xfff0, "cmd 2 not preserved\n");
    ok( ac[n].key == 0x00ff, "key 2 not preserved\n");
    ok( ac[n].fVirt == 0x0070, "fVirt 2 not changed\n");

    n++;
    ok( ac[n].cmd == 0xfff0, "cmd 3 not preserved\n");
    ok( ac[n].key == 0x00ff, "key 3 not preserved\n");
    ok( ac[n].fVirt == 0x0000, "fVirt 3 not changed\n");

    n++;
    ok( ac[n].cmd == 0xfff0, "cmd 4 not preserved\n");
    ok( ac[n].key == 0xffff, "key 4 not preserved\n");
    ok( ac[n].fVirt == 0x0001, "fVirt 4 not changed\n");

    r = DestroyAcceleratorTable( hAccel );
    ok( r, "destroy accelerator table\n");

    hAccel = CreateAcceleratorTable( &ac[0], 0 );
    ok( !hAccel, "zero elements should fail\n");

    /* these will on crash win2k
    hAccel = CreateAcceleratorTable( NULL, 1 );
    hAccel = CreateAcceleratorTable( &ac[0], -1 );
    */
}
Ejemplo n.º 24
0
static void test_accel1(void)
{
    UINT r, n;
    HACCEL hAccel;
    ACCEL ac[10];

    /* now create our own valid accelerator table */
    n = 0;
    ac[n].cmd = 1000;
    ac[n].key = 'A';
    ac[n++].fVirt = FVIRTKEY | FNOINVERT;

    ac[n].cmd = 1001;
    ac[n].key = 'B';
    ac[n++].fVirt = FNOINVERT;

    ac[n].cmd = 0;
    ac[n].key = 0;
    ac[n++].fVirt = 0;

    hAccel = CreateAcceleratorTable( &ac[0], n );
    ok( hAccel != NULL, "create accelerator table\n");

    r = DestroyAcceleratorTable( hAccel );
    ok( r, "destroy accelerator table\n");

    /* now try create an invalid one */
    n = 0;
    ac[n].cmd = 1000;
    ac[n].key = 'A';
    ac[n++].fVirt = FVIRTKEY | FNOINVERT;

    ac[n].cmd = 0xffff;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0xffff;

    ac[n].cmd = 0xfff0;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0xfff0;

    ac[n].cmd = 0xfff0;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0x0000;

    ac[n].cmd = 0xfff0;
    ac[n].key = 0xffff;
    ac[n++].fVirt = (SHORT) 0x0001;

    hAccel = CreateAcceleratorTable( &ac[0], n );
    ok( hAccel != NULL, "create accelerator table\n");

    r = CopyAcceleratorTable( hAccel, NULL, 0 );
    ok( r == n, "two entries in table %u/%u\n", r, n);

    r = CopyAcceleratorTable( hAccel, &ac[0], n );
    ok( r == n, "still should be two entries in table %u/%u\n", r, n);

    n=0;
    ok( ac[n].cmd == 1000, "cmd 0 not preserved got %x\n", ac[n].cmd);
    ok( ac[n].key == 'A', "key 0 not preserved got %x\n", ac[n].key);
    ok( ac[n].fVirt == (FVIRTKEY | FNOINVERT), "fVirt 0 not preserved got %x\n", ac[n].fVirt);

    if (++n == r) goto done;
    ok( ac[n].cmd == 0xffff, "cmd 1 not preserved got %x\n", ac[n].cmd);
    ok( ac[n].key == 0xffff, "key 1 not preserved got %x\n", ac[n].key);
    ok( ac[n].fVirt == 0x007f, "fVirt 1 wrong got %x\n", ac[n].fVirt);

    if (++n == r) goto done;
    ok( ac[n].cmd == 0xfff0, "cmd 2 not preserved got %x\n", ac[n].cmd);
    ok( (ac[n].key & 0xff) == 0xff, "key 2 not preserved got %x\n", ac[n].key);
    ok( ac[n].fVirt == 0x0070, "fVirt 2 wrong got %x\n", ac[n].fVirt);

    if (++n == r) goto done;
    ok( ac[n].cmd == 0xfff0, "cmd 3 not preserved got %x\n", ac[n].cmd);
    ok( (ac[n].key & 0xff) == 0xff, "key 3 not preserved got %x\n", ac[n].key);
    ok( ac[n].fVirt == 0x0000, "fVirt 3 wrong got %x\n", ac[n].fVirt);

    if (++n == r) goto done;
    ok( ac[n].cmd == 0xfff0, "cmd 4 not preserved got %x\n", ac[n].cmd);
    ok( ac[n].key == 0xffff, "key 4 not preserved got %x\n", ac[n].key);
    ok( ac[n].fVirt == 0x0001, "fVirt 4 wrong  got %x\n", ac[n].fVirt);
done:
    r = DestroyAcceleratorTable( hAccel );
    ok( r, "destroy accelerator table\n");

    hAccel = CreateAcceleratorTable( &ac[0], 0 );
    ok( !hAccel || broken(hAccel != NULL), /* nt4 */ "zero elements should fail\n");

    /* these will on crash win2k
    hAccel = CreateAcceleratorTable( NULL, 1 );
    hAccel = CreateAcceleratorTable( &ac[0], -1 );
    */
}
Ejemplo n.º 25
0
BOOL CPopupFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) 
{
	CFormDoc* pDoc = (CFormDoc *)pContext->m_pCurrentDoc;
	ASSERT_VALID(pDoc);

	m_strCaption = pDoc->m_strCaption;
	
	m_cx = (int)pDoc->GetWidth();
	m_cy = (int)pDoc->GetHeight();

	if (pDoc->m_enumStartUpPosition == StartUpPositionWindowsDefault)
	{
		m_x = 0;
		m_y = 0;
	}
	else if (pDoc->m_enumStartUpPosition == StartUpPositionManual)
	{
		m_x = (int)pDoc->GetHorizontalPosition();
		m_y = (int)pDoc->GetVerticalPosition();
	}
	else 
	{
		CRect rect;
		
		if (pDoc->m_enumStartUpPosition == StartUpPositionOwner)
		{
			pParentWnd->GetWindowRect(&rect);
		}
		else
		{
			rect.left = 0;
			rect.top = 0;
			rect.right = GetSystemMetrics(SM_CXSCREEN);
			rect.bottom = GetSystemMetrics(SM_CYSCREEN);
		}
	
		if (rect.Width() > m_cx)
			m_x = (rect.right + rect.left - m_cx) / 2;
		
		if (rect.Height() > m_cy)
			m_y = (rect.bottom + rect.top - m_cy) / 2;
	}

	if (!pDoc->IsMainForm())
	{
		m_bTopMost = TRUE;
		m_bCaption = pDoc->m_enumBorderStyle != BorderStyleNone;
		m_bThickframe = pDoc->m_enumBorderStyle == BorderStyleSizable;
		m_bControlBox = pDoc->m_bControlBox;
	}
	
	BOOL b = CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext);

	if (b)
	{
		CDevObj* pObj = pDoc->GetMenuObject();
		if (pObj != NULL)
		{
			CMenu menu;
			menu.CreateMenu();
					
			CComQIPtr<IDrawMenu, &IID_IDrawMenu> spDrawMenu(pObj->GetObjectUnknown());
			long lCount;
			spDrawMenu->get_ItemCount(&lCount);
			
			int nIndex = 0;
			AddMenuItems(menu.m_hMenu, spDrawMenu, nIndex, lCount, 0);

			m_pMenu = spDrawMenu;
			SetMenu(&menu);

			menu.Detach();

			if (m_arrAccels.GetSize() > 0)
				m_hAccelTable = CreateAcceleratorTable(m_arrAccels.GetData(), m_arrAccels.GetSize());

		}
	}

	return b;
}
Ejemplo n.º 26
0
/*
 *  memcmp on the tables works in Windows, but does not work in wine, as
 *  there is an extra undefined and unused byte between fVirt and the key
 */
static void test_accel2(void)
{
    ACCEL ac[2], out[2];
    HACCEL hac;
    int res;

    ac[0].cmd   = 0;
    ac[0].fVirt = 0;
    ac[0].key   = 0;

    ac[1].cmd   = 0;
    ac[1].fVirt = 0;
    ac[1].key   = 0;

    /*
     * crashes on win2k
     * hac = CreateAcceleratorTable( NULL, 1 );
     */

    /* try a zero count */
    hac = CreateAcceleratorTable( &ac[0], 0 );
    ok( !hac || broken(hac != NULL), /* nt4 */ "fail\n");
    if (!hac) ok( !DestroyAcceleratorTable( hac ), "destroy failed\n");

    /* creating one accelerator should work */
    hac = CreateAcceleratorTable( &ac[0], 1 );
    ok( hac != NULL , "fail\n");
    ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy failed\n");
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");

    /* how about two of the same type? */
    hac = CreateAcceleratorTable( &ac[0], 2);
    ok( hac != NULL , "fail\n");
    res = CopyAcceleratorTable( hac, NULL, 100 );
    ok( res == 2, "copy null failed %d\n", res);
    res = CopyAcceleratorTable( hac, NULL, 0 );
    ok( res == 2, "copy null failed %d\n", res);
    res = CopyAcceleratorTable( hac, NULL, 1 );
    ok( res == 2, "copy null failed %d\n", res);
    ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy 1 failed\n");
    ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n");
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");
    /* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */

    /* how about two of the same type with a non-zero key? */
    ac[0].key = 0x20;
    ac[1].key = 0x20;
    hac = CreateAcceleratorTable( &ac[0], 2);
    ok( hac != NULL , "fail\n");
    ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n");
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");
    /* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */

    /* how about two of the same type with a non-zero virtual key? */
    ac[0].fVirt = FVIRTKEY;
    ac[0].key = 0x40;
    ac[1].fVirt = FVIRTKEY;
    ac[1].key = 0x40;
    hac = CreateAcceleratorTable( &ac[0], 2);
    ok( hac != NULL , "fail\n");
    ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n");
    /* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");

    /* how virtual key codes */
    ac[0].fVirt = FVIRTKEY;
    hac = CreateAcceleratorTable( &ac[0], 1);
    ok( hac != NULL , "fail\n");
    ok( 1 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n");
    /* ok( !memcmp( ac, out, sizeof ac/2 ), "tables different\n"); */
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");

    /* how turning on all bits? */
    ac[0].cmd   = 0xffff;
    ac[0].fVirt = 0xff;
    ac[0].key   = 0xffff;
    hac = CreateAcceleratorTable( &ac[0], 1);
    ok( hac != NULL , "fail\n");
    ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy 1 failed\n");
    /* ok( memcmp( ac, out, sizeof ac/2 ), "tables not different\n"); */
    ok( out[0].cmd == ac[0].cmd, "cmd modified\n");
    ok( out[0].fVirt == (ac[0].fVirt&0x7f), "fVirt not modified\n");
    ok( out[0].key == ac[0].key, "key modified\n");
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");

    /* how turning on all bits? */
    memset( ac, 0xff, sizeof ac );
    hac = CreateAcceleratorTable( &ac[0], 2);
    ok( hac != NULL , "fail\n");
    res = CopyAcceleratorTable( hac, out, 2 );
    ok( res == 2, "copy 2 failed %d\n", res);
    /* ok( memcmp( ac, out, sizeof ac ), "tables not different\n"); */
    ok( out[0].cmd == ac[0].cmd, "cmd modified\n");
    ok( out[0].fVirt == (ac[0].fVirt&0x7f), "fVirt not modified\n");
    ok( out[0].key == ac[0].key, "key modified\n");
    if (res == 2)
    {
        ok( out[1].cmd == ac[1].cmd, "cmd modified\n");
        ok( out[1].fVirt == (ac[1].fVirt&0x7f), "fVirt not modified\n");
        ok( out[1].key == ac[1].key, "key modified\n");
    }
    ok( DestroyAcceleratorTable( hac ), "destroy failed\n");
}
Ejemplo n.º 27
0
		void AccelTable::Update()
		{
			if (handle)
				DestroyAcceleratorTable(handle);
			handle = CreateAcceleratorTable(accels.Buffer(), accels.Count());
		}
//////////////////////////////////////////////////////////////////////
// Update the application's ACCELs table
//////////////////////////////////////////////////////////////////////
//
//
bool CAcceleratorManager::UpdateWndTable()
{
  int iLoop = 0;
  std::vector<LPACCEL> arrayACCEL;

  CCmdAccelOb* pCmdAccel;
  WORD wKey;
  LPACCEL pACCEL;
  CAccelsOb* pAccelOb;
  CMapWordToCCmdAccelOb::iterator it = m_mapAccelTable.begin();
  while (it != m_mapAccelTable.end()) {
    wKey = it->first;
    pCmdAccel = it->second;
    std::list<CAccelsOb*>::iterator it2 = pCmdAccel->m_Accels.begin();

    while (it2 != pCmdAccel->m_Accels.end()) {
      pAccelOb = *it2;
      it2++;

      pACCEL = new ACCEL;
      ASSERT(pACCEL != NULL);
      pACCEL->fVirt = pAccelOb->m_cVirt;
      pACCEL->key = pAccelOb->m_wKey;
      pACCEL->cmd = pCmdAccel->m_wIDCommand;
      arrayACCEL.push_back(pACCEL);
    }

    it++;
  }
        
  int nAccel = arrayACCEL.size();
  LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
  if (!lpAccel) {
    for (iLoop = 0; iLoop < nAccel; iLoop++)
      delete arrayACCEL.at(iLoop);
    arrayACCEL.clear();

    return false;
  }

  for (iLoop = 0; iLoop < nAccel; iLoop++) {
                
    pACCEL = arrayACCEL.at(iLoop);
    lpAccel[iLoop].fVirt = pACCEL->fVirt;
    lpAccel[iLoop].key = pACCEL->key;
    lpAccel[iLoop].cmd = pACCEL->cmd;

    delete pACCEL;
  }
  arrayACCEL.clear();

  HACCEL hNewTable = CreateAcceleratorTable(lpAccel, nAccel);
  if (!hNewTable) {
    ::LocalFree(lpAccel);
    return false;
  }
  HACCEL hOldTable = hAccel;
  if (!::DestroyAcceleratorTable(hOldTable)) {
    ::LocalFree(lpAccel);
    return false;
  }
  hAccel = hNewTable;
  ::LocalFree(lpAccel);

  UpdateMenu(GetMenu(hWindow));

  return true;
}
int WINAPI WinMain (HINSTANCE hInst,
                    HINSTANCE hPreInst,
                    LPSTR lpszCmdLine,
                    int nCmdShow)
{
        MSG lpMsg;
        WNDCLASS wcApp;
        ATOM classAtom;
                HWND hMainWindow;


        if (!hPreInst) {
           wcApp.lpszClassName = szClassName;   // name of this class
           wcApp.hInstance = hInst;             // instance handle
           wcApp.lpfnWndProc = WndProc;         // window procedure
           wcApp.hCursor =                      // load custom cursor
                  LoadCursor(hInst,MAKEINTRESOURCE(IDC_CURSOR1));
           wcApp.hIcon =                        // load custom icon
              LoadIcon(hInst,MAKEINTRESOURCE(IDI_ICON2));
           wcApp.lpszMenuName =
              MAKEINTRESOURCE(HIWORLDMENU);     // menu identifier
           wcApp.hbrBackground =                // background is white
              GetStockObject(WHITE_BRUSH);
           wcApp.cbClsExtra = 0;                // no class words
           wcApp.cbWndExtra = 0;                // no window words
           wcApp.style = CS_HREDRAW|CS_VREDRAW; // redraw on horizontal and vertical changes

           classAtom = RegisterClass(&wcApp);   // register the window class
           if (classAtom==0) {                  // was the register successful?
              return FALSE;                     // return to caller
                  }
        }

        hMainWindow = CreateWindow(szClassName, // class name
                            szProgName,         // window name
                            WS_OVERLAPPEDWINDOW,// window style
                            newX,               // x position
                            newY,               // y position
                            3*newX,             // width
                            3*newY,             // height
                            (HWND) NULL,        // parent handle - not used
                            (HMENU) NULL,       // menu handle - use class menu
                            (HANDLE) hInst,     // instance handle
                            (LPVOID) NULL);     // window creation data - not used

        ShowWindow(hMainWindow,nCmdShow);       // set show state
        UpdateWindow(hMainWindow);              // update client area of the window

        hMyAccelTable =                         // create accel table
           CreateAcceleratorTable(accelTable,NUMBER_OF_ACCELTABLE_ENTRIES);

        // standard message loop with accelerator handling
        while (GetMessage(&lpMsg,NULL,0,0)) {
                if (!TranslateAccelerator(hMainWindow,hMyAccelTable,&lpMsg)) {
                        TranslateMessage(&lpMsg);
                        DispatchMessage(&lpMsg);
                }
        }

        DestroyAcceleratorTable(hMyAccelTable); // cleanup accel table

        return (lpMsg.wParam);                  // return to caller
}
Ejemplo n.º 30
0
HACCEL uikeyboard_create_accelerator_table(void)
{
    FILE *fshortcuts;
    char *complete_path;
    char buffer[1000];
    char *p, *menustr, *metastr, *keystr, *displaystr;
    int i;

    accelnum = 0;
    menuitemmodifier_len = 0;
    for (i = 0; idmlist[i].str != NULL; i++) {
        if (idmlist[i].cmd >= menuitemmodifier_len) {
            menuitemmodifier_len = idmlist[i].cmd + 1;
        }
    }

    menuitemmodifier = lib_calloc(menuitemmodifier_len, sizeof(char*));
    memset(menuitemmodifier, 0, menuitemmodifier_len * sizeof(char*));

    fshortcuts = sysfile_open("win_shortcuts.vsc", &complete_path, MODE_READ_TEXT);
    lib_free(complete_path);
    if (fshortcuts == NULL) {
        log_error(LOG_DEFAULT, "Warning. Cannot open keyboard shortcut file win_shortcuts.vsc.");
        return NULL;
    }

    /* read the shortcut table */
    do {
        buffer[0] = 0;
        if (fgets(buffer, 999, fshortcuts)) {

            if (strlen(buffer) == 0) {
                break;
            }

            buffer[strlen(buffer) - 1] = 0; /* remove newline */

	      /* remove comments */
	      if ((p = strchr(buffer, '#'))) {
                *p = 0;
            }

            metastr = strtok(buffer, " \t:");
            keystr = strtok(NULL, " \t:");
            menustr = strtok(NULL, " \t:");
            displaystr = strtok(NULL, " \t:");
	      if (displaystr && (p = strchr(displaystr, '#'))) {
	          *p = 0;
            }

            if (metastr && keystr && menustr) {
                for (i = 0; idmlist[i].str; i++) {
                    if (strcmp(idmlist[i].str, menustr) == 0) {
                        break;
                    }
                }

                if (idmlist[i].str) {
                    ACCEL accel;

                    accel.fVirt = FVIRTKEY | FNOINVERT;
                    if (strstr(strlwr(metastr), "shift") != NULL) {
                        accel.fVirt |= FSHIFT;
                    }
                    if (strstr(strlwr(metastr), "ctrl") != NULL) {
                        accel.fVirt |= FCONTROL;
                    }
                    if (strstr(strlwr(metastr), "alt") != NULL) {
                        accel.fVirt |= FALT;
                    }

                    if (keystr[0] == '\'' && keystr[2] == '\'') {
                        accel.key = keystr[1];
                        if (displaystr == NULL || displaystr[0] == 0) {
                            displaystr = keystr + 1;
                            keystr[2] = 0;
                        }
                    } else {
                        accel.key = (unsigned short)strtol(keystr, NULL, 0);
                    }

                    accel.cmd = idmlist[i].cmd;

                    if (accel.key > 0 && accel.cmd > 0 && accelnum < MAXACCEL) {
                        accellist[accelnum++] = accel;
                    }

                    if (displaystr != NULL && menuitemmodifier[accel.cmd] == NULL) {
                        p = util_concat("\t",
                                        ((accel.fVirt & FSHIFT  ) ? "Shift+" : ""),
                                        ((accel.fVirt & FCONTROL) ? "Ctrl+" : ""),
                                        ((accel.fVirt & FALT) ? "Alt+" : ""),
                                        displaystr, NULL);

                        menuitemmodifier[accel.cmd] = p;
                    }
                }
            }
        }
    } while (!feof(fshortcuts));
    fclose(fshortcuts);

    return CreateAcceleratorTable(accellist, accelnum);
}