• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Complete WinLIFT API encapsulation for C++

Started by Patrice Terrier, August 04, 2010, 08:14:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

This is the complete encapsulation of the WinLIFT API for C++ Win32.

//+--------------------------------------------------------------------------+
//|                                                                          |
//|                                WinLIFT.h                                 |
//|                                                                          |
//|             WinLIFT simplified API constants and declarations.           |
//|                                                                          |
//|                               Version 4.85                               |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|                                                                          |
//|                         Author Patrice TERRIER                           |
//|            8 Domaine de Rochagnon. 38800 Champagnier  FRANCE             |
//|                       http://www.zapsolution.com                         |
//|                    E-mail: pterrier@zapsolution.com                      |
//|                                                                          |
//|                   copyright (c) 2010 Patrice TERRIER                     |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|          C++ translation started on : 08-03-2010                         |
//|                        Last revised : 08-06-2010                         |
//+--------------------------------------------------------------------------+

#include <windows.h>
//
#include <iostream>
#include <string.h>

// Macro definitions.
#define int_proc typedef int (__stdcall *zProc)
#define string_proc typedef char* (__stdcall *zProc)
#define void_proc typedef void (__stdcall *zProc)
#define hwnd_proc typedef HWND (__stdcall *zProc)

// Constants.
#define WM_SKGETMENUICON (WM_USER + WM_GETICON)
// Anchor constants
#define ANCHOR_NONE                0
#define ANCHOR_LEFT                ANCHOR_NONE
#define ANCHOR_WIDTH               1
#define ANCHOR_RIGHT               2
#define ANCHOR_CENTER_HORZ         3
#define ANCHOR_HEIGHT              4
#define ANCHOR_HEIGHT_WIDTH        5
#define ANCHOR_HEIGHT_RIGHT        6
#define ANCHOR_BOTTOM              7
#define ANCHOR_BOTTOM_WIDTH        8
#define ANCHOR_BOTTOM_RIGHT        9
#define ANCHOR_CENTER_HORZ_BOTTOM  10
#define ANCHOR_CENTER_VERT         11
#define ANCHOR_CENTER_VERT_RIGHT   12
#define ANCHOR_CENTER              13
//
#define SK_DWM_LEFT                27
#define SK_DWM_TOP                 28
#define SK_DWM_RIGHT               29
#define SK_DWM_BOTTOM              30
//
#define FontStyleRegular           0
#define FontStyleBold              1
#define FontStyleItalic            2
#define FontStyleBoldItalic        3
#define FontStyleUnderline         4
#define FontStyleStrikeout         8
// Use this value in the optional GMToffset parameter to disable local timer in case of animated background.
#define DISABLE_TIMER              99

// Global.
HMODULE g_WinLIFT_DLL;

// Load the WinLIFT DLL.
int LoadDLL_WinLIFT() {
   static int nRet;
   if (nRet == 0) {
      g_WinLIFT_DLL = LoadLibraryA ("WinLIFT");
      if (g_WinLIFT_DLL != 0) { nRet = -1; }
   }
   return nRet;
}

// Init the WinLIFT SkinEngine.
// This function must be the first WinLIFT call.
int skInitEngine(
   std::string skinfile,       // Full path to the Skin theme.
   std::string suserkey        // Private user key to unlock the DLL.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL == 0) { LoadDLL_WinLIFT(); }

   if (g_WinLIFT_DLL) {
       int_proc (char*, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skInitEngine");
       if (hPROC) {
           nRet = hPROC((char*) skinfile.c_str(), (char*) suserkey.c_str());
       }
       else {
           FreeLibrary(g_WinLIFT_DLL);
       }
   }
   return nRet;
}

// The main function to skin a window.
int skSkinWindow(
   HWND hWnd,                  // Handle of the poup window to apply the skin theme.
   std::string sbuttontip      // string to build the system button tooltips.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (HWND, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSkinWindow");
       if (hPROC) {
           nRet = hPROC(hWnd, (char*) sbuttontip.c_str());
       }
   }
   return nRet;
}

// Disable skinning of a specific control.
int skSkinDisable(
   HWND hCtrl                  // The control handle.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSkinDisable");
       if (hPROC) {
           nRet = hPROC(hCtrl);
       }
   }
   return nRet;
}

// Enable skinning of a specific control (use it only after a previous call to skSkinDisable).
int skSkinEnable(
   HWND hCtrl                  // The control handle.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSkinEnable");
       if (hPROC) {
           nRet = hPROC(hCtrl);
       }
   }
   return nRet;
}

// Return the "Skin" author name and copyright.
string skAuthor (
   ) {

   std::string sText;

   if (g_WinLIFT_DLL) {
       string_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skAuthor");
       if (hPROC) {
           sText = hPROC();
       }
   }
   return sText;
}

// Return the internal version number.
string skVersion (
   ) {

   std::string sText;

   if (g_WinLIFT_DLL) {
       string_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skVersion");
       if (hPROC) {
           sText = hPROC();
       }
   }
 return sText;
}

// Return the skin folder full path, completed with a trailing back slash.
string skSkinFolder (
   ) {

   std::string sText;

   if (g_WinLIFT_DLL) {
       string_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSkinFolder");
       if (hPROC) {
           sText = hPROC();
       }
   }
   return sText;
}

// Anchor child controls.
int skSetAnchorCtrl(
   HWND hCtrl,                 // Handle of the control to anchor.
   int AnchorMode              // Anchor constant.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (HWND, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSetAnchorCtrl");
       if (hPROC) {
           nRet = hPROC(hCtrl, AnchorMode);
       }
   }
   return nRet;
}

// Animated clock control.
HWND skClockCtrl (
   HWND hOwner,                // Handle of the window parent owner.
   std::string sImageFile,     // Full path name to the clock image background.
   int x,                      // X location of the clock control.
   int y,                      // Y location of the clock control.
   int w,                      // Width of the clock control.
   int h,                      // Height of the clock control.
   int ButID,                  // Unique ID of the clock control.
   int ARGB1,                  // The color to draw the Hour/Minute hands.
   int ARGB2,                  // The color to draw the second hands.
   int GMToffset ) {           // The GMT offset to be used.

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       int_proc (__in HWND, char*, int, int, int, int, int, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skClockCtrl");
       if (hPROC) {
           hCtrl = (HWND) hPROC(hOwner, (char*) sImageFile.c_str(), x, y, w, h, ButID, ARGB1, ARGB2, GMToffset);
       }
   }
   return hCtrl;    
}

// Create Tooltip.
HWND skCreateToolTip (
   HWND hCtrl,                      // Handle of the child control.
   std::string sText) {             // The text to display.

   HWND hTooltip = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skCreateToolTip");
       if (hPROC) {
           hCtrl = hPROC(hCtrl, (char*) sText.c_str());
       }
   }
   return hCtrl;
}

// Assign new tooltip text to control.
void skSetToolTipText (
   HWND hCtrl,                      // Handle of the child control.
   std::string sText) {             // The new text to display.

   if (g_WinLIFT_DLL) {
       void_proc (HWND, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSetToolTip");
       if (hPROC) {
           hPROC(hCtrl, (char*) sText.c_str());
       }
   }
}

// Get the tooltip text of a specific control.
string skGetToolTipText (
   HWND hCtrl) {                    // Handle of the child control.

   std::string sText;

   if (g_WinLIFT_DLL) {
       string_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGetToolTipText");
       if (hPROC) {
           sText = hPROC(hCtrl);
       }
   }
   return sText;
}

// Create a knob control.
HWND skKnobGauge (
   HWND hOwner,                     // Handle of the window parent owner.
   std::string sImageFile,          // Full path name to the gauge image.
   int x,                           // X location of the gauge control.
   int y,                           // Y location of the gauge control.
   int w,                           // Width of the gauge control.
   int h,                           // Height of the gauge control.
   int ButID,                       // Unique ID of the gauge control.
   int MinValue,                    // MAXIMUM range value (the exclusion zone is between the MINIMUM and MAXIMUM range).
   int MaxValue,                    // MAXIMUM range value (the exclusion zone is between the MINIMUM and MAXIMUM range).
   int UsePos,                      // 0 or initial angle value in degree to use.
   int Reserved                     // Must be NULL.
   ) {

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND, char*, int, int, int, int, int, int, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skKnobGauge");
       if (hPROC) {
           hCtrl = hPROC(hOwner, (char*) sImageFile.c_str(), x, y, w, h, ButID, MinValue, MaxValue, UsePos, Reserved);
       }
   }
   return hCtrl;    
}

// Assign the Min/Max gauge value.
void skGaugeSetMinMax (
   HWND hCtrl,                      // The control handle.
   int nMin,                        // Minimum value (for knob this must be a rotation angle in the range 0-359).
   int nMax                         // Maximum value (for knob this must be a rotation angle in the range 0-359).
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND, LONG, LONG);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGaugeSetMinMax");
       if (hPROC) {
           hPROC(hCtrl, nMin, nMax);
       }
   }
}

// Retrieve the Min/Max gauge value (passage by reference).
void skGaugeGetMinMax (
   HWND hCtrl,                      // The control handle.
   int &nMin,                       // Minimum value (for knob this is a rotation angle in the range 0-359).
   int &nMax                        // Maximum value (for knob this is a rotation angle in the range 0-359).
   ) {

   nMin = 0, nMax = 0;
   if (g_WinLIFT_DLL) {
       void_proc (HWND, int*, int*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGaugeGetMinMax");
       if (hPROC) {
           hPROC(hCtrl, &nMin, &nMax); // Passage by reference.
       }
   }
}

// Set the gauge value.
void skGaugeSetPos (
   HWND hCtrl,                      // The control handle.
   int nPos,                        // The pos value to set (must be an angle in the range 0-359 for Knob control).
   int RedrawFlag                   // Redraw boolean flag.
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGaugeSetPos");
       if (hPROC) {
           hPROC(hCtrl, nPos, RedrawFlag);
       }
   }
}

// Get the gauge value.
int skGaugeGetPos (
   HWND hCtrl                       // The control handle.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGaugeGetPos");
       if (hPROC) {
           nRet = hPROC(hCtrl);
       }
   }
   return nRet;
}

// Create a button from a 5-state image.
HWND skButtonImage (
   HWND hOwner,            // Handle of the window parent owner.
   std::string sImageFile, // Full path name to the button image.
   int x,                  // X location of the button.
   int y,                  // Y location of the button.
   int ButID,              // Unique ID of the button.
   int StateMax            // Number of state of the button image.
   ) {

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND, char*, int, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skButtonImage");
       if (hPROC) {
           hCtrl = hPROC(hOwner, (char*) sImageFile.c_str(), x, y, ButID, StateMax);
       }
   }
   return hCtrl;    
}

// Draw a frame border.
HWND skBorder (
   HWND hOwner,            // Handle of the child control.
   int x,                  // X location of the border.
   int y,                  // Y location of the border.
   int w,                  // Width of the border.
   int h,                  // Height of the border.
   int BorderID,           // Unique ID of the border control.
   int UseBorderSize       // Size of the border.
   ) {

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND, int, int, int, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skBorder");
       if (hPROC) {
           hCtrl = hPROC(hOwner, x, y, w, h, BorderID, UseBorderSize);
       }
   }
   return hCtrl;    
}

// Create a themed button using an icon and a label.
HWND skPushButtonImage (
   HWND hOwner,            // Handle of the window parent owner.
   std::string sImageFile, // Full path name to the icon-image shown on the themed button.
   std::string sLabel,     // The text label of the button.
   int x,                  // X location of the button.
   int y,                  // Y location of the button.
   int w,                  // Width of the button.
   int h,                  // Height of the button.
   int UseID,              // Unique ID of the button.
   int nAlignment          // Button style alignment (BS_LEFT, BS_RIGHT, BS_CENTER, BS_TOP, BS_BOTTOM).
   ) {

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND, char*, char*, int, int, int, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skPushButtonImage");
       if (hPROC) {
           hCtrl = hPROC(hOwner, (char*) sImageFile.c_str(), (char*) sLabel.c_str(), x, y, w, h, UseID, nAlignment);
       }
   }
   return hCtrl;    
}

// Paint a static image anywhere hover the skinned window, and under all other child controls.
HWND skStaticImage (
   HWND hOwner,            // Handle of the window parent owner.
   std::string sImageFile, // Full path name to the static image.
   int x,                  // X location of the static image control.
   int y,                  // Y location of the static image control.
   int w,                  // Width of the static image control.
   int h,                  // Height of the static image control.
   int UseID               // Unique ID of the static image control.
   ) {

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND, char*, int, int, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skStaticImage");
       if (hPROC) {
           hCtrl = hPROC(hOwner, (char*) sImageFile.c_str(), x, y, w, h, UseID);
       }
   }
   return hCtrl;    
}

// Create a full ARGB color (with alpha channel).
int skARGB (
   BYTE A,             // Alpha channel in the range 0-255 (0 full transparency, 255 full opaque mode).
   BYTE R,             // Red channel in the range 0-255.
   BYTE G,             // Green channel in the range 0-255.
   BYTE B              // Blue channel in the range 0-255.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (BYTE, BYTE, BYTE, BYTE);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skARGB");
       if (hPROC) {
           nRet = hPROC(A, R, G, B);
       }
   }
   return nRet;
}

//****************************************************************************
//*                THESE MUST BE USED WITH WINLIFT's MENU                    *
//****************************************************************************
// Replace the standard DrawMenuBar API, must be used with WinLIFT's menu.
void skRedrawMenuBar (
   HWND hWinliftMenu        // The WinLIFT menu handle.
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skRedrawMenuBar");
       if (hPROC) {
           hPROC(hWinliftMenu);
       }
   }
}

// Note: WinLIFT's menu are not standard menu, thus do not use the standard API GetMenu
// to retrieve a menu handle but the specific skGetMenu below.
// Instead of using skGetMenu you can also save the menu handle in a global variable and then
// use this global variable in lieu of the GetMenu API.
HWND skGetMenu (
   HWND hWinliftMenu       // The internal WinLIFT menu handle.
   ) {                     // RETURN: the Windows menu handle.

   HWND hWindowsMenu = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGetMenu");
       if (hPROC) {
           hWindowsMenu = hPROC(hWinliftMenu);
       }
   }
   return hWindowsMenu;
}

// Retrieve the handle of the WinLIFT's menu container
HWND skMenuContainer (
   HWND hWnd               // The parent popup window handle.
   ) {

   HWND hMenuContainer = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skMenuContainer");
       if (hPROC) {
           hMenuContainer = hPROC(hWnd);
       }
   }
   return hMenuContainer;
}
//****************************************************************************
//*                           END OF SKINNED MENU                            *
//****************************************************************************

HWND skCreateDW (
   HWND hParent                // The parent popup window handle.
   ) {

   HWND hCtrl = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skCreateDW");
       if (hPROC) {
           hCtrl = hPROC(hParent);
       }
   }
   return hCtrl;
}

void skDestroyDW (
   HWND &hDW                   // Handle of the DW window.
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skDestroyDW");
       if (hPROC) {
           hPROC(&hDW);
       }
   }
}

void skDialogAlert (
   std::string sCaption,       // Text of the caption.
   std::string sMessage,       // Text of the message.
   std::string sButton         // Text of the button (will be "Ok" if empty).
   ) {                         // RETURN: nothing.

   if (g_WinLIFT_DLL) {
       void_proc (char*, char*, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skDialogAlert");
       if (hPROC) {
           hPROC((char*) sCaption.c_str(), (char*) sMessage.c_str(), (char*) sButton.c_str());
       }
   }
}

void skDialogError (
   std::string sCaption,       // Text of the caption.
   std::string sMessage,       // Text of the message.
   std::string sButton         // Text of the button (will be "Ok" if empty).
   ) {                         // RETURN: nothing.

   if (g_WinLIFT_DLL) {
       void_proc (char*, char*, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skDialogError");
       if (hPROC) {
           hPROC((char*) sCaption.c_str(), (char*) sMessage.c_str(), (char*) sButton.c_str());
       }
   }
}

void skDialogInfo (
   std::string sCaption,       // Text of the caption.
   std::string sMessage,       // Text of the message.
   std::string sButton         // Text of the button (will be "Ok" if empty).
   ) {                         // RETURN: nothing.

   if (g_WinLIFT_DLL) {
       void_proc (char*, char*, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skDialogInfo");
       if (hPROC) {
           hPROC((char*) sCaption.c_str(), (char*) sMessage.c_str(), (char*) sButton.c_str());
       }
   }
}

int skDialogYesNo (
   std::string sCaption,       // Text of the caption.
   std::string sMessage,       // Text of the message.
   std::string sButton         // "@Yes|No", the "@" char means put the focus on this button.
   ) {                         // RETURN: TRUE for Yes, FALSE for No.
   
   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (char*, char*, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skDialogYesNo");
       if (hPROC) {
           nRet = hPROC((char*) sCaption.c_str(), (char*) sMessage.c_str(), (char*) sButton.c_str());
       }
   }
   return nRet;
}

string skDialogInput (
   std::string sCaption,       // Text of the caption.
   std::string sMessage,       // Text of the input message.
   std::string sButton         // Text of the button (will be "Ok" if empty).
   ) {                         // RETURN: the text entered by the user.

   std::string sText;

   if (g_WinLIFT_DLL) {
       string_proc (char*, char*, char*);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skDialogInput");
       if (hPROC) {
           sText = hPROC((char*) sCaption.c_str(), (char*) sMessage.c_str(), (char*) sButton.c_str());
       }
   }
   return sText;
}

// Return the theme caption font handle.
int skCaptionFont (
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skCaptionFont");
       if (hPROC) {
           nRet = hPROC();
       }
   }
   return nRet;
}

// Return the theme standard font handle.
int skFont (
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skFont");
       if (hPROC) {
           nRet = hPROC();
       }
   }
   return nRet;
}

// return the theme bold font handle.
int skFontBold (
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skFontBold");
       if (hPROC) {
           nRet = hPROC();
       }
   }
   return nRet;
}

// Return the theme font handle being used in popup dialog.
int skFontDlg (
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skFontDlg");
       if (hPROC) {
           nRet = hPROC();
       }
   }
   return nRet;
}

// To skin a child control on the fly, must be used AFTER the initial call to skInitEngine.
void skSkinChildCtrl (
   HWND hCtrl,                 // The handle of the child control.
   int RedrawFlag              // Redraw boolean flag.
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSkinChildCtrl");
       if (hPROC) {
           hPROC(hCtrl, RedrawFlag);
       }
   }
}

// Use this when new controls are added AFTER the initial skinning of the main window.
void skSkinWindowUpdate (
   HWND hWnd,                  // The main window handle.
   int RedrawFlag              // Redraw boolean flag.
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSkinWindowUpdate");
       if (hPROC) {
           hPROC(hWnd, RedrawFlag);
       }
   }
}

// This API is to be used only with STATIC and BUTTON controls exclusively!
void skSetLabelFont (
   HWND hCtrl,                 // The control handle.
   string sFontName,           // The GDI+ compatible font name to use.
   unsigned short nSize,       // The font size in pixel.
   int ARGBcolor,              // The ARGB color (use the skARGB() function above, or NULL to apply the skin theme color).
   unsigned short nStyle       // One of the FontStyle constant above.      
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND, char*, WORD, int, WORD);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSetLabelFont");
       if (hPROC) {
           hPROC(hCtrl, (char*) sFontName.c_str(), nSize, ARGBcolor, nStyle);
       }
   }
}

void skSetZorder (
   HWND hCtrl,                 // Handle of the child control.
   int UseOrder                // HWND constant or another child control handle.
   ) {

   if (g_WinLIFT_DLL) {
       void_proc (HWND, int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skSetZorder");
       if (hPROC) {
           hPROC(hCtrl, UseOrder);
       }
   }
}

int skGetSystemMetrics (
   int nMeasure                // The measure to retrieve.
   ) {

   int nRet = 0;

   if (g_WinLIFT_DLL) {
       int_proc (int);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGetSystemMetrics");
       if (hPROC) {
           nRet = hPROC(nMeasure);
       }
   }
   return nRet;
}

HWND skGetDWMregion (
   HWND hOwner                 // Handle of the window parent owner.
   ) {

   HWND hRgn = 0;

   if (g_WinLIFT_DLL) {
       hwnd_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_WinLIFT_DLL, "skGetDWMregion");
       if (hPROC) {
           hRgn = hPROC(hOwner);
       }
   }
   return hRgn;
}
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#1
And here is the C++ source code of the "HUD window" project.

I put many effort to keep it as close as my PB's SDK coding style, to ease the translation between the two languages.

//+--------------------------------------------------------------------------+
//|                                                                          |
//|                                  HUD Plus                                |
//|                                                                          |
//|                HUD composited window for VISTA and SEVEN.                |
//|                    Based on direct use of the core API.                  |
//|                  Theme by WinLIFT and graphic by GDImage.                |
//|                                                                          |
//|                               Version 1.00Ab                             |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|                                                                          |
//|                         Author Patrice TERRIER                           |
//|            8 Domaine de Rochagnon. 38800 Champagnier  FRANCE             |
//|                       http://www.zapsolution.com                         |
//|                    E-mail: pterrier@zapsolution.com                      |
//|                                                                          |
//|                   copyright (c) 2010 Patrice TERRIER                     |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|                  Project started on : 04-18-2010                         |
//|                        Last revised : 08-08-2010                         |
//+--------------------------------------------------------------------------+

#include <windows.h>  // Search along the path.
#include <stdlib.h>   // Search along the path.
#include <tchar.h>    // Search along the path.
#include <stdio.h>    // Search along the path.

#include <iostream>   // Search along the path.
#include <string.h>   // Search along the path.
using namespace std;

#include "zTrace.h"   // Search in the same directory of the current file.
#include "WinLIFT.h"  // Search in the same directory of the current file.
#include "GDImage.h"

#define NM_FIRST            0
#define NM_AUDIOCOMPLETION  NM_FIRST - 80
#define NM_MOVIEPLAYING     NM_FIRST - 81

#define TBS_AUTOTICKS       0x0001
#define TBS_VERT            0x0002
#define TBS_BOTTOM          0x0000
#define TBM_GETPOS          WM_USER
#define TBM_SETPOS          WM_USER + 5
#define TBM_SETRANGE        WM_USER + 6
#define TBM_SETTICFREQ      WM_USER + 20
#define TBM_SETPAGESIZE     WM_USER + 21
#define TBM_SETLINESIZE     WM_USER + 23

#define MyWindowWidth       1000 //800
#define MyWindowHeight      614


#define IDC_STATIC          -101
#define IDC_MAIN_GDIMAGE    1001
#define IDC_MAIN_SLIDEZOOM  1002
#define IDC_MAIN_CHECKBOX   1003
#define IDC_MAIN_CLOCK      1004
#define IDC_MAIN_KNOBLEFT   1005
#define IDC_MAIN_KNOBBIG    1006
#define IDC_MAIN_KNOBRIGHT  1007
#define IDC_MAIN_LOADIMAGE  1008
#define IDC_MAIN_STATICIMG  1009
#define IDC_MAIN_PLUGIN     1010
#define IDC_MAIN_WALLPAPER  1011

#define IDC_CB_PLUGIN       1012
#define IDC_CB_AUDIO        1013

// GDImage constant to identify each sprite image.
#define ID_PHOTO            1
#define ID_LOGO             2

// Global variables
HINSTANCE g_hInst;    // Current instance
HWND g_hImageCtrl, g_hMain;
string g_sAudioPath, g_sPluginPath;
int g_nFocusID, g_nTrueWidth, g_nTrueHeight, g_nUseWidth, g_nUseHeight;
float g_rWasZoom;
int WM_ZWPNOTIFICATION;

// Declaration of the functions being used in this module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
string  FullExeName();
string  ExePath();
void    ComboSelectPlus (HWND hCombo, int nSelected);
void    DetectAudio (HWND hCombo, int nUseItem);
void    DetectPlugin (HWND hCombo, int nUseItem);
int     ZWP_Message(string sMsg);
HWND    ZWP_Handle();
void    ZWP_Destroy();
void    ZWP_Play(string sAudio);
void    ZWP_SizeMove();
int     GetStaticValue(string sUseString);
void    SetStaticValue(string sUseString, int nValue);
void    ZWP_Stop();
void    ZWP_Hide();
void    ZWP_UsePlugin(string sPlugin);
void    ZWP_Show(string sAudio);
void    UseThisZoom(int nPos);
void    UseThisPhoto(string sUsePhoto, int bReset);

// Start of main.
int WINAPI wWinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR lpCmdLine,
                   int nCmdShow) {

   UNREFERENCED_PARAMETER(hPrevInstance);
   UNREFERENCED_PARAMETER(lpCmdLine);

   // Load WinLIFT.dll and GDImage.dll.
   if (LoadDLL_WinLIFT()) {
      if (LoadDLL_GDImage()) {
         // We must initialize GDImage using the private key
         ZI_LoadDLL(""); }
      else {
         //Error("Unable to start GDImage")
         return GetLastError();
      } }
   else {
      //Error("Unable to start WinLIFT")
      return GetLastError();
   }


   // Check if ZWP is already running.
   char zClass[] = "ZWALLPAPER"; HWND hZWP = FindWindowA(zClass, zClass);

   // Important: we use RegisterWindowMessage to communicate with ZWP's plugins.
   WM_ZWPNOTIFICATION = RegisterWindowMessageA("ZWPnotification");

   // Declaration of local variables
   MSG msg;
   int nRet = 0;
   int IsInitialized = 0;
   WNDCLASSEX wcx;
   TCHAR szWindowClass[] = _T("ZHUDPLUS");
   TCHAR szTitle[] = _T("HUD window");
   char szFullpathToFile[MAX_PATH];

   // Register the main window class
   wcx.cbSize = sizeof(wcx);
   IsInitialized = GetClassInfoEx(hInstance, szWindowClass, &wcx);
   if (!IsInitialized)
   {
      wcx.style         = CS_HREDRAW | CS_VREDRAW;
      wcx.lpfnWndProc   = WndProc;
      wcx.cbClsExtra    = 0;
      wcx.cbWndExtra    = 0;
      wcx.hInstance     = hInstance;
      wcx.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
      wcx.hCursor       = LoadCursor(NULL, IDC_ARROW);
      wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
      wcx.lpszMenuName  = NULL;
      wcx.lpszClassName = szWindowClass;
      wcx.hIconSm       = LoadIcon(wcx.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
      if (RegisterClassEx(&wcx))
      {
         IsInitialized = -1;
      }
   }

   if (IsInitialized) {

      g_hInst = hInstance; // Stocke le handle d'instance dans la variable globale

      int w = MyWindowWidth;
      int h = MyWindowHeight;
      int x = max((GetSystemMetrics(SM_CXSCREEN) - w) / 2, 0);
      int y = max((GetSystemMetrics(SM_CYSCREEN) - h) / 2, 0);

      DWORD dwStyle = WS_POPUP | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
                      WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // | WS_VISIBLE

      g_hMain    = CreateWindowEx(
                   0,                              // Optional window styles.
                   szWindowClass,                  // Window class
                   szTitle,                        // Window text
                   dwStyle,                        // Window style

                   // Size and position
                   x, -2000, w, h,

                   NULL,       // Parent window
                   NULL,       // Menu
                   hInstance,  // Instance handle
                   NULL        // Additional application data
                   );

      if (g_hMain) {

         g_hImageCtrl = CreateWindowExA(0, GDImageClassName, NULL,
                                        WS_CHILD | WS_VISIBLE,
                                        78, 40, 628 + 200, 432,
                                        g_hMain, (HMENU) IDC_MAIN_GDIMAGE,
                                        hInstance, NULL);

         HWND hCtrl   = CreateWindowExA(0, "MSCTLS_TRACKBAR32", NULL,
                                        WS_CHILD | WS_VISIBLE | WS_TABSTOP | TBS_VERT | TBS_BOTTOM | TBS_AUTOTICKS,
                                        728 + 200, 40, 32, 432,
                                        g_hMain, (HMENU) IDC_MAIN_SLIDEZOOM,
                                        hInstance, NULL);

         string sExePath = ExePath();
         string sResourcePath = sExePath;
         sResourcePath += "Resource\\";
         g_sAudioPath = sExePath, g_sAudioPath += "Audio\\";
         g_sPluginPath = sExePath, g_sPluginPath += "BBPlugin\\";

         string SkinTheme = ExePath();
         //SkinTheme += "Sony.sks";
         SkinTheme += "Naavi.sks";
         if (skInitEngine (SkinTheme, "")) {

            skSkinWindow(g_hMain, "Dock|Undock|Minimize|Maximize|Restore|Close");

            // Anchor the SLIDEZOOM trackbar
            skSetAnchorCtrl(hCtrl, ANCHOR_HEIGHT_RIGHT);

            hCtrl = CreateWindowExA(0, "BUTTON", "Transparent HUD mode",
                                    WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX,
                                    500 + 100, 542, 200, 16,
                                    g_hMain, (HMENU) IDC_MAIN_CHECKBOX,
                                    hInstance, NULL);
            skSkinChildCtrl(hCtrl, 0), skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);
            ZI_UseWinLIFTbackground(g_hImageCtrl, TRUE, FALSE);

            hCtrl = CreateWindowExA(0, "COMBOBOX", NULL,
                                    WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS,
                                    127, 542-49, 150, 164,
                                    g_hMain, (HMENU) IDC_CB_AUDIO,
                                    hInstance, NULL);
            DetectAudio(hCtrl, 1);
            skSkinChildCtrl(hCtrl, 0);
            skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);

            hCtrl = CreateWindowExA(0, "COMBOBOX", NULL,
                                    WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS,
                                    127, 542-24, 150, 164,
                                    g_hMain, (HMENU) IDC_CB_PLUGIN,
                                    hInstance, NULL);
            DetectPlugin(hCtrl, 1);
            skSkinChildCtrl(hCtrl, 0);
            skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);
            SendMessageA(hCtrl, CB_GETLBTEXT, SendMessageA(hCtrl, CB_GETCURSEL, 0, 0), (LPARAM) szFullpathToFile);

            string sRunProg = ExePath(); sRunProg += "ZWP.exe";
            char szRunProg[MAX_PATH]; strncpy_s(szRunProg, sRunProg.c_str(), sRunProg.size() ); sRunProg = "";
            string sPlaythis = g_sPluginPath; sPlaythis += szFullpathToFile;
            char szPlaythis[MAX_PATH]; strncpy_s(szPlaythis, sPlaythis.c_str(), sPlaythis.size() ); sPlaythis = "";
            char szExePath[MAX_PATH]; strncpy_s(szExePath, sExePath.c_str(), sExePath.size() );
            // Start the background plugin player.
            if (hZWP == 0) {
               ShellExecuteA(0, "open", szRunProg, szPlaythis, szExePath, SW_SHOWNOACTIVATE);
            }

            hCtrl = CreateWindowExA(0, "BUTTON", "Use visual plugin",
                                    WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX,
                                    127, 542, 150, 16,
                                    g_hMain, (HMENU) IDC_MAIN_PLUGIN,
                                    hInstance,
                                    NULL);
            skSkinChildCtrl(hCtrl, 0); skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);
            skCreateToolTip(hCtrl, "Enable/disable visual plugin");

            // Add a clock control.
            string sResource = sResourcePath;
            sResource += "Clock_09_92.png";
            hCtrl = skClockCtrl(g_hMain, sResource, 4, 476, 0, 0, IDC_MAIN_CLOCK, 0x7FCB0000, 0x7F8F8F8F, 0);
            skSetAnchorCtrl(hCtrl, ANCHOR_BOTTOM);          // Anchor control
            skCreateToolTip(hCtrl, "WinLIFT clock widget"); // Add tooltip.

            // Add a 5-state button image.
            sResource = sResourcePath;
            sResource += "SelectImage.png";
            hCtrl = skButtonImage(g_hMain, sResource, 780 - 58 + 200, 498, IDC_MAIN_LOADIMAGE, 5);
            skSetAnchorCtrl(hCtrl, ANCHOR_BOTTOM_RIGHT);
            skCreateToolTip(hCtrl, "WinLIFT ButtonImage");

            // Add two circular slider gauges.
            sResource = sResourcePath;
            sResource += "BTN_Gauge01.png";
            hCtrl = skKnobGauge(g_hMain, sResource, 303 + 100, 527, 0, 0, IDC_MAIN_KNOBLEFT, 0, 0, 0, 0);
            skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);
            skCreateToolTip(hCtrl, "WinLIFT KnobGauge");
            hCtrl = skKnobGauge(g_hMain, sResource, 436 + 100, 527, 0, 0, IDC_MAIN_KNOBRIGHT, 0, 0, 0, 0);
            skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);
            skCreateToolTip(hCtrl, "WinLIFT KnobGauge");

            // Add a circular slider gauge.
            sResource = sResourcePath;
            sResource += "BTN_Gauge02.png";
            hCtrl = skKnobGauge(g_hMain, sResource, 344 + 100, 476, 0, 0, IDC_MAIN_KNOBBIG, 0, 0, 0, 0);
            skSetAnchorCtrl(hCtrl, ANCHOR_CENTER_HORZ_BOTTOM);
            skCreateToolTip(hCtrl, "WinLIFT KnobGauge");

//             sResource = sResourcePath;
//             sResource += "Assistant.png";
//             hCtrl = skStaticImage (g_hMain, sResource, 580, 20, 185, 456, IDC_MAIN_STATICIMG);
//             skSetAnchorCtrl(hCtrl, ANCHOR_HEIGHT_RIGHT);

            if (g_hImageCtrl) {
               RECT lpw;
               POINT p;
               GetWindowRect(g_hImageCtrl, &lpw);
               p.x = lpw.left, p.y = lpw.top;
               ScreenToClient (g_hMain, &p);
               skBorder(g_hImageCtrl, p.x - 1, p.y - 1, lpw.right - lpw.left + 2, lpw.bottom - lpw.top + 2, 0, 1);
               // Anchor the GDImage control.
               skSetAnchorCtrl(g_hImageCtrl, ANCHOR_HEIGHT_WIDTH);

               // Compute the good range to use with the zoom slider.
               int imgW, imgH, xP, yP, xS, yS;
               ZI_GetImageSizeFromControl(g_hImageCtrl, imgW, imgH);

               ZI_Iconise(imgW, imgH, lpw.right - lpw.left, lpw.bottom - lpw.top, xP, yP, xS, yS);
               if (imgW) {
                  hCtrl = GetDlgItem(g_hMain, IDC_MAIN_SLIDEZOOM);
                  SendMessageA(hCtrl, TBM_SETPAGESIZE, 0, 1);
                  SendMessageA(hCtrl, TBM_SETLINESIZE, 0, 1);
                  SendMessageA(hCtrl, TBM_SETTICFREQ, 0, 1);
                  SendMessageA(hCtrl, TBM_SETRANGE, 1, MAKELONG( 1, imgW));
                  SendMessageA(hCtrl, TBM_SETPOS, 1, xS);
               }

               // Start with the default picture.
               sResource = sResourcePath;
               sResource += "Naavi.png";
               UseThisPhoto(sResource, 0);

               // Add a transparent logo on the top right corner.
               sResource = sResourcePath;
               sResource += "GDImage.png";
               // Load image and retrieve the width and height of its bitmap.
               HANDLE hBitmap = ZI_CreateBitmapFromFile(sResource, imgW, imgH);
               // Use the new hBitmap to create a sprite image on the top right corner.
               ZD_DrawBitmapToCtrl(g_hImageCtrl, (lpw.right - lpw.left) - (imgW + 10), 10, hBitmap, ZD_ColorARGB(255, 0), ID_LOGO, ZS_VISIBLE);
               // Anchor the logo to the top right corner.
               ZD_SetObjectAnchorMode(ID_LOGO, ANCHOR_RIGHT);
               // Lock and disable the sprite image.
               ZD_SetObjectLocked(ID_LOGO, TRUE);
                         
            }
         }

         ShowWindow(g_hMain, SW_SHOW);

         // Create a fall down effect animation.
         RECT lpw; int k, NewW, NewH;
         GetWindowRect(g_hMain, &lpw);
         NewW = lpw.right - lpw.left;
         NewH = lpw.bottom - lpw.top;
         //x = max((GetSystemMetrics(SM_CXSCREEN) - MyWindowWidth) \ 2, 0)
         //   y = Max((GetSystemMetrics(SM_CYSCREEN) - MyWindowHeight) \ 2, 0)
         //   w = MyWindowWidth
         //   h = MyWindowHeight
         ShowWindow(g_hImageCtrl, 0);
         dwStyle = RDW_INVALIDATE | RDW_INTERNALPAINT | RDW_ERASE | RDW_ERASENOW | RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_FRAME;
         for (k = -h ; k < 0 ; k += 8 ) {
             MoveWindow(g_hMain, x, k, w, h, 0);
             ZI_UpdateWindow(g_hMain, 1);
         }
         for (k = 0; k <= y; k += 8) {
             MoveWindow(g_hMain, x, k, w, h, 0);
             RedrawWindow(g_hMain, NULL, NULL, dwStyle);
         }
         ShowWindow(g_hMain, SW_HIDE);
         x = max((GetSystemMetrics(SM_CXSCREEN) - NewW) / 2, 0);
         y = max((GetSystemMetrics(SM_CYSCREEN) - NewH) / 2, 0);
         MoveWindow(g_hMain, x, y, NewW, NewH, 0);
         ShowWindow(g_hMain, SW_SHOW);
         ShowWindow(g_hImageCtrl, SW_SHOW);

         UpdateWindow(g_hMain);

         // Main message loop
         while (GetMessage(&msg, NULL, 0, 0)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
         }
         nRet = msg.wParam;
      }
   }

   return nRet;
}

// Main winproc
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {

   HWND hPopup, hDW, hCtrl;          int wmId, wmEvent, nRet, nPos;
   string sDataString, sUseFile;   char szText[MAX_PATH];
   NMHDR *pNMHDR;
   PAINTSTRUCT ps; HDC hdc;

   if (uMsg == WM_ZWPNOTIFICATION) {
       switch (wParam) {
       case NM_AUDIOCOMPLETION:
            // Uncheck VisualPlugin
            SendMessage(GetDlgItem(hWnd, IDC_MAIN_PLUGIN), BM_SETCHECK, BST_UNCHECKED, 0);
            ZWP_Hide();
            hPopup = skGetDWMregion(hWnd);
            if (hPopup) {
               SetWindowPos(hPopup, GetWindow(hWnd, 2), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
               SetFocus(hWnd);
            }
            break;
       }
       return 0;
   }

   switch (uMsg) {

   case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        // TODO: process here the WM_PAINT message...
        EndPaint(hWnd, &ps);
        return 0;

   case WM_NOTIFY:
        pNMHDR = (NMHDR*) lParam;
        // Assign the new rotation angle to the sprite image.
        nPos = pNMHDR->code;
        switch (pNMHDR->idFrom) {  

        case IDC_MAIN_KNOBBIG:
             ZD_SetObjectAngle(g_nFocusID, nPos, TRUE);
             skGaugeSetPos(GetDlgItem(hWnd, IDC_MAIN_KNOBLEFT), nPos, TRUE);
             skGaugeSetPos(GetDlgItem(hWnd, IDC_MAIN_KNOBRIGHT), nPos, TRUE);
        break;
        case IDC_MAIN_KNOBLEFT:
             ZD_SetObjectAngle(g_nFocusID, nPos, TRUE);
             skGaugeSetPos(GetDlgItem(hWnd, IDC_MAIN_KNOBBIG), nPos, TRUE);
             skGaugeSetPos(GetDlgItem(hWnd, IDC_MAIN_KNOBRIGHT), nPos, TRUE);
             break;
        case IDC_MAIN_KNOBRIGHT:
             ZD_SetObjectAngle(g_nFocusID, nPos, TRUE);
             skGaugeSetPos(GetDlgItem(hWnd, IDC_MAIN_KNOBBIG), nPos, TRUE);
             skGaugeSetPos(GetDlgItem(hWnd, IDC_MAIN_KNOBLEFT), nPos, TRUE);
             break;
        }
        return 0;

   case WM_SIZE:
   case WM_MOVE:
   case WM_WINDOWPOSCHANGED:
   case WM_IME_NOTIFY:
        if (ZWP_Handle()) {
           ZWP_SizeMove();
        }
        break;

   case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);

        // Process menu command
        switch (wmId) {

        case IDC_MAIN_LOADIMAGE:
             hDW = skCreateDW(hWnd);
             sDataString = ZI_LoadDialog(hWnd);
             skDestroyDW(hDW);

             if (sDataString.length()) {
                 UseThisPhoto(sDataString, 0);
             }
             break;

        case IDC_MAIN_CHECKBOX:
             nRet = SendMessageA(GetDlgItem(hWnd, IDC_MAIN_CHECKBOX), BM_GETCHECK, 0, 0);
             if (nRet == BST_CHECKED) {
                ZI_UseWinLIFTbackground(g_hImageCtrl, FALSE, TRUE); }
             else {
                ZI_UseWinLIFTbackground(g_hImageCtrl, TRUE, TRUE);
             }
             SetFocus(g_hImageCtrl);
             break;

        case IDC_MAIN_PLUGIN:
             nRet = SendMessageA(GetDlgItem(hWnd, IDC_MAIN_PLUGIN), BM_GETCHECK, 0, 0);
             if (nRet == BST_CHECKED) {
                hCtrl = GetDlgItem(hWnd, IDC_CB_AUDIO);
                SendMessageA(hCtrl, CB_GETLBTEXT, SendMessageA(hCtrl, CB_GETCURSEL, 0, 0), (LPARAM) szText);
                hPopup = skGetDWMregion(hWnd);
                if (hPopup) { ShowWindow(hPopup, SW_HIDE); }
                sUseFile = g_sAudioPath;
                sUseFile += szText;
                ZWP_Show(sUseFile); }
             else {
                hPopup = skGetDWMregion(hWnd);
                if (hPopup) { ShowWindow(hPopup, SW_SHOW); }
                ZWP_Hide();
             }
             SetFocus(g_hImageCtrl);
             break;

        case IDC_CB_PLUGIN:
             if (wmEvent == CBN_SELENDOK) {
                hCtrl = GetDlgItem(hWnd, IDC_CB_PLUGIN);
                SendMessageA(hCtrl, CB_GETLBTEXT, SendMessageA(hCtrl, CB_GETCURSEL, 0, 0), (LPARAM) szText);
                sUseFile = g_sPluginPath;
                sUseFile += szText;
                ZWP_UsePlugin(sUseFile);
                SetFocus(g_hImageCtrl);
             }
             break;

        case IDC_CB_AUDIO:
             if (wmEvent == CBN_SELENDOK) {
                nRet = SendMessageA(GetDlgItem(hWnd, IDC_MAIN_PLUGIN), BM_GETCHECK, 0, 0);
                if (nRet == BST_CHECKED) {
                   hCtrl = GetDlgItem(hWnd, IDC_CB_AUDIO);
                   SendMessageA(hCtrl, CB_GETLBTEXT, SendMessageA(hCtrl, CB_GETCURSEL, 0, 0), (LPARAM) szText);
                   sUseFile = g_sAudioPath;
                   sUseFile += szText;
                   ZWP_Play(sUseFile);
                }
                SetFocus(g_hImageCtrl);
             }
             break;

        }
        return 0;

   case WM_VSCROLL:
        nRet = GetDlgCtrlID((HWND) lParam);
        if (nRet == IDC_MAIN_SLIDEZOOM) {
           UseThisZoom(SendMessageA((HWND) lParam, TBM_GETPOS, 0, 0)); // Do not use nPosition, because it could be NULL.
        }
        break;

   case WM_CLOSE:
        hPopup = skGetDWMregion(hWnd);
        // Hide DWMregion if any.
        if (hPopup) { MoveWindow(hPopup, 0, 0, 0, 0, 1); }
        break;

   case WM_DESTROY:
        ZWP_Destroy();
        PostQuitMessage(0);
        return 0;
   }

   return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

string FullExeName() {
   string sResult;
   char exepath[MAX_PATH];
   if (GetModuleFileNameA(0, exepath, sizeof(exepath))) {
      sResult = exepath;
   }
   return sResult;
}

string ExePath() {
   string sResult;
   char exepath[MAX_PATH];
   if (GetModuleFileNameA(0, exepath, sizeof(exepath))) {
      sResult = exepath;
      sResult = sResult.substr( 0, sResult.rfind("\\"));
      sResult += "\\";
   }
   return sResult;
}

void ComboSelectPlus (
   HWND hCombo,
   int nSelected) {
   if (nSelected > 0) {
      nSelected -= 1; // Because ListBox is zero based.
   }
   if (hCombo) {
      SendMessageA(hCombo, CB_SETCURSEL, nSelected, 0);
   }
}

void DetectAudio (HWND hCombo, int nUseItem) {

   if (!hCombo) return;

   int nCount, nPos;
   HANDLE hFind;
   WIN32_FIND_DATAA fd;
   char zTmp[MAX_PATH];
   char zExt[8];
   std::string sExt;

   SendMessageA(hCombo, CB_RESETCONTENT, 0, 0);

   string sAudio = ".xm.mod.it.s3m.mo3.mp3.ogg.";
   string sSearch = g_sAudioPath;
   sSearch += "*.*";
   strncpy_s(zTmp, sSearch.c_str(), sSearch.size() );
   hFind = FindFirstFileA((LPSTR) zTmp, &fd);
   nCount = 0;
   nPos = 0;
   if (hFind != INVALID_HANDLE_VALUE) {
      while (FindNextFileA(hFind, &fd)) {
         if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
            sSearch = fd.cFileName;
            strncpy_s(zTmp, sSearch.c_str(), sSearch.size() );
            nPos = sSearch.find_last_of("."); // Extract extension.
            sExt = sSearch.substr(nPos);      // Extract extension
            sExt += ".";                      // Add '.' to extension.
            strncpy_s(zExt, sExt.c_str(), sExt.size() );
            CharLowerA(zExt);
            nPos = sAudio.find(zExt);
            if (nPos) {
               if (SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) zTmp) > -1) {
                  nCount += 1;
               }
            }
         }
      }
      FindClose(hFind);
   }

   if (nCount) {
      if (nUseItem > nCount) { nUseItem = 1; }
      ComboSelectPlus(hCombo, nUseItem);
   }
}

void DetectPlugin (HWND hCombo, int nUseItem) {

   if (!hCombo) return;

   int nCount, nPos;
   HANDLE hFind;
   WIN32_FIND_DATAA fd;
   char zTmp[MAX_PATH];
   char zExt[8];
   std::string sExt;

   SendMessageA(hCombo, CB_RESETCONTENT, 0, 0);

   string sSearch = g_sPluginPath;
   sSearch += "*.dll";
   strncpy_s(zTmp, sSearch.c_str(), sSearch.size() );
   hFind = FindFirstFileA((LPSTR) zTmp, &fd);
   nCount = 0;
   if (hFind != INVALID_HANDLE_VALUE) {
      while (FindNextFileA(hFind, &fd)) {
         if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
            sSearch = fd.cFileName;
            strncpy_s(zTmp, sSearch.c_str(), sSearch.size() );
            nPos = sSearch.find_last_of("."); // Extract extension.
            sExt = sSearch.substr(nPos);    // Extract extension
            sExt += ".";            // Add '.' to extension.
            strncpy_s(zExt, sExt.c_str(), sExt.size() );
            CharLowerA(zExt);
            sExt = zExt;
            if (!sExt.compare(".dll.")) { // Check if the two strings are the same
               if (SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) zTmp) > -1) {
                  nCount += 1;
               }
            }
         }
      }
       FindClose(hFind);
   }

   if (nCount) {
      if (nUseItem > nCount) { nUseItem = 1; }
      ComboSelectPlus(hCombo, nUseItem);
   }
}

void ZWP_SizeMove() {
   RECT lpw;
   int x, y, w, h;
   HWND hWnd, hPopup;
   GetWindowRect(g_hMain, &lpw);
   x = lpw.left + skGetSystemMetrics(SK_DWM_LEFT);
   y = lpw.top + skGetSystemMetrics(SK_DWM_TOP);
   w = lpw.right - skGetSystemMetrics(SK_DWM_RIGHT) - x;
   h = lpw.bottom - skGetSystemMetrics(SK_DWM_BOTTOM) - y;

   // Use this to move the window in case of AERO shake
   // because setting the new location with SetWindowPos
   // may fail!
   hWnd = ZWP_Handle();
   hPopup = skGetDWMregion(g_hMain);
   if (hPopup == 0) { hPopup = g_hMain; }

   SetWindowPos(hWnd, GetWindow(hPopup, 2), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
   MoveWindow(hWnd, x, y, w, h, 0);
}

void SetStaticValue(string sUseString, int nValue) {
   int nIndex;
   HWND hStaticHandle = 0;
   sUseString += "|";
   char zMsg[MAX_PATH]; strncpy_s(zMsg, sUseString.c_str(), sUseString.size() );
   hStaticHandle = GetDlgItem(g_hMain, IDC_STATIC);
   if (hStaticHandle == 0) {
      hStaticHandle = CreateWindowExA(0, "LISTBOX", "", WS_CHILD | LBS_HASSTRINGS, 0, 0, 0, 0, g_hMain, (HMENU) IDC_STATIC, GetModuleHandleA(NULL), NULL);
   }
   if (hStaticHandle) {
      nIndex = SendMessageA(hStaticHandle, 399, -1, (LPARAM) zMsg);
      if (nIndex > -1) { // We found same static
         SendMessageA(hStaticHandle, 410, nIndex, nValue); }
      else { // Add it to our static list
         SendMessageA(hStaticHandle, 410, SendMessageA(hStaticHandle, 384, 0, (LPARAM) zMsg), nValue);
      }
   }
}

int GetStaticValue(string sUseString) {
   int nIndex, nValue;
   HWND hStaticHandle;
   sUseString += "|";
   char zMsg[MAX_PATH]; strncpy_s(zMsg, sUseString.c_str(), sUseString.size() );
   nValue = 0;
   hStaticHandle = GetDlgItem(g_hMain, IDC_STATIC);
   if (hStaticHandle) {
      nIndex = SendMessageA(hStaticHandle, 399, -1, (LPARAM) zMsg);
      if (nIndex > -1) { // We found it
         nValue = SendMessageA(hStaticHandle, 409, nIndex, 0);
      }
   }
   return nValue;
}

HWND ZWP_Handle() {
   static HWND hZWP;
   if (hZWP == 0) {
      char zClass[] = "ZWALLPAPER";
      hZWP = FindWindowA(zClass, zClass);
      if (hZWP) {
         ZWP_SizeMove();
         string sMsg = "PARENT,";
         char szStr[12];
         sprintf_s(szStr, "% d", g_hMain);
         sMsg += szStr;
         sMsg += ",";
         sprintf_s(szStr, "% d", IDC_MAIN_WALLPAPER);
         sMsg += szStr;
         ZWP_Message(sMsg);
      }
   }
   return hZWP;
}

int ZWP_Message(string sMsg) {
   char szText[512];
   strncpy_s(szText, sMsg.c_str(), sMsg.size() );
   int nRet = SendMessageA(ZWP_Handle(), WM_SETTEXT, 0, (LPARAM) szText);
   return nRet;
}

void ZWP_Play(string sAudio) {
   string sMsg = "PLAY,";
   sMsg += sAudio;
   ZWP_Message(sMsg);
}

void ZWP_Stop() {
   ZWP_Message("STOP");
}

void ZWP_Hide() {
   ShowWindow(ZWP_Handle(), SW_HIDE);
   ZWP_Stop();
}

void ZWP_Destroy() {
   ZWP_Message("DESTROY");
}

void ZWP_UsePlugin(string sPlugin) {
   string sCommand = "PLUGIN,";
   sCommand += sPlugin;
   ZWP_Message(sCommand);
}

void ZWP_Show(string sAudio) {
   RECT lpw;
   int x, y, w, h;
   HWND hWnd, hPopup;
   GetWindowRect(g_hMain, &lpw);
   x = lpw.left + skGetSystemMetrics(SK_DWM_LEFT);
   y = -2000;
   w = lpw.right - skGetSystemMetrics(SK_DWM_RIGHT) - x;
   h = lpw.bottom - skGetSystemMetrics(SK_DWM_BOTTOM) - y;

   // Use this to move the window in case of AERO shake
   // because setting the new location with SetWindowPos
   // may fail!
   hWnd = ZWP_Handle();
   hPopup = skGetDWMregion(g_hMain);
   if (hPopup == 0) { hPopup = g_hMain; }
   SetWindowPos(hWnd, GetWindow(hPopup, 2), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
   MoveWindow(hWnd, x, y, w, h, 0);

   ZWP_SizeMove();
   ZWP_Play(sAudio);
   ShowWindow(hWnd, SW_SHOW);
}

void UseThisZoom(int nPos) {
   if (g_nFocusID) {
      HWND hCtrl;
      float rZoomValue;

      rZoomValue = float (nPos * 0.001);
      if (rZoomValue != g_rWasZoom) {
         hCtrl = ZD_GetObjectParent(g_nFocusID);
         // Make sure to disable the crop rectangle if any
         if (ZI_GetToolCropStatus(hCtrl)) { ZI_DisableCropRectangle(hCtrl); }

         ZD_SetObjectScale(g_nFocusID, rZoomValue);
         ZI_UpdateWindow(hCtrl, FALSE);

      }
      g_rWasZoom = rZoomValue;
   }
}

void GDImageSetZoomRange(int bmW, int bmH, int &xSize, int &ySize) {
   RECT lpr;
   int xPos, yPos;
   HWND hCtrl;

   GetClientRect(g_hImageCtrl, &lpr);

   ZI_Iconise(bmW, bmH, lpr.right, lpr.bottom, xPos, yPos, xSize, ySize);

   hCtrl = GetDlgItem(g_hMain, IDC_MAIN_SLIDEZOOM);
   SendMessageA(hCtrl, TBM_SETRANGE, 1, MAKELONG((int)((xSize / bmW) * 128), 1500));
}

void UseThisPhoto(
   string sUsePhoto,
   int bReset
   ) {

   RECT lpr;
   HANDLE hBitmap;
   int nW, nH, nX, nY, nSizeX, nSizeY, nPosAngle;
   float rAspect, rZoomValue;

   // Make sure to disable the crop rectangle if any
   if (ZI_GetToolCropStatus(g_hImageCtrl)) { ZI_DisableCropRectangle(g_hImageCtrl); }

   ZI_GetImageSizeFromFile(sUsePhoto, g_nTrueWidth, g_nTrueHeight);
   nW = max(g_nTrueWidth, g_nTrueHeight);
   if (nW > 1024) { nW = 1024; }
   hBitmap = ZI_FitBitmapFromFile((sUsePhoto), nW, nW);

   ZI_GetBitmapSize(hBitmap, nW, nH);

   if (hBitmap) {
      g_nUseWidth = nW; g_nUseHeight = nH;

      // Compute range based on the image size
      GDImageSetZoomRange(g_nUseWidth, g_nUseHeight, nSizeX, nSizeY);

      GetClientRect(g_hImageCtrl, &lpr);
      ZI_Iconise(g_nTrueWidth, g_nTrueHeight, lpr.right, lpr.bottom, nX, nY, nW, nH);
      if (nW > nH) {
         rAspect = float (nW / nH); }
      else {
         rAspect = 1;
      }

      rZoomValue = float (nSizeX / (g_nUseWidth / rAspect));
      SendMessageA(GetDlgItem(g_hMain, IDC_MAIN_SLIDEZOOM), TBM_SETPOS, 1, (int)(rZoomValue * 1000));

      GetClientRect(g_hImageCtrl, &lpr);
      nX = (lpr.right - g_nUseWidth) / 2;
      nY = (lpr.bottom - g_nUseHeight) / 2;

      ZD_DrawBitmapToCtrl(g_hImageCtrl, nX, nY, hBitmap, ZD_ColorARGB(255, 0), ID_PHOTO, ZS_HIDDEN); // ZS_VISIBLE)
      ZD_SetObjectScale(ID_PHOTO, rZoomValue);

      nPosAngle = skGaugeGetPos(GetDlgItem(g_hMain, IDC_MAIN_KNOBBIG));
      ZD_SetObjectAngle(ID_PHOTO, nPosAngle, FALSE);
      ZD_SetObjectAnchorMode(ID_PHOTO, ANCHOR_CENTER);

      //UpdateQualityStatus(TRUE)

      SetFocus(g_hImageCtrl);
      ZI_SetObjectFocusID(ID_PHOTO);
      g_nFocusID = ID_PHOTO;

      ZD_SetObjectVisibility(ID_PHOTO, ZS_VISIBLE);
      ZI_UpdateWindow(g_hImageCtrl, 0);
   }
}
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#2
This is a partial encapsulation of the GDImage API for C++ Win32.

//+--------------------------------------------------------------------------+
//|                                                                          |
//|                                GDImage.h                                 |
//|                                                                          |
//|         C++ GDImage API encapsulation constants and declarations.        |
//|                                                                          |
//|                               Version 5.16                               |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|                                                                          |
//|                         Author Patrice TERRIER                           |
//|            8 Domaine de Rochagnon. 38800 Champagnier  FRANCE             |
//|                       http://www.zapsolution.com                         |
//|                    E-mail: pterrier@zapsolution.com                      |
//|                                                                          |
//|                   copyright (c) 2010 Patrice TERRIER                     |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|          C++ translation started on : 08-03-2010                         |
//|                        Last revised : 08-08-2010                         |
//+--------------------------------------------------------------------------+

#include <windows.h>
//
#include <iostream>
#include <string.h>

// Macro definitions.
#define int_proc typedef int (__stdcall *zProc)
#define string_proc typedef char* (__stdcall *zProc)
#define void_proc typedef void (__stdcall *zProc)
#define handle_proc typedef HANDLE (__stdcall *zProc)

//
// Constants.
#define zLim              '|'
#define Anti              '\\'
#define Dot               '.'
#define GDImageClassName  "ZIMAGECTRL"  // Class name for GDImage standard control.
#define GLImageClassName  "ZOPENGLCTRL" // Class name for OpenGL control.

// Anchor constants
#define ANCHOR_NONE                0
#define ANCHOR_LEFT                ANCHOR_NONE
#define ANCHOR_WIDTH               1
#define ANCHOR_RIGHT               2
#define ANCHOR_CENTER_HORZ         3
#define ANCHOR_HEIGHT              4
#define ANCHOR_HEIGHT_WIDTH        5
#define ANCHOR_HEIGHT_RIGHT        6
#define ANCHOR_BOTTOM              7
#define ANCHOR_BOTTOM_WIDTH        8
#define ANCHOR_BOTTOM_RIGHT        9
#define ANCHOR_CENTER_HORZ_BOTTOM  10
#define ANCHOR_CENTER_VERT         11
#define ANCHOR_CENTER_VERT_RIGHT   12
#define ANCHOR_CENTER              13

#define ZM_Size            WM USER + 1001
#define ZM_Crop            WM USER + 1002
#define ZM_CENTER_DIALOG   WM USER + 1003
#define ZM_CropRedEye      WM USER + 1004

// Constant prefixed with ZD_ apply to DRAWING functions
#define ZD_TRANSCOLOR      0xFF00FF     // Magenta color that is the default GDImage transparent color
#define ZD_TOPLEFTCOLOR    -1           // Pixel color at location 0,0
//
// ZD DrawText constants
#define ZD_TextHorzUp      0            // Horizontal text orientation
#define ZD_TextVertUp      4            // Vertical text orientation from bottom to top
#define ZD_TextVertDn      8            // Vertical text orientation from top to bottom
#define ZD_HIDE            0            // FALSE
#define ZD_SHOW            1            // TRUE

// GDImage overlay Generic STYLE must be a 2^
#define ZS_HIDDEN          ZD_HIDE
#define ZS_VISIBLE         ZD_SHOW      // VISIBLE, same as %WS VISIBLE
#define ZS_SCROLL          2            // MOVE with scroll bars, default is FIX (do not scroll)
#define ZS_DRAFT           4            // Draft drawing mode

// GDImage drawing style for all the ZD_Drawxxx functions
#define ZD_DRAW_OUTLINE    1
#define ZD_DRAW_FILLED     2
#define ZD_DRAW_3DIN       3
#define ZD_DRAW_3DOUT      4
#define ZD_DRAW_OPEN       5

#define ZD_DRAW_REDRAW     -1           // Forces immediate redraw of parent object
#define ZD_DRAW_DEFERRED   0            // Defers redraw of parent object

// Sprite objects:
#define OBJECT_TEXT        1
#define OBJECT_ELLIPSE     2
#define OBJECT_RECT        3
#define OBJECT_CURVE       4
#define OBJECT_ARROW       5
#define OBJECT_POLYLINE    6
#define OBJECT_BITMAP      7
#define OBJECT_BEZIER      8
#define OBJECT_POLYPOLYGON 9
#define OBJECT_TEXTBITMAP  10

// Internal GDImage structure being used to store details about each sprite object.
#define      METADATA_SIZE    2048      //See it in GDImage.inc
typedef struct {
    HWND    hWnd;        
    LONG    objType;    
    LONG    metacount;  
    char    metadata[METADATA_SIZE];

    char    useFont[64];
    char    extrabyte[64];

    LONG    useSize;    
    LONG    fontFam;    
    LONG    curFont;    
    LONG    strFormat;  
    LONG    useARGB;    
    LONG    use3D;      
    LONG    x1;          // x top coordinate
    LONG    y1;          // y top coordinate
    LONG    x2;          // object width
    LONG    y2;          // object height
    LONG    visible;    
    LONG    order;      
    BYTE    locked;      

    LONG    ID;              
    LONG    Style;      
    LONG    Bitmap;      
    LONG    Region;      
    char    objLabel[64];
    short   xCapture;
    short   yCapture;
    BYTE    opacity;     // PNG variable opacity
    float   scale;        
    LONG    clone;        
    short   xP;            
    short   yP;            
    WORD    angle;      
    BYTE    quality;          
    BYTE    flipmode;        
    BYTE    userotate;        
    BYTE    selected;        
    BYTE    hidden;          
         
    BYTE    brightness;      
    BYTE    contrast;        
    BYTE    red;              
    BYTE    green;            
    BYTE    blue;            
    BYTE    hue;              
         
    BYTE    FrameCount;      
    BYTE    FrameToUse;      
         
    BYTE    anchor;          
    SHORT   nLeft;  
    SHORT   nTop;      
    SHORT   nRight;    
    SHORT   nBottom;    
    SHORT   centerx;    
    SHORT   centery;    

    LONG    linked;      

    char    reserved[2];
} ZOBJECT; // 2368 bytes
// WARNING in case of change into the ZOBJECT structure that would impact its size,
// don't forget to update the "zItemFromID" and "zCloneFromID" functions!!!

HMODULE g_GDImage_DLL;

// Load the GDImage DLL.
int LoadDLL_GDImage() {
   static int nRet;
   if (nRet == 0) {
      g_GDImage_DLL = LoadLibraryA ("GDImage");
      if (g_GDImage_DLL != 0) { nRet = -1; }
   }
   return nRet;
}

// Unlock the DLL
int ZI_LoadDLL (
   std::string sUserKey        // The private user key.
   ) {

   int nRet = 0;

   if (g_GDImage_DLL == 0) { LoadDLL_GDImage(); }

   if (g_GDImage_DLL) {
       int_proc (char*);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_LoadDLL");
       if (hPROC) {
           nRet = hPROC((char*) sUserKey.c_str());
       }
       else {
           FreeLibrary(g_GDImage_DLL);
       }
   }
   return nRet; // 0 = means failure, any other value means success.
}

// Register the GDImage window classes.
// Must be done in the WinMain section BEFORE USING any of the GDImage function.
// Parameter: None
int RegisterGDImageClass(
   ) {

   int nRet = 0;

   if (g_GDImage_DLL == 0) { LoadDLL_GDImage(); }

   if (g_GDImage_DLL) {
       int_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "RegisterGDImageClass");
       if (hPROC) {
           nRet = hPROC();
       }
       else {
           FreeLibrary(g_GDImage_DLL);
       }
   }
   return nRet; // 0 = means failure, any other value means registered.
}

// Get the GDImage.dll internal version number
string ZI_Version (
   ) {

   std::string sText;

   if (g_GDImage_DLL) {
       string_proc ();
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_Version");
       if (hPROC) {
           sText = hPROC();
       }
   }
   return sText; // Version number of the form "#.#"
}

// Enable/Disable drawing of the WinLIFT skin background in the specified GDImage graphic control.
void ZI_UseWinLIFTbackground (
   HWND hGDImageCtrl,          // The GDimage control handle.
   int TrueOrFalse,            // The enable/disable boolean value to use.
   int RedrawParent            // TRUE causes immediate redraw of the object parent.
   ) {

   if (g_GDImage_DLL) {
       void_proc (HWND, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_UseWinLIFTbackground");
       if (hPROC) {
           hPROC(hGDImageCtrl, TrueOrFalse, RedrawParent);
       }
   }
}

// To force immediate refresh of a GDImage control display
void ZI_UpdateWindow (  
   HWND hGDImageCtrl,          // The GDimage control handle.
   int EraseFlag               // Boolean flag to erase first the background.
   ) {

   if (g_GDImage_DLL) {
       void_proc (HWND, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_UpdateWindow");
       if (hPROC) {
           hPROC(hGDImageCtrl, EraseFlag);
       }
   }
}

// Apply a scale factor to resize a sprite on the fly
// Note: the real size of the sprite bitmap stay unchanged, it just affect the way it is being shown.
void ZD_SetObjectScale (  
   int ObjID,                  // The unique sprite object identifier.
   float rScaleValue           // The scale factor 0.5, 0.75, 0.80, etc.
   ) {

   if (g_GDImage_DLL) {
       void_proc (int, float);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_SetObjectScale");
       if (hPROC) {
           hPROC(ObjID, rScaleValue);
       }
   }
}

// Disable (cancel) the drawing of a rectangular section.
// See also: ZI EnableCropRectangle.
void ZI_DisableCropRectangle (  
   HWND hGDImageCtrl           // The GDimage control handle.
   ) {

   if (g_GDImage_DLL) {
       void_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_DisableCropRectangle");
       if (hPROC) {
           hPROC(hGDImageCtrl);
       }
   }
}

// The Crop tool status mode.
// Return: True = Crop status is On, False = Crop status is false.
int ZI_GetToolCropStatus (  
   HWND hGDImageCtrl           // The GDimage control handle.
   ) {

   int nRet = 0;

   if (g_GDImage_DLL) {
       int_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_GetToolCropStatus");
       if (hPROC) {
           nRet = hPROC(hGDImageCtrl);
       }
   }
   return nRet; // 0 = means failure, any other value means success.
}

// Retrieve the immediate parent of the overlay object
// Return: the GDImage control handle of the parent.
HWND ZD_GetObjectParent (  
   int ObjID                   // The unique object IDentifier (each object MUST USE A UNIQUE one).
   ) {

   HWND hCtrl = 0;

   if (g_GDImage_DLL) {
       hwnd_proc (int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_GetObjectParent");
       if (hPROC) {
           hCtrl = hPROC(ObjID);
       }
   }
   return hCtrl;
}

//4.05
// Useful to embend an image into a fixed size square to perform image rotation from the center.
// Example 512 x 512 or 1024 x 1024 or 2048 x 2048 or 1024 x 512 (for texture creation).
HANDLE ZI_FitBitmapFromFile (
   std::string sFullPath,         // Full path name to image.
   int Xin,                       // Width of the container.
   int Yin                        // Height of the container.
   ) {

   HANDLE hBitmap = 0;

   if (g_GDImage_DLL) {
       handle_proc (char*, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_FitBitmapFromFile");
       if (hPROC) {
           hBitmap = hPROC((char*) sFullPath.c_str(), Xin, Yin);
       }
   }
   return hBitmap;
}

// Computes location and size to stretch a bitmap preserving its aspect.
void ZI_Iconise (
   int xPicSize,               // The real image width.
   int yPicSize,               // The real image height.
   int xCell,                  // The fit into wdith.
   int yCell,                  // The fit inot height.
   int &xPos,                  // New X computed value.
   int &yPos,                  // New Y computed value.
   int &xSiz,                  // New Width computed value.
   int &ySiz                   // New Height computed value.
   ) {

   xPos = 0, yPos = 0; xSiz = 0, ySiz = 0;
   if (g_GDImage_DLL) {
       void_proc (int, int, int, int, int*, int*, int*, int*);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_Iconise");
       if (hPROC) {
           hPROC(xPicSize, yPicSize, xCell, yCell, &xPos, &yPos, &xSiz, &ySiz); // Passage by reference.
       }
   }
}

// Create a sprite BITMAP (overlay object).
// Return: TRUE (-1) if success, FALSE (0) if error.
int ZD_DrawBitmapToCtrl (  
   HWND hGDImageCtrl,          // The GDImage control handle.
   int x,                      // The X coordinate.
   int y,                      // The Y coordinate.
   HANDLE hBitmap,             // The bitmap handle.
   int ColrARGB,               // ARGB color with Alpha channel (0-255).
   int ObjID,                  // Unique onlect IDentifier.
   int ZS_Style  
   ) {

   int nRet = 0;

   if (g_GDImage_DLL) {
       int_proc (HWND, int, int, HANDLE, int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_DrawBitmapToCtrl");
       if (hPROC) {
           nRet = hPROC(hGDImageCtrl, x, y, hBitmap, ColrARGB, ObjID, ZS_Style);
       }
   }
   return nRet;
}

// Retrieve bitmap size from a supported GDI+ disk file (do not load the image)
void ZI_GetImageSizeFromFile (  
   string sFullPath,           // The name of the graphic file to detect size
   int &imgWidth,              // Width of the picture
   int &imgHeight              // Height of the picture
   ) {

   imgWidth = 0, imgHeight = 0;
   if (g_GDImage_DLL) {
       void_proc (char*, int*, int*);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_GetImageSizeFromFile");
       if (hPROC) {
           hPROC((char*) sFullPath.c_str(), &imgWidth, &imgHeight); // Passage by reference.
       }
   }
}

// To GET the Width and Height of a STANDARD BITMAP
void ZI_GetBitmapSize (  
   HANDLE hBitmap,             // Handle to a standard bitmap.
   int &BitmapWidth,           // The width of the bitmap.
   int &BitmapHeight           // The Height of the bitmap.
   ) {

   BitmapWidth = 0, BitmapHeight = 0;
   if (g_GDImage_DLL) {
       void_proc (HANDLE, int*, int*);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_GetBitmapSize");
       if (hPROC) {
           hPROC(hBitmap, &BitmapWidth, &BitmapHeight); // Passage by reference.
       }
   }
}

// Compute an ARGB color to ensure compatibility with GDI+
// Return: 32-bit ARGB color.
int ZD_ColorARGB (  
   BYTE AlphaChannel,          // The translucency level ranging from 0 to 255.
   DWORD ColrRGB               // The classical RGB() color to use.
   ) {

   int nRet = 0;

   if (g_GDImage_DLL) {
       int_proc (BYTE, DWORD);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_ColorARGB");
       if (hPROC) {
           nRet = hPROC(AlphaChannel, ColrRGB);
       }
   }
   return nRet;
}

// Retrieve the rotation angle of a GDImage sprite object.
// Return: the rotation angle in degree (0-360).
int ZD_GetObjectAngle (  
   int ObjID  
   ) {

   int nRet = 0;

   if (g_GDImage_DLL) {
       int_proc (int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_GetObjectAngle");
       if (hPROC) {
           nRet = hPROC(ObjID);
       }
   }
   return nRet;
}

// Set the rotation angle of a GDImage sprite object.
// Remark: full rotation angle applies only to bitmap objects (OBJECT_BITMAP and OBJECT_TEXTBITMAP).
void ZD_SetObjectAngle (  
 int ObjID,         // The unique sprite object identifier.
 int AngleDegree,   // Value must fit within the 0-360 degree range.
 int RedrawParent   // TRUE causes immediate redraw of the object parent.
 ) {

   if (g_GDImage_DLL) {
       void_proc (int, int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_SetObjectAngle");
       if (hPROC) {
           hPROC(ObjID, AngleDegree, RedrawParent);
       }
   }
}

// To anchor a specific GDImage sprite object.
// Note: it uses a limited subset of the ANCHOR_flags,
//       because you can't change the width or the height of a sprite object with any of ANCHOR_WIDTH or ANCHOR_HEIGHT
int ZD_SetObjectAnchorMode (  
   int nObjID,  
   int AnchorMode  
   ) {

   int nRet = 0;

   if (g_GDImage_DLL) {
       int_proc (int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_SetObjectAnchorMode");
       if (hPROC) {
           nRet = hPROC(nObjID, AnchorMode);
       }
   }
   return nRet;
}

// Put the focus on a specific GDImage sprite object.
// Remark: dito a left mouse button clic on a GDImage sprite object.
void ZI_SetObjectFocusID (  
   int nObjID                  // The unique object IDentifier.
   ) {

   if (g_GDImage_DLL) {
       void_proc (int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_SetObjectFocusID");
       if (hPROC) {
           hPROC(nObjID);
       }
   }
}

// Show or Hide a specific GDImage overlay object.
void ZD_SetObjectVisibility (  
   int nObjID,                 // The unique object IDentifier (each object MUST USE A UNIQUE one).
   int ShowOrHide              // A boolean TRUE/FALSE flag to show or hide the object.
   ) {

   if (g_GDImage_DLL) {
       void_proc (int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_SetObjectVisibility");
       if (hPROC) {
           hPROC(nObjID, ShowOrHide);
       }
   }
}

// Display the common file selector dialog using thumbnail preview for the supported graphic format.
// Return: the FullPathName of the selected picture
string ZI_LoadDialog (
   HWND hParent                // The parent window handle.
   ) {

   std::string sFileName;

   if (g_GDImage_DLL) {
       string_proc (HWND);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_LoadDialog");
       if (hPROC) {
           sFileName = hPROC(hParent);
       }
   }
   return sFileName;
}

// To retrieve the image size of specific GDimage control
void ZI_GetImageSizeFromControl (  
   HWND hGDImageCtrl,          // The GDimage control handle.
   int &imgW,                  // Width of the picture.
   int &imgH                   // Height of the picture.
   ) {

   imgW = 0, imgH = 0;
   if (g_GDImage_DLL) {
       void_proc (HWND, int*, int*);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_GetImageSizeFromControl");
       if (hPROC) {
           hPROC(hGDImageCtrl, &imgW, &imgH);
       }
   }
}

// Create a valid GDI BITMAP handle from FILE using any of the supported GDImage format.
// Return: a valid GDI bitmap handle (do not confuse GDI bitmap handle and GDI+ Image handle).
// Important: you must use DeleteObject(GDIBitmapHandle) when you do not need it anymore.
HANDLE ZI_CreateBitmapFromFile (  
   string sFullPath,           // The name of an image file.
   int &bmW,                   // The width of the bitmap.
   int &bmH                    // The Height of the bitmap.
   ) {

   HANDLE hBitmap = 0;
   bmW = 0, bmH = 0;

   if (g_GDImage_DLL) {
       handle_proc (char*, int*, int*);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZI_CreateBitmapFromFile");
       if (hPROC) {
           hBitmap = hPROC((char*) sFullPath.c_str(), &bmW, &bmH);
       }
   }
   return hBitmap;
}        

// Set the mouse lock status of a specific sprite object.
void ZD_SetObjectLocked (  
   int ObjID,                  // The unique sprite object identifier.
   int TrueFalse               // The TRUE or FALSE lock mode.
   ) {

   if (g_GDImage_DLL) {
       void_proc (int, int);
       zProc hPROC = (zProc) GetProcAddress(g_GDImage_DLL, "ZD_SetObjectLocked");
       if (hPROC) {
           hPROC(ObjID, TrueFalse);
       }
   }
}
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#3
Attached to this post, you will find the complete "HUD window" VS2010 c++ project.

It has been translated from the original "HUD plus" project written for PowerBASIC and WinDev.

Because this is the first application i have ever written with VS2010 (i am still learning it), if you find something wrong in the provided source code, please let me know, as i am also a beginner with C++.

The project is designed to work on Windows Seven running in AERO composited mode.

It is a pure Win32 project, using only the low level flat API.

"HUD window" introduce a new concept of transparent window, based on variable opacitiy ranging from opaque to full transaprency.

On the contrary of a layered window, using only one signle alpha channel for the main window and the child controls, the HUD window can have distinct alpha channels for each child controls, and every pieces of the interface.

VISTA was the first Windows OS to introduce, in the integral version, the concept of animated background, named DreamScene that is video based.

"HUD window" takes this a step further, and instead of "static video animation", it uses dynamic OpenGL plugins running in the background on the rythm of a playing audio file. And the result is the most amazing window you have ever seen.


  • The audio part of the project is based on Bass.dll and it can play most of the popular audio formats.
  • The visual animations are based on the OpenGL BassBox plugins.
  • The interface is skinned by WinLIFT, because it is the only one able to render child controls using variable opacity on a DWM DirectDraw surface.
  • The graphic control is based on GDImage, because it is also able to render its content on a DWM DirectDraw surface.


Screen shot:





How to use the project:

Use the combo to select a new audio file.
Use the combo to select a new visual plugin.
Use the checkbox "Visual plugin" to start the background animation.
Use the checkbox "Transparent HUD mode" to see the animation behind the graphic control.
Use any of the circular knob gauges to rotate the sprite image at any angle.
Use the left mouse button to move the sprite image inside of the graphic control.
Use the vertical slider on the right of the graphic control to zoom the sprite image in/out.
Use the folder button, to select a new image to display in the graphic control.
To select a new theme frame, click with the left or right mouse button on the Naavi's face icon, located on the top left corner.

Note:
Before you download a ZIP file from this forum, you must add this web site to your Internet Explorer security zone, to avoid problems with UAC.


The ZIP file has been moved here.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

I can't remember where I got this but it seems to work fine as a replacement for Pb's STR$/FORMAT$ when working with std::string

James


//**********************************
//Example of _str for std::string's
//**********************************
#include <iostream>
#include <sstream>
#include <string>
#include <typeinfo>
#include <stdexcept>
//**********************************
// I can't remember where I got this but I'm using it as STR$/FORMAT$
//**********************************
class BadConversion : public std::runtime_error {
public:
BadConversion(std::string const& s)
: std::runtime_error(s)
{ }
};
template<typename T>
inline std::string _str(T const& x)
{
std::ostringstream o;
if (!(o << x))
throw BadConversion(std::string("_str(")
+ typeid(x).name() + ")");
return o.str();
}
//**********************************
using namespace std;

int main (int argc, char** argv)
{
string  S1;
string  S2;
long     hwnd;
double   d;
hwnd=12345;
d=1.09356;
S1="Window Handle = ";
S1+=_str(hwnd);
S2=_str(d);
cout << S1 << endl;
cout << "d = " << S2 <<endl;
return 0;
}



Peter Weis

Hi Patrice,
Have the Debug directory of HUDplus.exe tested it works well. http://www.zapsolution.com/preview/HUDplusC++.zip
The project I could not test because my beta version of Visual Studio will not work.

Regards Peter

James C. Fuller

I found the answer and it was UAC.
I unblocked the zip before extraction and all worked fine.
At first I unzipped and then I needed to unblock all the exe's and dll's.

James

Patrice Terrier

#7
Peter, James,

Thank you very much for the feedbacks!

Indeed this is a good example of the UAC problem you can encounter downloading a ZIP file from a web site, that has not been put yet into the Internet Explorer security zone.

To avoid such problem with the José Roca's web site, please follow these steps:

QuoteTo add a website to a security zone

1.Open Internet Explorer by clicking the Start button , and then clicking Internet Explorer.

2.Navigate to the website that you want to add to a specific security zone.

3.Click the Tools button, and then click Internet Options.

4.Click the Security tab, and then click a security zone (Local intranet, Trusted sites, or Restricted sites).

5.Click Sites.

6.If you clicked Local intranet in the previous step, click Advanced.

7.The website should be shown in the Add this website to the zone field. Click Add.

If the site is not a secure site (HTTPS), clear the Require server verification (https:) for all sites in this zone check box.

8.Click Close, and then click OK (or click OK twice if you clicked Local intranet in step 4).

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

Any suggestions for Chrome or Firefox?

James

Patrice Terrier

James,

QuoteLooking ahead, Google has said it has no immediate plans to add Website security zones as in Internet Explorer or to add the ability to disable JavaScript within the user interface. It is possible, however, to disable JavaScript through the command line if that seems to be a way to thwart attacks.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

Ok. I guess now that we know what the problem was it's easy just to right click a zip file and unblock.
I've been doing that for .chm files right along.

On a related note(?):
  Is there an unzipper that preserves the file dates. I'm using 7-zip now and I don't see that option.

James

Peter Weis

Hi,

I have unpacked it with winrar X64 version 3.9. And had no problems

Regards Peter

James C. Fuller

Thanks for the reminder Peter.
I used WinRar for a long time and don't know why I stopped. Maybe when I upgraded computers??
Anyway I found my registration and will now start using it again.

James


James C. Fuller

#13
Patrice,
  We are both learning c++. I chose the MinGW route as I am also working with Linux but I think I may still be able to help(?)
A look at your source shows you are targeting c++ exclusivly. Why leave out all the "c" programmers?
You can always wrap with classes and c++ code after you have a working c model.

I am confused on the approach you took on calling the dll functions?
My research into function pointers and the output from Bcx lead me to very different coding.

I wrote a parser that took the PowerBASIC WinLift.inc file and created a c/c++ header file.
It has flaws. All window handles should be declared as HWND and I just guessed here. If the var name was hWnd I assumed HWND.
Also you can use PowerBASIC strings as the attached demo shows.

The cpp code was generated by Bcx with some tweaking by me so there is a lot of code that probably really isn't needed.

In wl.h I take the name of the function and prepend fp_ (function pointer). I then use the actual Function name for calling.
This way the calling is the same as if you had a .lib file to link in. Along with this you have parameter type checks.

This is the actual wl.h file:



HMODULE hWinLIFTDLL;
//==========================================
#define ANCHOR_NONE 0
#define ANCHOR_LEFT ANCHOR_NONE
#define ANCHOR_WIDTH 1
#define ANCHOR_RIGHT 2
#define ANCHOR_CENTER_HORZ 3
#define ANCHOR_HEIGHT 4
#define ANCHOR_HEIGHT_WIDTH 5
#define ANCHOR_HEIGHT_RIGHT 6
#define ANCHOR_BOTTOM 7
#define ANCHOR_BOTTOM_WIDTH 8
#define ANCHOR_BOTTOM_RIGHT 9
#define ANCHOR_CENTER_HORZ_BOTTOM 10
#define ANCHOR_CENTER_VERT 11
#define ANCHOR_CENTER_VERT_RIGHT 12
#define ANCHOR_CENTER 13
#define DISABLE_TIMER 99
#define FontStyleRegular 0
#define FontStyleBold 1
#define FontStyleItalic 2
#define FontStyleBoldItalic 3
#define FontStyleUnderline 4
#define FontStyleStrikeout 8
typedef int (__stdcall *fp_skInitEngine)(char*,char*);
typedef int (__stdcall *fp_skSkinWindow)(HWND,char*);
typedef int (__stdcall *fp_skSkinDisable)(HWND);
typedef int (__stdcall *fp_skSkinEnable)(HWND);
typedef BSTR* (__stdcall *fp_skAuthor)();
typedef int (__stdcall *fp_skSetAnchorCtrl)(HWND,int);
typedef void (__stdcall *fp_skRedrawMenuBar)(HWND);
typedef int (__stdcall *fp_skGetMenu)(HWND);
typedef int (__stdcall *fp_skMenuContainer)(HWND);
typedef int (__stdcall *fp_skCreateDW)(HWND);
typedef void (__stdcall *fp_skDestroyDW)(int);
typedef int (__stdcall *fp_skDialogAlert)(char*,char*,char*);
typedef int (__stdcall *fp_skDialogError)(char*,char*,char*);
typedef int (__stdcall *fp_skDialogInfo)(char*,char*,char*);
typedef int (__stdcall *fp_skDialogYesNo)(char*,char*,char*);
typedef BSTR* (__stdcall *fp_skDialogInput)(char*,char*,char*);
typedef BSTR* (__stdcall *fp_skVersion)();
typedef int (__stdcall *fp_skCaptionFont)();
typedef int (__stdcall *fp_skFont)();
typedef int (__stdcall *fp_skFontBold)();
typedef int (__stdcall *fp_skFontDlg)();
typedef int (__stdcall *fp_skButtonImage)(HWND,char*,int,int,int,int);
typedef int (__stdcall *fp_skBorder)(HWND,int,int,int,int,int,int);
typedef int (__stdcall *fp_skCreateToolTip)(HWND,char*);
typedef void (__stdcall *fp_skSetToolTipText)(HWND,char*);
typedef BSTR* (__stdcall *fp_skGetToolTipText)(HWND);
typedef int (__stdcall *fp_skPushButtonImage)(HWND,char*,char*,int,int,int,int,int,int);
typedef BSTR* (__stdcall *fp_skSkinFolder)();
typedef int (__stdcall *fp_skClockCtrl)(HWND,char*,int,int,int,int,int,int,int,int);
typedef void (__stdcall *fp_skSkinChildCtrl)(HWND,int);
typedef void (__stdcall *fp_skSkinWindowUpdate)(HWND,int);
typedef int (__stdcall *fp_skKnobGauge)(HWND,char*,int,int,int,int,int,int,int,int,int);
typedef void (__stdcall *fp_skGaugeSetMinMax)(HWND,int,int);
typedef void (__stdcall *fp_skGaugeGetMinMax)(HWND,int,int);
typedef void (__stdcall *fp_skGaugeSetPos)(HWND,int,int);
typedef int (__stdcall *fp_skGaugeGetPos)(HWND);
typedef int (__stdcall *fp_skARGB)(BYTE,BYTE,BYTE,BYTE);
typedef void (__stdcall *fp_skSetLabelFont)(HWND,char*,WORD,int,WORD);
typedef int (__stdcall *fp_skStaticImage)(HWND,char*,int,int,int,int,int);
typedef void (__stdcall *fp_skSetZorder)(HWND,int);
//==========================================
static fp_skInitEngine skInitEngine;
static fp_skSkinWindow skSkinWindow;
static fp_skSkinDisable skSkinDisable;
static fp_skSkinEnable skSkinEnable;
static fp_skAuthor skAuthor;
static fp_skSetAnchorCtrl skSetAnchorCtrl;
static fp_skRedrawMenuBar skRedrawMenuBar;
static fp_skGetMenu skGetMenu;
static fp_skMenuContainer skMenuContainer;
static fp_skCreateDW skCreateDW;
static fp_skDestroyDW skDestroyDW;
static fp_skDialogAlert skDialogAlert;
static fp_skDialogError skDialogError;
static fp_skDialogInfo skDialogInfo;
static fp_skDialogYesNo skDialogYesNo;
static fp_skDialogInput skDialogInput;
static fp_skVersion skVersion;
static fp_skCaptionFont skCaptionFont;
static fp_skFont skFont;
static fp_skFontBold skFontBold;
static fp_skFontDlg skFontDlg;
static fp_skButtonImage skButtonImage;
static fp_skBorder skBorder;
static fp_skCreateToolTip skCreateToolTip;
static fp_skSetToolTipText skSetToolTipText;
static fp_skGetToolTipText skGetToolTipText;
static fp_skPushButtonImage skPushButtonImage;
static fp_skSkinFolder skSkinFolder;
static fp_skClockCtrl skClockCtrl;
static fp_skSkinChildCtrl skSkinChildCtrl;
static fp_skSkinWindowUpdate skSkinWindowUpdate;
static fp_skKnobGauge skKnobGauge;
static fp_skGaugeSetMinMax skGaugeSetMinMax;
static fp_skGaugeGetMinMax skGaugeGetMinMax;
static fp_skGaugeSetPos skGaugeSetPos;
static fp_skGaugeGetPos skGaugeGetPos;
static fp_skARGB skARGB;
static fp_skSetLabelFont skSetLabelFont;
static fp_skStaticImage skStaticImage;
static fp_skSetZorder skSetZorder;
int WinLIFT_Init()
{
    hWinLIFTDLL = LoadLibrary("WinLIFT.DLL");
    if (hWinLIFTDLL == 0)
        return -1;
    skInitEngine = (fp_skInitEngine)GetProcAddress(hWinLIFTDLL ,"skInitEngine");
    skSkinWindow = (fp_skSkinWindow)GetProcAddress(hWinLIFTDLL ,"skSkinWindow");
    skSkinDisable = (fp_skSkinDisable)GetProcAddress(hWinLIFTDLL ,"skSkinDisable");
    skSkinEnable = (fp_skSkinEnable)GetProcAddress(hWinLIFTDLL ,"skSkinEnable");
    skAuthor = (fp_skAuthor)GetProcAddress(hWinLIFTDLL ,"skAuthor");
    skSetAnchorCtrl = (fp_skSetAnchorCtrl)GetProcAddress(hWinLIFTDLL ,"skSetAnchorCtrl");
    skRedrawMenuBar = (fp_skRedrawMenuBar)GetProcAddress(hWinLIFTDLL ,"skRedrawMenuBar");
    skGetMenu = (fp_skGetMenu)GetProcAddress(hWinLIFTDLL ,"skGetMenu");
    skMenuContainer = (fp_skMenuContainer)GetProcAddress(hWinLIFTDLL ,"skMenuContainer");
    skCreateDW = (fp_skCreateDW)GetProcAddress(hWinLIFTDLL ,"skCreateDW");
    skDestroyDW = (fp_skDestroyDW)GetProcAddress(hWinLIFTDLL ,"skDestroyDW");
    skDialogAlert = (fp_skDialogAlert)GetProcAddress(hWinLIFTDLL ,"skDialogAlert");
    skDialogError = (fp_skDialogError)GetProcAddress(hWinLIFTDLL ,"skDialogError");
    skDialogInfo = (fp_skDialogInfo)GetProcAddress(hWinLIFTDLL ,"skDialogInfo");
    skDialogYesNo = (fp_skDialogYesNo)GetProcAddress(hWinLIFTDLL ,"skDialogYesNo");
    skDialogInput = (fp_skDialogInput)GetProcAddress(hWinLIFTDLL ,"skDialogInput");
    skVersion = (fp_skVersion)GetProcAddress(hWinLIFTDLL ,"skVersion");
    skCaptionFont = (fp_skCaptionFont)GetProcAddress(hWinLIFTDLL ,"skCaptionFont");
    skFont = (fp_skFont)GetProcAddress(hWinLIFTDLL ,"skFont");
    skFontBold = (fp_skFontBold)GetProcAddress(hWinLIFTDLL ,"skFontBold");
    skFontDlg = (fp_skFontDlg)GetProcAddress(hWinLIFTDLL ,"skFontDlg");
    skButtonImage = (fp_skButtonImage)GetProcAddress(hWinLIFTDLL ,"skButtonImage");
    skBorder = (fp_skBorder)GetProcAddress(hWinLIFTDLL ,"skBorder");
    skCreateToolTip = (fp_skCreateToolTip)GetProcAddress(hWinLIFTDLL ,"skCreateToolTip");
    skSetToolTipText = (fp_skSetToolTipText)GetProcAddress(hWinLIFTDLL ,"skSetToolTipText");
    skGetToolTipText = (fp_skGetToolTipText)GetProcAddress(hWinLIFTDLL ,"skGetToolTipText");
    skPushButtonImage = (fp_skPushButtonImage)GetProcAddress(hWinLIFTDLL ,"skPushButtonImage");
    skSkinFolder = (fp_skSkinFolder)GetProcAddress(hWinLIFTDLL ,"skSkinFolder");
    skClockCtrl = (fp_skClockCtrl)GetProcAddress(hWinLIFTDLL ,"skClockCtrl");
    skSkinChildCtrl = (fp_skSkinChildCtrl)GetProcAddress(hWinLIFTDLL ,"skSkinChildCtrl");
    skSkinWindowUpdate = (fp_skSkinWindowUpdate)GetProcAddress(hWinLIFTDLL ,"skSkinWindowUpdate");
    skKnobGauge = (fp_skKnobGauge)GetProcAddress(hWinLIFTDLL ,"skKnobGauge");
    skGaugeSetMinMax = (fp_skGaugeSetMinMax)GetProcAddress(hWinLIFTDLL ,"skGaugeSetMinMax");
    skGaugeGetMinMax = (fp_skGaugeGetMinMax)GetProcAddress(hWinLIFTDLL ,"skGaugeGetMinMax");
    skGaugeSetPos = (fp_skGaugeSetPos)GetProcAddress(hWinLIFTDLL ,"skGaugeSetPos");
    skGaugeGetPos = (fp_skGaugeGetPos)GetProcAddress(hWinLIFTDLL ,"skGaugeGetPos");
    skARGB = (fp_skARGB)GetProcAddress(hWinLIFTDLL ,"skARGB");
    skSetLabelFont = (fp_skSetLabelFont)GetProcAddress(hWinLIFTDLL ,"skSetLabelFont");
    skStaticImage = (fp_skStaticImage)GetProcAddress(hWinLIFTDLL ,"skStaticImage");
    skSetZorder = (fp_skSetZorder)GetProcAddress(hWinLIFTDLL ,"skSetZorder");
}



And This is the Bcx generated cpp file tweaked by my cppfixup utility.
Notice: MessageBox (GetActiveWindow(),(LPSTR)skVersion(),"",0);
skVersion above is declare as returning a BSTR*



// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 6.1.6 (2010/08/02)
//                 BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
//              Translated for compiling with a C++ Compiler
// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
//                    CPPFIXUP Ver: 2.0.25
//                       James C. Fuller
//                         08/13/10
// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
// *********************************************************************
#include <windows.h>    // Win32 Header File
#include <windowsx.h>   // Win32 Header File
#include <commctrl.h>   // Win32 Header File
#include <commdlg.h>    // Win32 Header File
#include <mmsystem.h>   // Win32 Header File
#include <shellapi.h>   // Win32 Header File
#include <shlobj.h>     // Win32 Header File
#include <richedit.h>   // Win32 Header File
#include <wchar.h>      // Win32 Header File
#include <objbase.h>    // Win32 Header File
#include <ocidl.h>      // Win32 Header File
#include <winuser.h>    // Win32 Header File
#include <olectl.h>     // Win32 Header File
#include <oaidl.h>      // Win32 Header File
#include <ole2.h>       // Win32 Header File
#include <oleauto.h>    // Win32 Header File
#include <conio.h>
#include <direct.h>
#include <ctype.h>
#include <io.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>
#include <time.h>
#include <stdarg.h>
#include <process.h>
// *************************************************

// ***************************************************
// Compiler Defines
// ***************************************************

// C++
#if defined( __cplusplus )
  #define overloaded
  #define C_EXPORT EXTERN_C __declspec(dllexport)
  #define C_IMPORT EXTERN_C __declspec(dllimport)
#else
  #define C_EXPORT __declspec(dllexport)
  #define C_IMPORT __declspec(dllimport)
#endif




// ***************************************************

#include <iostream>
#include <sstream>
#include <string>
#include <typeinfo>
#include <stdexcept>
class BadConversion : public std::runtime_error {
public:
BadConversion(std::string const& s)
: std::runtime_error(s)
{ }
};
template<typename T>
inline std::string _str(T const& x)
{
std::ostringstream o;
if (!(o << x))
throw BadConversion(std::string("_str(")
+ typeid(x).name() + ")");
return o.str();
}

// ***************************************************

#include "C:\RadAsm3\Bcx3264\Projects\PBHP\wl.h"


#if !defined( __LCC__ )
// *************************************************
// Instruct Linker to Search Object/Import Libraries
// *************************************************
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"advapi32.lib")
#pragma comment(lib,"winspool.lib")
#pragma comment(lib,"shell32.lib")
#pragma comment(lib,"ole32.lib")
#pragma comment(lib,"oleaut32.lib")
#pragma comment(lib,"uuid.lib")
#pragma comment(lib,"odbc32.lib")
#pragma comment(lib,"odbccp32.lib")
#pragma comment(lib,"winmm.lib")
#pragma comment(lib,"comdlg32.lib")
#pragma comment(lib,"imagehlp.lib")
#pragma comment(lib,"version.lib")
#else
#pragma lib <winspool.lib>
#pragma lib <shell32.lib>
#pragma lib <ole32.lib>
#pragma lib <oleaut32.lib>
#pragma lib <uuid.lib>
#pragma lib <odbc32.lib>
#pragma lib <odbccp32.lib>
#pragma lib <winmm.lib>
#pragma lib <imagehlp.lib>
#pragma lib <version.lib>
// *************************************************
// End of Object/Import Libraries To Search
// *************************************************
#endif
//               Standard Macros
// *************************************************
#define DefaultFont ((BcxFont==0)?GetStockObject(DEFAULT_GUI_FONT):BcxFont)
// *************************************************
//               User Prototypes

// *************************************************
//            User Defined Constants
// *************************************************

#define IDD_DLG1 1000
#define IDC_GRP1 1001
#define IDC_BTN_CANCEL 1004
#define IDC_CHK1 1002
#define IDC_CHK2 1003
#define IDC_CHK3 1005
#define IDC_GRP2 1006
#define IDC_RBN1 1007
#define IDC_RBN2 1008
#define IDC_RBN3 1009
#define IDC_GRP3 1010
#define IDC_RBN4 1011
#define IDC_RBN5 1012
#define IDC_RBN6 1013
#define IDC_BTN_VER 1014
#define MYMSG WM_USER +100

// *************************************************

int     WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
LRESULT CALLBACK InputBox (HWND, UINT, WPARAM, LPARAM);


// *************************************************
//            User Global Initialized Arrays
// *************************************************


using namespace std;
BSTR PbString(char* stemp){return(SysAllocStringByteLen(stemp,strlen(stemp)));}

// *************************************************
//                 Runtime Functions
// *************************************************


// ************************************
//       User Subs and Functions
// ************************************


int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
{
   int      rv;
  rv=WinLIFT_Init();
  DialogBox(hInst,MAKEINTRESOURCE(1000),0,(DLGPROC)InputBox);
  return 0;
}


LRESULT CALLBACK InputBox (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
  for(;;)
  {
    if(Msg==WM_INITDIALOG)
      {
        if(skInitEngine("Glass.sks",""))
          {
            skSkinWindow(hWnd,"");
          }
        SetFocus(GetDlgItem(hWnd,IDC_BTN_CANCEL));
        break;
      }
    if(Msg==WM_COMMAND)
      {
        for(;;)
        {
          if(LOWORD(wParam)==IDC_BTN_VER)
            {
              MessageBox (GetActiveWindow(),(LPSTR)skVersion(),"",0);
              break;
            }
          if(LOWORD(wParam)==IDC_BTN_CANCEL)
            {
              EndDialog(hWnd,0);
            }
          break;
        }
        break;
      }
    if(Msg==WM_CLOSE)
      {
        EndDialog(hWnd,0);
        PostQuitMessage(0);
      }
    break;
  }
  return 0;
}



Patrice Terrier

James,

Thank you for sharing what you have learned with us!

I choose myself Visual Studio, because i am also a C# programmer, and because VS is the widest market for a third party addon provider.
I have done the same translation for WinDev several years ago, and WinDev itself is also written in C and C++ with Visual Studio.

I have never been interrested by Linux, because my work is tied close to the core Windows API.

QuoteI am confused on the approach you took on calling the dll functions
This is because i want  my encapsulation to use C++ string rather than ASCIIZ, but in essence they work the same.
However i must say that yours is easier  ;)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com