示例#1
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInst*/, LPSTR /*lpszCmdParam*/, int nCmdShow) 
{
	MSG msg;
	HACCEL hAccel = AtlLoadAccelerators(IDR_ACCELERATOR1);
	if (!LoadLibrary("RICHED32.DLL"))
	{
		MessageBox(nullptr, "Could not load RICHED32.DLL", nullptr, MB_OK);
		return (FALSE);
	}

	if (!InitApplication(hInstance)) 
	{
		MessageBox(nullptr, "Could not initialize application", nullptr, MB_OK);
		return (FALSE);
	}

	if (!InitInstance(hInstance, nCmdShow)) 
	{
		MessageBox(nullptr, "Could not create window", nullptr, MB_OK);
		return (FALSE);
	}

	// message loop
	while (GetMessage(&msg, nullptr, 0, 0))
	{
		if (!TranslateAccelerator(hwnd_main,hAccel,&msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	} // while(GetMessage...
	
	return static_cast<int>(msg.wParam);
} // WinMain
示例#2
0
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// center the dialog on the screen
	CenterWindow();

	// set icons
	HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
	SetIcon(hIconSmall, FALSE);

	// register object for message filtering and idle updates
	m_haccelerator = AtlLoadAccelerators(IDR_MAINFRAME);
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	UIAddChildWindowContainer(m_hWnd);

	return TRUE;
}
示例#3
0
LRESULT CPlayList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// Init the CDialogResize code
	DlgResize_Init();
    //Bind keys...
    m_haccelerator = AtlLoadAccelerators(IDR_ACCELERATORS_PLAYLIST);
	
	// bind buttons with objects
	btnAdd.Attach(GetDlgItem(IDC_BTN_ADD));
	btnRemove.Attach(GetDlgItem(IDC_BTN_REMOVE));
	btnAddFolder.Attach(GetDlgItem(IDC_BTN_ADDFOLDER));
	btnLoadPlayList.Attach(GetDlgItem(IDC_BTN_LOADPL));
	btnSavePlayList.Attach(GetDlgItem(IDC_BTN_SAVEPL));
	btnPrevMod.Attach(GetDlgItem(IDC_BTN_PREVMODULE));
	btnPlayMod.Attach(GetDlgItem(IDC_BTN_PLAYSELECTION));
	btnNextMod.Attach(GetDlgItem(IDC_BTN_NEXTMODULE));
	HINSTANCE inst = _Module.GetResourceInstance();
	// load & set button icons
	HICON icon = (HICON) ::LoadImage(inst, MAKEINTRESOURCE(IDI_ICON_OPEN),
		IMAGE_ICON, 16, 16, LR_SHARED);
	btnLoadPlayList.SetIcon(icon);
	icon = (HICON) ::LoadImage(inst, MAKEINTRESOURCE(IDI_ICON_SAVE),
		IMAGE_ICON, 16, 16, LR_SHARED);
	btnSavePlayList.SetIcon(icon);
	icon = (HICON) ::LoadImage(inst, MAKEINTRESOURCE(IDI_ICON_PREV),
		IMAGE_ICON, 16, 16, LR_SHARED);
	btnPrevMod.SetIcon(icon);
	icon = (HICON) ::LoadImage(inst, MAKEINTRESOURCE(IDI_ICON_PLAY),
		IMAGE_ICON, 16, 16, LR_SHARED);
	btnPlayMod.SetIcon(icon);
	icon = (HICON) ::LoadImage(inst, MAKEINTRESOURCE(IDI_ICON_NEXT),
		IMAGE_ICON, 16, 16, LR_SHARED);
	btnNextMod.SetIcon(icon);
	//
	UINT uCToolTipCtrlStyle = TTS_NOPREFIX |TTS_NOFADE | TTS_NOANIMATE; // | TTS_BALLOON
	UINT uToolFlags = TTF_IDISHWND | TTF_SUBCLASS;

	ATLVERIFY(NULL != m_wndToolTip[0].Create(m_hWnd, 0, NULL, uCToolTipCtrlStyle)); // WS_POPUP|TTS_NOPREFIX|TTS_NOFADE|TTS_NOANIMATE
	CToolInfo toolInfo(uToolFlags, btnAdd.m_hWnd, 0, 0, _T("Add file(s)"));
	m_wndToolTip[0].AddTool(&toolInfo);
	m_wndToolTip[0].SetDelayTime(TTDT_INITIAL,0);
	m_wndToolTip[0].SetDelayTime(TTDT_RESHOW,0);
	m_wndToolTip[0].Activate(TRUE);
	
	ATLVERIFY(NULL != m_wndToolTip[1].Create(m_hWnd, 0, NULL, uCToolTipCtrlStyle));
	toolInfo.Init(uToolFlags, btnRemove.m_hWnd, 0, 0, _T("Remove File(s)"));
	m_wndToolTip[1].AddTool(&toolInfo);
	m_wndToolTip[1].Activate(TRUE);

	ATLVERIFY(NULL != m_wndToolTip[2].Create(m_hWnd, 0, NULL, uCToolTipCtrlStyle));
	toolInfo.Init(uToolFlags, btnAddFolder.m_hWnd, 0, 0, _T("Add Folder"));
	m_wndToolTip[2].AddTool(&toolInfo);
	m_wndToolTip[2].Activate(TRUE);
	
	// Create the listview columns
	playListView.Attach(GetDlgItem(IDC_LSV1));
	playListView.SetView(LV_VIEW_DETAILS);
	// FIXME doesnt work
	//playListView.SetExtendedListViewStyle(LVS_SHOWSELALWAYS);
	playListView.AddColumn(_T("Filename"), LV_FIELD_FILENAME);
	playListView.SetColumnWidth(LV_FIELD_FILENAME, 150);
	//
	playListView.AddColumn(_T("Title"), LV_FIELD_TITLE);
	playListView.SetColumnWidth(LV_FIELD_TITLE, 120);
	//
	playListView.AddColumn(_T("Author"), LV_FIELD_AUTHOR);
	playListView.SetColumnWidth(LV_FIELD_TITLE, 250);
	//
	playListView.AddColumn(_T("Released"), LV_FIELD_RELEASED);
	playListView.SetColumnWidth(LV_FIELD_TITLE, 200);
	//
	playListView.AddColumn(_T("Path"), LV_FIELD_PATH);
	playListView.SetColumnWidth(LV_FIELD_PATH, 300);
	//
	playListView.AddColumn(_T("Status"), LV_FIELD_STATUS);
	playListView.SetColumnWidth(LV_FIELD_STATUS, 50);
	//
	playListView.AddColumn(_T("Type"), LV_FIELD_TYPE);
	playListView.SetColumnWidth(LV_FIELD_TYPE, 50);
	//
	playListView.AddColumn(_T("Load address"), LV_FIELD_LOAD_ADDRESS);
	playListView.SetColumnWidth(LV_FIELD_LOAD_ADDRESS, 32);
	//
	playListView.AddColumn(_T("#"), LV_FIELD_INDEX);
	playListView.SetColumnWidth(LV_FIELD_INDEX, 32);

	// register hotkeys for the playlist
	::RegisterHotKey(m_hWnd, 1, MOD_ALT | MOD_CONTROL, VK_RIGHT);
	::RegisterHotKey(m_hWnd, 2, MOD_ALT | MOD_CONTROL, VK_LEFT);
	//
	// register object for message filtering and idle updates    
    CMessageLoop* pLoop = _Module.GetMessageLoop();
    ATLASSERT(pLoop != NULL);
    pLoop->AddMessageFilter(this);
    pLoop->AddIdleHandler(this);
	return TRUE;
}