Exemple #1
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// HELP dialog
INT_PTR CALLBACK HELP(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_INITDIALOG)
	{
		InitHTMLControl(g_hInst);
		CeleCtrl::InitDlgBar(hWnd, IDR_DlgMenu, FALSE, TBSTATE_HIDDEN);

		HWND hHtml = CreateWindow(WC_HTML, NULL, WS_CHILD | WS_VISIBLE | HS_CONTEXTMENU, 0, 0, 0, 0, hWnd, (HMENU) IDC_Browse, g_hInst, NULL);

		if (lParam && *((PTSTR) lParam))
		{
			if ((UStrEqualI((PTSTR) lParam, TEXT("http://")) == 7) || (UStrEqualI((PTSTR) lParam, TEXT("file://")) == 7))
			{
				SendMessage(hHtml, DTM_NAVIGATE, NAVIGATEFLAG_ENTERED, lParam);
				return TRUE;
			}

			PTSTR ptzData;
			if (UFileExist((PTSTR) lParam) && (ptzData = UFileToStr((PTSTR) lParam)))
			{
				SendMessage(hHtml, DTM_ADDTEXTW, FALSE, (LPARAM) ptzData);
				SendMessage(hHtml, DTM_ENDOFSOURCE, 0, 0);
				UMemFree(ptzData);
				return TRUE;
			}
		}
		else
		{
			TCHAR tzPath[512];
			UDirGetAppExt(tzPath, TEXT("htm"));
			if (UFileExist(tzPath))
			{
				TCHAR tzUrl[MAX_PATH];
				UStrPrint(tzUrl, TEXT("file://%s"), tzPath);
				SendMessage(hHtml, DTM_NAVIGATE, NAVIGATEFLAG_ENTERED, (LPARAM) tzUrl);
				return TRUE;
			}
			lParam = (LPARAM) UStrGet(IDS_Help);
		}
		SendMessage(hHtml, DTM_ADDTEXTW, FALSE, lParam);
		SendMessage(hHtml, DTM_ENDOFSOURCE, 0, 0);
		return TRUE;
	}
	else if (uMsg == WM_SIZE)
	{
		MoveWindow(GetDlgItem(hWnd, IDC_Browse), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
	}
	else if (uMsg == WM_COMMAND)
	{
		if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
		{
			EndDialog(hWnd, S_OK);
		}
	}

	return FALSE;
}
Exemple #2
0
BOOL CICompApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

    InitHTMLControl(m_hInstance);
    InitCommonControls();


	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CICompDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CICompView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}
Exemple #3
0
void HtmlView::init() {
    BOOST_ASSERT(parentHWnd);

    SetCursor(cursorWait);
    if (htmlViewInstance==0) 
        htmlViewInstance=LoadLibrary(L"htmlview.dll");

    if (htmlViewInstance==0) throw std::exception("Unable to initialize HTML control");

    if(!InitHTMLControl( g_hInst )) throw std::exception("Unable to initialize HTML control");

    if (windowClass==0) 
        windowClass=RegisterWindowClass();

    if (windowClass==0) throw std::exception("Can't create window class");

    thisHWnd=CreateWindow((LPCTSTR)windowClass, _T("HtmlView"), WS_CHILD | WS_VISIBLE,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parentHWnd, NULL, g_hInst, (LPVOID)this);

    SetCursor(NULL);
}
Exemple #4
0
BOOL CPrssrApp::InitInstance() {
	LOG0(1, "CPrssrApp::InitInstance()");

	LoadSSL();
	// init win sock
	WSADATA wsaData;
	WSAStartup(0x0101, &wsaData);

	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("DaProfik"));

	// register wnd class
	WNDCLASS wc = { 0 };
	wc.lpfnWndProc = ::DefWindowProc;
	wc.hInstance = AfxGetInstanceHandle();
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = PRSSR_CLASS_NAME;
	if (!AfxRegisterClass(&wc))
		return FALSE;

	CFeedView::Register();
	CGroupView::Register();
	CTextProgressCtrl::Register();
	CInfoBar::Register();

	// get DPI
	HDC hdcScreen = ::GetDC(NULL);
	int nSystemDPI = ::GetDeviceCaps(hdcScreen, LOGPIXELSX);
	::ReleaseDC(NULL, hdcScreen);

	// load the resource library according to the system DPI
	CString resLibName;
	resLibName.Format(_T("res.%03d.dll"), nSystemDPI);
	m_hResDLL = LoadLibrary(resLibName);
	if (m_hResDLL == NULL) return Error(IDS_INTERNAL_ERROR, 0x00000002);

	if (!InitHTMLControl(AfxGetInstanceHandle()))
		return 0;

	// Initialize the control
	INITCOMMONCONTROLSEX icce;
	icce.dwSize = sizeof(icce);
	icce.dwICC = ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS | ICC_TREEVIEW_CLASSES | ICC_TOOLTIP_CLASSES | ICC_TAB_CLASSES;
	InitCommonControlsEx(&icce);

	SHInitExtraControls();

	// frame
	CMainFrame* pFrame = new CMainFrame();
	m_pMainWnd = pFrame;

	// create and load the frame with its resources
	pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW, NULL, NULL);

	// process cmd line
	CString strCmdLine = m_lpCmdLine;

	// minimized ?
	if (strCmdLine.Find(_T("/minimized")) != -1) {
		pFrame->ShowWindow(SW_MINIMIZE);
	}
	else {
		pFrame->ShowWindow(m_nCmdShow);
		pFrame->UpdateWindow();
	}

	if (strCmdLine.Find(_T("/updateall")) != -1) {
		pFrame->PostMessage(UWM_UPDATE_ALL);
	}

	int npos;
	if ((npos = strCmdLine.Find(_T("/opensite"))) != -1) {
		CString strSite = strCmdLine.Mid(npos + 10);
		int site;
		if (swscanf(strSite.GetBuffer(strSite.GetLength()), _T("%d"), &site) == 1) {
			// after sites are loaded, site with this value is opened
			pFrame->PostMessage(UWM_OPEN_SITE, site, 0);
		}
	}

	if ((npos = strCmdLine.Find(_T("/openitem"))) != -1) {
		CString sPar = strCmdLine.Mid(npos + 10);

		int site, feedIdx;
		if (swscanf(sPar.GetBuffer(sPar.GetLength()), _T("%d %d"), &site, &feedIdx) == 2) {
			pFrame->PostMessage(UWM_OPEN_FEEDITEM, site, (LPARAM) feedIdx);
		}
		sPar.ReleaseBuffer();
	}

	return TRUE;
}