Share via


Add Functionality to the Hook Procedure to Handle Any Messages (Compact 2013)

3/26/2014

You can extend your XAML for Windows Embedded application launcher by customizing the hook procedure to monitor and process specific window messages before they reach the default WndProc for the sample home screen (XRShell.exe).

Then, you can design an application to send a system-wide window message to XRShell.exe.

Before you customize the hook procedure in the sample home screen, backup the source code files by using a source code control system.

Prerequisites

You must have an OS design that includes an application launcher to complete the following procedures. For more information, see Create and Prepare the OS Design and Application Launcher Project.

To send a specific window message to the application launcher

  1. In Platform Builder, open your application subproject.

  2. Open a source code file in your application. For example, open MainPage.cpp.

  3. Add code that posts a window message to the message queue for the sample home screen.

    For example, add the following lines of code to an event handler in your application:

    HWND hwndDesktop = NULL;
    hwndDesktop = GetDesktopWindow(); 
    PostMessage(hwndDesktop, WM_SETTINGCHANGE, NULL, (LPARAM)L"User Data");
    
  4. Rebuild your application.

To customize the hook procedure to process a specific window message

  1. In Solution Explorer, browse to <OS Design Name>\C:/WINCE800\Public\Shell\Oak\XRShell\Src\Source files and double-click CXRShell.cpp.

  2. In CXRShell.cpp, browse to the CXRShell::MessageHook hook procedure.

  3. Add code to the CXRShell:MessageHook method implementation that processes a specific window message. For example, after the bRet variable is initialized, add a switch statement that processes additional window messages before they are routed to the default WndProc. For example:

    switch (Message)
         {
           case WM_SETTINGCHANGE:
                   // Add code to process parameters in window message
                   bRet = TRUE;
                   break;
         }
    
  4. Recompile and build the XRShell source code.

To recompile and build XRShell

  1. In Solution Explorer, browse to <OS Design Name>\C:/WINCE800\Public\Shell\Oak\XRShell\Src, right-click Src, and click Rebuild.

  2. In the Output window, verify that the build succeeded by looking for the following output message:

    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
    
  3. In Solution Explorer, browse to <OS Design Name>\C:/WINCE800\Public\Shell, right-click Shell, and click Build and Sysgen.

  4. Create an updated run-time image with the updated XRShell.exe file.

To create an updated run-time image

  1. In Platform Builder, on the Build menu, click Copy Files to Release Directory.

  2. On the Build menu, click Make Run-Time Image.

  3. In the Output window, verify that the build succeeded.

  4. In the Device drop-down menu, select the name of the Virtual CEPC device that you already configured.

  5. Start the virtual CEPC that you have preconfigured and connected to Platform Builder, as described in Use the Sample Virtual Device. For example, to start Virtual CEPC on a Windows 7 computer:

    1. On the Start menu, point to All Programs, point to Windows Virtual PC, and then click Windows Virtual PC.
    2. Double-click the virtual CEPC you have preconfigured.
    3. On the Target menu, click Attach Device.
  6. Start the application that sends the window message to the application launcher. On the Target menu, click Run Programs, click the application name, and then click Run.

Next Steps

After you complete your customizations, you can use the procedures in Build and Run the Application Launcher to rebuild the theme DLL by using the Command Prompt window in Visual Studio before you rebuild your run-time image.

See Also

Concepts

Create an Application Launcher in XAML for Windows Embedded