Embedded Browser Using Pure C++

This embedded browser called IWEbBrowser2 uses Internet Explorer core embedded into a window like WebView in MFC or WebBrowser in .NET using interfaces IOleClientSiteIOleInPlaceSite, and IStorage.

Here’s the code for the WebBrowser Class header:

#include <comdef.h>
#include <Exdisp.h>
#include <string>
#include <tchar.h>
#include <Windows.h>

using namespace std;

class WebBrowser :
    public IOleClientSite,
    public IOleInPlaceSite,
    public IStorage
{

public:

    WebBrowser(HWND hWndParent);

    bool CreateBrowser();

    RECT PixelToHiMetric(const RECT& _rc);

    virtual void SetRect(const RECT& _rc);

    // ----- Control methods -----

    void GoBack();

    void GoForward();

    void Refresh();
    
    void Navigate(wstring szUrl);

    // ----- IUnknown -----

    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
        void**ppvObject) override;

    virtual ULONG STDMETHODCALLTYPE AddRef(void);

    virtual ULONG STDMETHODCALLTYPE Release(void);

    // ---------- IOleWindow ----------

    virtual HRESULT STDMETHODCALLTYPE GetWindow( 
        __RPC__deref_out_opt HWND *phwnd) override;

    virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp( 
        BOOL fEnterMode) override;

    // ---------- IOleInPlaceSite ----------

    virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate( void) override;

    virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate( void) override;

    virtual HRESULT STDMETHODCALLTYPE OnUIActivate( void) override;

    virtual HRESULT STDMETHODCALLTYPE GetWindowContext( 
        __RPC__deref_out_opt IOleInPlaceFrame **ppFrame,
        __RPC__deref_out_opt IOleInPlaceUIWindow **ppDoc,
        __RPC__out LPRECT lprcPosRect,
        __RPC__out LPRECT lprcClipRect,
        __RPC__inout LPOLEINPLACEFRAMEINFO lpFrameInfo) override;

    virtual HRESULT STDMETHODCALLTYPE Scroll( 
        SIZE scrollExtant) override;

    virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate( 
        BOOL fUndoable) override;

    virtual HWND GetControlWindow();

    virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate( void) override;

    virtual HRESULT STDMETHODCALLTYPE DiscardUndoState( void) override;

    virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo( void) override;

    virtual HRESULT STDMETHODCALLTYPE OnPosRectChange( 
        __RPC__in LPCRECT lprcPosRect) override;

    // ---------- IOleClientSite ----------

    virtual HRESULT STDMETHODCALLTYPE SaveObject( void) override;

    virtual HRESULT STDMETHODCALLTYPE GetMoniker( 
        DWORD dwAssign,
        DWORD dwWhichMoniker,
        __RPC__deref_out_opt IMoniker **ppmk) override;

    virtual HRESULT STDMETHODCALLTYPE GetContainer( 
        __RPC__deref_out_opt IOleContainer **ppContainer) override;

    virtual HRESULT STDMETHODCALLTYPE ShowObject( void) override;
    virtual HRESULT STDMETHODCALLTYPE OnShowWindow( 
        BOOL fShow) override;

    virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout( void) override;

    // ----- IStorage -----

    virtual HRESULT STDMETHODCALLTYPE CreateStream( 
        __RPC__in_string const OLECHAR *pwcsName,
        DWORD grfMode,
        DWORD reserved1,
        DWORD reserved2,
        __RPC__deref_out_opt IStream **ppstm) override;

    virtual HRESULT STDMETHODCALLTYPE OpenStream( 
        const OLECHAR *pwcsName,
        void *reserved1,
        DWORD grfMode,
        DWORD reserved2,
        IStream **ppstm) override;

    virtual HRESULT STDMETHODCALLTYPE CreateStorage( 
        __RPC__in_string const OLECHAR *pwcsName,
        DWORD grfMode,
        DWORD reserved1,
        DWORD reserved2,
        __RPC__deref_out_opt IStorage **ppstg) override;

    virtual HRESULT STDMETHODCALLTYPE OpenStorage( 
        __RPC__in_opt_string const OLECHAR *pwcsName,
        __RPC__in_opt IStorage *pstgPriority,
        DWORD grfMode,
        __RPC__deref_opt_in_opt SNB snbExclude,
        DWORD reserved,
        __RPC__deref_out_opt IStorage **ppstg) override;

    virtual HRESULT STDMETHODCALLTYPE CopyTo( 
        DWORD ciidExclude,
        const IID *rgiidExclude,
        __RPC__in_opt  SNB snbExclude,
        IStorage *pstgDest) override;

    virtual HRESULT STDMETHODCALLTYPE MoveElementTo( 
        __RPC__in_string const OLECHAR *pwcsName,
        __RPC__in_opt IStorage *pstgDest,
        __RPC__in_string const OLECHAR *pwcsNewName,
        DWORD grfFlags) override;

    virtual HRESULT STDMETHODCALLTYPE Commit( 
        DWORD grfCommitFlags) override;

    virtual HRESULT STDMETHODCALLTYPE Revert( void) override;

    virtual HRESULT STDMETHODCALLTYPE EnumElements( 
        DWORD reserved1,
        void *reserved2,
        DWORD reserved3,
        IEnumSTATSTG **ppenum) override;

    virtual HRESULT STDMETHODCALLTYPE DestroyElement( 
        __RPC__in_string const OLECHAR *pwcsName) override;

    virtual HRESULT STDMETHODCALLTYPE RenameElement( 
        __RPC__in_string const OLECHAR *pwcsOldName,
        __RPC__in_string const OLECHAR *pwcsNewName) override;

    virtual HRESULT STDMETHODCALLTYPE SetElementTimes( 
        __RPC__in_opt_string const OLECHAR *pwcsName,
        __RPC__in_opt const FILETIME *pctime,
        __RPC__in_opt const FILETIME *patime,
        __RPC__in_opt const FILETIME *pmtime) override;

    virtual HRESULT STDMETHODCALLTYPE SetClass( 
        __RPC__in REFCLSID clsid) override;
    virtual HRESULT STDMETHODCALLTYPE SetStateBits( 
        DWORD grfStateBits,
        DWORD grfMask) override;

    virtual HRESULT STDMETHODCALLTYPE Stat( 
        __RPC__out STATSTG *pstatstg,
        DWORD grfStatFlag) override;

protected:

    IOleObject* oleObject;
    IOleInPlaceObject* oleInPlaceObject;

    IWebBrowser2* webBrowser2;

    LONG iComRefCount;

    RECT rObject;

    HWND hWndParent;
    HWND hWndControl;

};

View the rest of the code here: http://www.codeproject.com/Tips/800585/Embedded-WebBrowser-IWebBrowser-in-Pure-Cplusplus

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

.NET Chart Solutions Vs Web Applications: Which Is Better?

Long years have passed releasing ASP.NET, the community comes up with several solutions for data virtualization for any taste and budge. They all work differently,  have no interoperable interfaces, uses different architecture, etc. This article will try to collect all available solutions in one place, compare their performance, and provide summary and supply with the best usage examples. The article will also introduce a quick guide to explain the technical implementation of test applications.

Here is the list of chart solutions that were included to the overview:

Read the rest of the post here: http://www.codeproject.com/Articles/794412/Comparing-NET-chart-solutions-for-web-applications

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

XBox Controller Controlled Rocket Launcher

Bruno Capuano have done many things with the Xbox One controller, and this time he is extending his pas work done with the USB Rocket Launcher.

This solution includes three projects: 1 is responsible for controlling the rocket launcher, then the app WPF to coordinate signals of the remote control and the Lance missiles. Then the PCL that is responsible for translating Int32 values from the command.

 

Doing this is not complicated at all. The only thing to keep in mind is the values that sends the controller. After seeing that the gamepad moves in the range of Int32, the only thing left to do is define the values for it.

Read the rest of the post here: http://channel9.msdn.com/coding4fun/blog/USB-Rocket-Launcher-and-Xbox-One-Controller

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Extend ASP.NET Identity 2.0 Roles and Implementation of Role Based Authorization

If you didn’t know, ASP.NET Identity 2.0 does not work with the same code as they have done for Identity 1.0.  This article will implement a simple role-based authorization with ASP.NET MVC 5 and Identity 2.0.

First, lets create the project.

  1. Go to File > New Project
  2. Select Web then ASP.NET Web APplication
  3. Name the project to: ASP.NETMVCExtendingIdentity2Roles
  4. Click OK, then select MVC as the template.
  5. Click OK.

Now that you are done with project creation, download the file available in this article. Once you have the files, if you looked at the codes, you’ll notice that there are so many files and folders. If there are build errors, you know what to do.

Read the rest of the post here: http://www.codeproject.com/Articles/799571/ASP-NET-MVC-Extending-ASP-NET-Identity-Roles

 

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

SPA Using Knockout JS, Web API and ASP.NET MVC4

A single page application or SPA is a web app or website that uses only one page to offer a more fluid user experience like a desktop application. What is great about SPA is that it reduces the traffic to the service since it reduces round trips to the server.

Knockout, on the other hand, is a JavaScript library to aid in developing SPA and has the facility of declarative data binding to isolate the Data Model. Knockout also uses Observer pattern to update the View automatically when the Model state has changed and vice versa.

Read the rest of the post here: http://www.codeproject.com/Articles/798713/Single-Page-Application-using-Knockout-JS-and-ASP

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Format Date in MySQL with DATE_FORMAT()

MySQL support datetime values into different formats using the DATE_FORMAT() function. This function accepts date or datetime values as a first parameter and returns to a specific format defined in the second parameter.

Define a DATETIME variable
SET @date:='2014-06-16 14:12:49';

-- Display datetime values in YYYY-mm-dd format
SELECT date_format(@date,'%Y-%m-%d'AS formatted_date;

This would return: Monday, June 16, 2014

— Display datetime values in Month Year format
SELECT date_format(@date,‘%M %Y’)  AS formatted_date;

This would return June 2014.

— Display datetime values in HH:MM:SS format
SELECT date_format(@date,‘%T’AS formatted_date;

This would return 14:12:49.

-- Display datetime values as Full date format
SELECT date_format(@date,'%W, %M %d,%Y %T'ASformatted_date;

This would return Monday, June 16,2014 14:12:49

 

Read the rest of the post here: http://blog.sqlauthority.com/2014/07/19/mysql-how-to-format-date-in-mysql-with-date_format/

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Handle GridView.OnSorting() and Create a Sorting Expression using LinQ

GridView control from ASP.NET 2.0 like this one is widely used:

<asp:GridViewrunat="server"ID="gridPersons"AutoGenerateColumns="false"AllowSorting="true"OnSorting="gridPersons_Sorting"><Columns><asp:BoundFieldHeaderText="First name"DataField="FirstName"SortExpression="FirstName"/><asp:BoundFieldHeaderText="Last name"DataField="LastName"SortExpression="LastName"/></Columns></asp:GridView>
protected void gridPersons_Sorting(object sender, GridViewSortEventArgs e)
{
    string sortExpression = e.SortExpression;
}


 

However, it has one limitation: the sorting event argument GridViewSortEventArg is based on string values from markup, which means it cannot be used in programmatic sorting using LINQ.  This article will describe how to convert a string argument to a sorting expression to be used in LINQ.

Read the rest of the tutorial here: http://www.codeproject.com/Articles/246361/Handle-GridView-OnSorting-using-LINQ

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

ASP.NET MVC5: Extending and Modifying Roles

In the recent article about extending ASP.NET 5 identity model, the author add some custom properties to the basic IdentityUser class, and some basic role-based identity management. However, the author did not discuss modifying, extending, or working directly with Roles beyond seeding the database with basic roles with which to manage application access.

There are two reasons to extend the basic ASP.NET IdentityRole class and working directly with roles from an administrative perspective:

ASP.NET Identity User is fairly easy to extend.

When roles are used to enforce access restrictions, they are basically hard-coded; therefore, it gives the administrators the ability to add, modify, and delete roles.

Read the rest of the post here: http://www.codeproject.com/Articles/727054/ASP-NET-MVC-Identity-Extending-and-Modifying-R

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Use Encrypted Files Without Decrypting to Disk

When a file is encrypted, the only way to access it is to decrypt it first using an application to pull from the decrypted file. Assuming that encryption was used in the first place to maintain security or limit access to sensitive information, decrypting it first before accessing it defeats the purpose of encryption in the first place. Even if the decrypted data is automatically deleted after being played, remnants of it are still existent in the disk and could be recovered.

A better solution is to have the application decrypt the file in memory leaving no trace of the encrypted data.

Read the rest of the guide here: http://www.codeproject.com/Articles/796587/Using-Encrypted-Files-Without-Decrypting-To-Disk

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Overview of OWIN and Katana

OWIN is becoming popular and common. ASP.NET Developers will love OWIN and Katana as they fit into the whole wide web development.

OWIN stands for Open Web Interface for .NET. OWIN speficifically describes how a web development framework such as ASP.NET MVC should interact with web servers. Its goal is to decouple web applications from the web servers that support OWIN.

Katana is a set of components Microsoft built using OWIN specifications. Some of these components include ASP.NET Identity, SignalR, and Web API.

In this post, codeguru.com shows you how to use OWIN and Katana by developing a simple application.

Read the rest of the post here: http://www.codeguru.com/csharp/.net/net_asp/overview-of-owin-and-katana.htm

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS