• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

SLIDE - GDImage 64-bit

Started by Patrice Terrier, May 10, 2013, 09:02:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

GDImage 64-bit SLIDE project

Source code:

#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <bitset>
using namespace std;
#include <Commctrl.h>

#pragma comment(lib, "D:\\VS2010\\GDImage64.lib")
#pragma comment(lib, "D:\\VS2010\\GDImage32.lib")
#include "GDImage.h"

//Apply WinXP theme
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#define long_proc typedef long (__stdcall *zProc)

#define ID_CTRL          101
#define ID_START_SHOW    102
#define ID_DECR          103
#define ID_PAUSE         104
#define ID_PLAY          105
#define ID_INCR          106
#define ID_STOP_SHOW     107

const wchar_t  *BUTTON = L"BUTTON";

// Global variable
HINSTANCE g_hInst; // Current instance

// Declaration of the functions being used in this module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);


int WINAPI wWinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPTSTR lpCmdLine,
                    int nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // Declaration of local variables
    MSG msg;
    int nRet = 0;
    int IsInitialized = 0;
    WNDCLASSEX wcx;
    WCHAR szWindowClass[] = L"win32app";
    wstring sCaption;
    sCaption = L"SLIDE - GDImage ";
    if (sizeof(LONG_PTR) == 8) {
        sCaption += L"64-bit"; }
    else {
        sCaption += L"32-bit";
    }

    // Register the main window class
    wcx.cbSize = sizeof(WNDCLASSEX);
    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       = wcx.hIcon;
        if (RegisterClassEx(&wcx)) { IsInitialized = -1; }
     }

     if (IsInitialized) {

        nRet = ZI_LoadDLL (L"");

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

        UINT dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
        UINT dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
        RECT rc;
        SetRect(&rc, 0, 0, 740, 550);
        AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);    // Adjust Window To True Requested Size
        int x = max((GetSystemMetrics(SM_CXSCREEN) - rc.right - rc.left) / 2, 0);
        int y = max((GetSystemMetrics(SM_CYSCREEN) - rc.bottom - rc.top) / 2, 0);
        HWND hWnd = CreateWindowEx(
                    dwExStyle,                      // Optional window styles.
                    szWindowClass,                  // Window class
                    (WCHAR*) sCaption.c_str(),      // Window text
                    dwStyle,                        // Window style
                    x, y, rc.right - rc.left, rc.bottom - rc.top,
                    NULL,                           // Parent window   
                    NULL,                           // Menu
                    hInstance,                      // Instance handle
                    NULL                            // Additional application data
                    );
   
        if (hWnd) {
   
           ShowWindow(hWnd, nCmdShow);
           UpdateWindow(hWnd);

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

     }
   
     return nRet;
}

HFONT zDefaultFont() {
    static HFONT hDefault;
    if (hDefault == 0) { hDefault = (HFONT) GetStockObject(ANSI_VAR_FONT); }
    return hDefault;
}

void zSetCTLFont(IN HWND hCtrl, IN HFONT hFont) {
    SendMessage(hCtrl, WM_SETFONT, (WPARAM) hFont, 0);
}

long RND (IN long nMin, IN long nMax) {
     return ((rand() * (nMax - nMin + 1) / RAND_MAX)) + nMin;
}

// Main winproc
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent; long K, imgW, imgH, UB; BYTE PlayInLoopMode;
    PAINTSTRUCT ps; RECT rc; HDC hdc; HWND hCtrl;
    WCHAR sFullName[MAX_PATH] = {0};
    NMHDR* nmh;
    ZSLIDESHOW* PlayList;

    switch (uMsg) {
    case WM_CREATE:
         // Create button "START"
         CreateWindowEx(0, BUTTON, L"START", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
                        740 - (10 + 150 + 6), 10, 152, 22, hWnd, (HMENU) ID_START_SHOW, zInstance(), NULL);
         zSetCTLFont(GetDlgItem(hWnd, ID_START_SHOW), zDefaultFont());
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_START_SHOW), ANCHOR_RIGHT);

         // Create button "DECR"
         CreateWindowEx(0, BUTTON, L"<<", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED,
                       740 - (10 + 150 + 6), 10 + (22 + 5) * 1, 24, 22, hWnd, (HMENU) ID_DECR, zInstance(), NULL);
         zSetCTLFont(GetDlgItem(hWnd, ID_DECR), zDefaultFont());
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_DECR), ANCHOR_RIGHT);

         // Create button "PLAY"
         CreateWindowEx(0, BUTTON, L"PLAY", WS_CHILD | WS_TABSTOP | WS_DISABLED,
                        740 - (10 + 150 + 6) + 28, 10 + (22 + 5) * 1, 96, 22, hWnd, (HMENU) ID_PLAY, zInstance(), NULL);
         zSetCTLFont(GetDlgItem(hWnd, ID_PLAY), zDefaultFont());
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_PLAY), ANCHOR_RIGHT);

         // Create button "PAUSE"
         CreateWindowEx(0, BUTTON, L"PAUSE", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED,
                        740 - (10 + 150 + 6) + 28, 10 + (22 + 5) * 1, 96, 22, hWnd, (HMENU)ID_PAUSE, zInstance(), NULL);
         zSetCTLFont(GetDlgItem(hWnd, ID_PAUSE), zDefaultFont());
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_PAUSE), ANCHOR_RIGHT);

         // Create button "INCR"
         CreateWindowEx(0, BUTTON, L">>", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED,
                        740 - (10 + 150 + 6) + 128, 10 + (22 + 5) * 1, 24, 22, hWnd, (HMENU) ID_INCR, zInstance(), NULL);
         zSetCTLFont(GetDlgItem(hWnd, ID_INCR), zDefaultFont());
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_INCR), ANCHOR_RIGHT);

         // Create button "STOP"
         CreateWindowEx(0, BUTTON, L"STOP", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
                          740 - (10 + 150 + 6), 10 + (22 + 5) * 2, 152, 22, hWnd, (HMENU) ID_STOP_SHOW, zInstance(), NULL);
         zSetCTLFont(GetDlgItem(hWnd, ID_STOP_SHOW), zDefaultFont());
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_STOP_SHOW), ANCHOR_RIGHT);

         // ******************************************************************************
         // Helper function to create A GDImage control (with automatic scrollbar support)
         // ------------------------------------------------------------------------------
         ZI_CreateWindow(hWnd, 10, 10, 740 - (10 + 10 + 150 + 10 + 10), 550 - (10 * 2), (HMENU) ID_CTRL);
         wcscpy_s(sFullName, L"038.jpg");
         ZI_SetTiledBackground(GetDlgItem(hWnd, ID_CTRL), ZI_CreateBitmapFromFile(sFullName, imgW, imgH));
         ZI_SetAnchorMode(GetDlgItem(hWnd, ID_CTRL), ANCHOR_HEIGHT_WIDTH);
         break;

    case WM_NOTIFY:
         nmh = (NMHDR*) lParam;
         if (nmh->idFrom == ID_CTRL) {
             if (nmh->code == NM_LASTSLIDE) {
                MessageBox(0, L"End of slide show notification.", L"Slide", MB_OK);
             }
         }
         break;

    case WM_COMMAND:
         wmId    = LOWORD(wParam);
         wmEvent = HIWORD(wParam);
         // Process menu command
         switch (wmId) {

         case ID_START_SHOW:
              if (IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) == 0) {
                 EnableWindow(GetDlgItem(hWnd, ID_DECR), TRUE);
                 EnableWindow(GetDlgItem(hWnd, ID_PLAY), TRUE);
                 EnableWindow(GetDlgItem(hWnd, ID_PAUSE), TRUE);
                 EnableWindow(GetDlgItem(hWnd, ID_INCR), TRUE);
              }
              hCtrl = GetDlgItem(hWnd, ID_CTRL);
              UB = 3 * (ZE_EFFECT_MAX + 1);
              PlayList = new ZSLIDESHOW[UB];
              memset(PlayList, 0, sizeof(ZSLIDESHOW) * UB); // Fill up the whole new array with nulls (to mimic what PB's does)
              K = 0;
              for (long Effect = ZE_EFFECT_MIN; Effect <= ZE_EFFECT_MAX; ++Effect) {
                  wcscpy_s(PlayList[K].fullname, L"avalon.jpg"); zCheckName(PlayList[K].fullname);
                  PlayList[K].delay     = 2000;
                  PlayList[K].grain     = 1;           // <-- Use a larger grain on slow computer.
                  PlayList[K].effect    = (short) Effect;

                  ++K;
                  wcscpy_s(PlayList[K].fullname, L"genus.jpg"); zCheckName(PlayList[K].fullname);
                  PlayList[K].delay     = 2000;
                  PlayList[K].grain     = 2;     // <-- Use a larger grain on slow computer.
                  PlayList[K].effect    = (short) Effect;
                  wcscpy_s(PlayList[K].legend, L"GDImage Slide Show");
                  wcscpy_s(PlayList[K].fontname, L"Times New Roman");
                  PlayList[K].fontsize  = 40;
                  PlayList[K].fontcolor = ZD_ColorARGB(32, RGB(255,255,255));
                  PlayList[K].shadow    = 0;          // <-- Font shadow offset
                  PlayList[K].location  = (BYTE) RND(ZE_TXT_TOP_LEFT, ZE_TXT_BOTTOM_RIGHT);

                  ++K;
                  wcscpy_s(PlayList[K].fullname, L"mask.png"); zCheckName(PlayList[K].fullname);
                  PlayList[K].delay     = 2000;
                  PlayList[K].grain     = 1;           // <-- Use a larger grain on slow computer.
                  PlayList[K].effect    = (short) Effect;
                  PlayList[K].backcolor = ZD_ColorARGB(255, RGB(128,0,0)); // note: slide show use only 24-bit

                  ++K;
              }

              PlayInLoopMode = 0;

              ZI_SlideAnimate(hCtrl, &PlayList[0], UB, PlayInLoopMode);
              delete [] PlayList;
              break;

         case ID_DECR:
              ZI_SlidePlayDecrOrder();
              break;

         case ID_PAUSE:
              if (IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) ) {
                 EnableWindow(GetDlgItem(hWnd, ID_DECR), FALSE);
                 EnableWindow(GetDlgItem(hWnd, ID_INCR), FALSE);
              }
              ShowWindow(GetDlgItem(hWnd, ID_PAUSE), SW_HIDE);
              ShowWindow(GetDlgItem(hWnd, ID_PLAY), SW_SHOW);
              ZI_SlidePause();
              break;

         case ID_PLAY:
              if (IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) == 0 ) {
                 EnableWindow(GetDlgItem(hWnd, ID_DECR), TRUE);
                 EnableWindow(GetDlgItem(hWnd, ID_INCR), TRUE);
              }
              ShowWindow(GetDlgItem(hWnd, ID_PLAY), SW_HIDE);
              ShowWindow(GetDlgItem(hWnd, ID_PAUSE), SW_SHOW);
              ZI_SlidePlay();
              break;

         case ID_INCR:
              ZI_SlidePlayIncrOrder();
              break;
             
         case ID_STOP_SHOW:
              ZI_SlideStop();
              if (IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) ) {
                 EnableWindow(GetDlgItem(hWnd, ID_DECR), FALSE);
                 EnableWindow(GetDlgItem(hWnd, ID_PLAY), FALSE);
                 EnableWindow(GetDlgItem(hWnd, ID_PAUSE), FALSE);
                 EnableWindow(GetDlgItem(hWnd, ID_INCR), FALSE);
              }
              break;

         }
         return 0;

    case WM_PAINT:
         hdc = BeginPaint(hWnd, &ps);
         // TODO: process here the WM_PAINT message...
         GetClientRect (hWnd, &rc);
         ZI_GradientPaintDC(hdc, 0, 0, rc.right, rc.bottom, RGB(228,227,227), RGB(168,167,191));
         EndPaint(hWnd, &ps);
         return 0;

    case WM_DESTROY:
         PostQuitMessage(0);
         return 0;
    }
   
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James Klutho

Nice work Patrice.  I can not imagine the work you did porting your code to a new language.  My hat is off to you.

Jim

Patrice Terrier

QuoteI can not imagine the work you did porting your code to a new language.
Ask my wife, she calls me crazy  :P
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

Patrice,
  Good stuff!!
Are the lib files available so I can play a bit?

James

Patrice Terrier

James--

I shall post the header and the LIBs file later on, but there is still much debug work to do, this is the reason why i needed zTrace, and i am writing small examples to check each feature throughly, that's a long process for sure...

By the way i plan to post here a "PB to C/C++ pitfalls" to help those wanting to make the big jump.

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

Jean-Pierre Leroy

Hi Patrice,

I tried to run slide.exe but I get this message: MSVCP100.dll is missing ?

I'm using Windows7 64 bits.

Thanks. Jean-Pierre

Patrice Terrier

Jean Pierre--

Please download it again (from the first post), it is now compiled with the "Multithread (/MT)" switch, that should get rid of the VC run-time, at least i hope so ;)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Jean-Pierre Leroy

Thanks Patrice.

It works now without any VC run-time !

I don't know yet if I will do the big jump ... (why not I was used to program in C 25 years ago!) but for sure your "PB to C/C++ pitfalls" will be very useful for all of us.

Jean-Pierre

James C. Fuller

Patrice,
  I think your new GDImage dll's should be able to be used with other than standard c++.
Do you know anyone who uses 64bit delphi or FreePascal to try them?
I'm going to post on Hutch's site to see if anyone wants to try with 64bit asm :)

  GDImage64 worked fine with this bc9 port of Slide.
As I mentiond I am using cl from the Win7.1 SDK. No Visual Studio.
Attachment contains basic source, translated cpp source and exe.
James


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Clone of Patrice's Slide  GDImage64 demo
'Translated as a unicode app -u
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPPHDR
$ONEXIT "VC.BAT $FILE$ -m64 gui Release"
$NOMAIN
$HEADER
    #include "gdimage.h"
    #pragma comment(lib,"GDImage64.lib")
$HEADER
'==============================================================================
CONST ID_CTRL = 101
CONST ID_START_SHOW = 102
CONST ID_DECR = 103
CONST ID_PAUSE = 104
CONST ID_PLAY =  105
CONST ID_INCR = 106
CONST ID_STOP_SHOW = 107

Raw As const wchar_t Ptr BUTTON = L"BUTTON"
Raw As HINSTANCE g_hInst
'==============================================================================
Function WinMain()
   
    Local As MSG msg
    Local As Integer nRet,IsInitialized
    Local As WNDCLASSEX wcx
    Local As HANDLE hDll
   
    Raw As WCHAR szWindowClass[] = L"win64app"
    Raw As wstring sCaption = L"SLIDE - GDImage "
    If sizeof(LONG_PTR) = 8 Then
        sCaption+= L"64-bit"
    Else
        sCaption += L"32-bit"
    End If
    ' Register the main window class
    wcx.cbSize = sizeof(WNDCLASSEX)
    IsInitialized = GetClassInfoEx(hInst, szWindowClass, &wcx)
   
    If IsInitialized = 0 Then
        wcx.style         = CS_HREDRAW | CS_VREDRAW
        wcx.lpfnWndProc   = WndProc
        wcx.cbClsExtra    = 0
        wcx.cbWndExtra    = 0
        wcx.hInstance     = hInst
        wcx.hIcon         = LoadIcon(hInst, MAKEINTRESOURCE(IDI_APPLICATION))
        wcx.hCursor       = LoadCursor(NULL, IDC_ARROW)
        wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1)
        wcx.lpszMenuName  = NULL
        wcx.lpszClassName = szWindowClass
        wcx.hIconSm       = wcx.hIcon
        If RegisterClassEx(&wcx) Then
            IsInitialized = -1   
        End If
    End If
     
     If IsInitialized Then
         nRet = ZI_LoadDLL (L"")
         g_hInst = hInst
         Raw As UINT dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE
         Raw As UINT dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX
         Raw As RECT rc
         SetRect(&rc, 0, 0, 740, 550)
         AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle)    ' Adjust Window To True Requested Size
         Raw As int x = max((GetSystemMetrics(SM_CXSCREEN) - rc.right - rc.left) / 2, 0)
         Raw As int y = max((GetSystemMetrics(SM_CYSCREEN) - rc.bottom - rc.top) / 2, 0)
         Raw As HWND hWnd =     CreateWindowEx( _
                            dwExStyle, _                         'Optional window styles.
                            szWindowClass, _                     ' Window class
                            (WCHAR*) sCaption.c_str(), _         ' Window text
                            dwStyle, _                           ' Window style
                            x, y, rc.right - rc.left, rc.bottom - rc.top, _
                            NULL, _                               ' Parent window   
                            NULL, _                              ' Menu
                            hInst, _                             ' Instance handle
                            NULL _                               ' Additional application data
                            )
        If hWnd Then
            ShowWindow(hWnd, CmdShow)
            UpdateWindow(hWnd)
   
            While (GetMessage(&msg, NULL, 0, 0))
               TranslateMessage(&msg)
               DispatchMessage(&msg)
            Wend
            nRet = (int) msg.wParam
           
        End If
     End If

     Function = nRet
End Function
'==============================================================================
Function zDefaultFont() As HFONT
    static hDefault As HFONT
    If hDefault = 0 Then
        hDefault = (HFONT) GetStockObject(ANSI_VAR_FONT)
    End If
    Function = hDefault
End Function
'==============================================================================
Sub zSetCTLFont(hCtrl As HWND , hFont As HFONT)
    SendMessage(hCtrl, WM_SETFONT, (WPARAM) hFont, 0)
End Sub
'==============================================================================
'RND name changed to zRND to avoid bc9 name conflict
Function zRND (nMin As long, nMax As Long) As long
    Function = ((rand() * (nMax - nMin + 1) / RAND_MAX)) + nMin
End Function
'==============================================================================

CALLBACk Function WndProc()
    Raw As Integer wmId, wmEvent
    Raw As long K, imgW, imgH, UB
    Raw As BYTE PlayInLoopMode
    Raw As PAINTSTRUCT ps
    Raw As RECT rc
    Raw As HDC hdc
    Raw As HWND hCtrl
    Raw As WCHAR sFullName[MAX_PATH]={0}
    Raw As NMHDR Ptr nmh
    Raw As ZSLIDESHOW Ptr PlayList
   
    Select Case CBMSG
        Case WM_CREATE
            ' Create button "START"
            CreateWindowEx(0, BUTTON, L"START", WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                        740 - (10 + 150 + 6), 10, 152, 22, hWnd, (HMENU) ID_START_SHOW, zInstance(), NULL)
            zSetCTLFont(GetDlgItem(hWnd, ID_START_SHOW), zDefaultFont())
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_START_SHOW), ANCHOR_RIGHT)

            ' Create button "DECR"
            CreateWindowEx(0, BUTTON, L"<<", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED, _
                       740 - (10 + 150 + 6), 10 + (22 + 5) * 1, 24, 22, hWnd, (HMENU) ID_DECR, zInstance(), NULL)
            zSetCTLFont(GetDlgItem(hWnd, ID_DECR), zDefaultFont())
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_DECR), ANCHOR_RIGHT)
           
            ' Create button "PLAY"
            CreateWindowEx(0, BUTTON, L"PLAY", WS_CHILD | WS_TABSTOP | WS_DISABLED, _
                        740 - (10 + 150 + 6) + 28, 10 + (22 + 5) * 1, 96, 22, hWnd, (HMENU) ID_PLAY, zInstance(), NULL)
            zSetCTLFont(GetDlgItem(hWnd, ID_PLAY), zDefaultFont())
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_PLAY), ANCHOR_RIGHT)
           
            ' Create button "PAUSE"
            CreateWindowEx(0, BUTTON, L"PAUSE", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED, _
                        740 - (10 + 150 + 6) + 28, 10 + (22 + 5) * 1, 96, 22, hWnd, (HMENU)ID_PAUSE, zInstance(), NULL)
            zSetCTLFont(GetDlgItem(hWnd, ID_PAUSE), zDefaultFont())
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_PAUSE), ANCHOR_RIGHT)
           
            ' Create button "INCR"
            CreateWindowEx(0, BUTTON, L">>", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED, _
                        740 - (10 + 150 + 6) + 128, 10 + (22 + 5) * 1, 24, 22, hWnd, (HMENU) ID_INCR, zInstance(), NULL)
            zSetCTLFont(GetDlgItem(hWnd, ID_INCR), zDefaultFont())
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_INCR), ANCHOR_RIGHT)
           
            ' Create button "STOP"
            CreateWindowEx(0, BUTTON, L"STOP", WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                          740 - (10 + 150 + 6), 10 + (22 + 5) * 2, 152, 22, hWnd, (HMENU) ID_STOP_SHOW, zInstance(), NULL)
            zSetCTLFont(GetDlgItem(hWnd, ID_STOP_SHOW), zDefaultFont())
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_STOP_SHOW), ANCHOR_RIGHT)
           
            ' ******************************************************************************
            ' Helper function to create A GDImage control (with automatic scrollbar support)
            ' ------------------------------------------------------------------------------
            ZI_CreateWindow(hWnd, 10, 10, 740 - (10 + 10 + 150 + 10 + 10), 550 - (10 * 2), (HMENU) ID_CTRL)
            wcscpy_s(sFullName, L"038.jpg")
            ZI_SetTiledBackground(GetDlgItem(hWnd, ID_CTRL), ZI_CreateBitmapFromFile(sFullName, imgW, imgH))
            ZI_SetAnchorMode(GetDlgItem(hWnd, ID_CTRL), ANCHOR_HEIGHT_WIDTH)
           
        Case WM_NOTIFY
            nmh = (NMHDR*) lParam
            If nmh->idFrom = ID_CTRL Then
                If nmh->code = NM_LASTSLIDE Then
                    MessageBox(0, L"End of slide show notification.", L"Slide", MB_OK)
                End If
            End If
        Case WM_COMMAND
            wmId    = LOWORD(wParam) 'CBCTL
            wmEvent = HIWORD(wParam) 'CBCTLMSG
        '    Process menu command
            Select Case wmId
                Case ID_START_SHOW
                    If IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) = 0 Then
                        EnableWindow(GetDlgItem(hWnd, ID_DECR), TRUE)
                        EnableWindow(GetDlgItem(hWnd, ID_PLAY), TRUE)
                        EnableWindow(GetDlgItem(hWnd, ID_PAUSE), TRUE)
                        EnableWindow(GetDlgItem(hWnd, ID_INCR), TRUE)
                    End If
                    hCtrl = GetDlgItem(hWnd, ID_CTRL)
                    UB = 3 * (ZE_EFFECT_MAX + 1)
                    PlayList = new ZSLIDESHOW[UB]
                    memset(PlayList, 0, sizeof(ZSLIDESHOW) * UB) ' Fill up the whole new array with nulls (to mimic what PB's does)
                    K = 0
                    xFor long Effect = ZE_EFFECT_MIN WHILE Effect <= ZE_EFFECT_MAX BY ++Effect
                   
                        wcscpy_s(PlayList[K].fullname, L"avalon.jpg")
                        zCheckName(PlayList[K].fullname)
                        PlayList[K].delay     = 2000
                        PlayList[K].grain     = 1           ' <-- Use a larger grain on slow computer.
                        PlayList[K].effect    = (short) Effect
                       
                        ++K
                        wcscpy_s(PlayList[K].fullname, L"genus.jpg")
                        zCheckName(PlayList[K].fullname)
                        PlayList[K].delay     = 2000
                        PlayList[K].grain     = 2     ' <-- Use a larger grain on slow computer.
                        PlayList[K].effect    = (short) Effect
                        wcscpy_s(PlayList[K].legend, L"GDImage Slide Show")
                        wcscpy_s(PlayList[K].fontname, L"Times New Roman")
                        PlayList[K].fontsize  = 40
                        PlayList[K].fontcolor = ZD_ColorARGB(32, RGB(255,255,255))
                        PlayList[K].shadow    = 0          ' <-- Font shadow offset
                        PlayList[K].location  = (BYTE) zRND(ZE_TXT_TOP_LEFT, ZE_TXT_BOTTOM_RIGHT)

                        ++K
                        wcscpy_s(PlayList[K].fullname, L"mask.png")
                        zCheckName(PlayList[K].fullname)
                        PlayList[K].delay     = 2000
                        PlayList[K].grain     = 1           ' <-- Use a larger grain on slow computer.
                        PlayList[K].effect    = (short) Effect
                        PlayList[K].backcolor = ZD_ColorARGB(255, RGB(128,0,0)) ' note: slide show use only 24-bit
                       
                        ++K
                       
                    xNext
                   
                    PlayInLoopMode = 0
                    ZI_SlideAnimate(hCtrl, &PlayList[0], UB, PlayInLoopMode)
                    delete [] PlayList
                   
                Case ID_DECR
                      ZI_SlidePlayDecrOrder()
                     
                Case ID_PAUSE
                    If IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) Then
                        EnableWindow(GetDlgItem(hWnd, ID_DECR), FALSE)
                        EnableWindow(GetDlgItem(hWnd, ID_INCR), FALSE)
                    End If
                    ShowWindow(GetDlgItem(hWnd, ID_PAUSE), SW_HIDE)
                    ShowWindow(GetDlgItem(hWnd, ID_PLAY), SW_SHOW)
                    ZI_SlidePause()
                   
                Case ID_PLAY
                    If IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) = 0 Then
                        EnableWindow(GetDlgItem(hWnd, ID_DECR), TRUE)
                        EnableWindow(GetDlgItem(hWnd, ID_INCR), TRUE)
                    End If
                    ShowWindow(GetDlgItem(hWnd, ID_PLAY), SW_HIDE)
                    ShowWindow(GetDlgItem(hWnd, ID_PAUSE), SW_SHOW)
                    ZI_SlidePlay()
                   
                Case ID_INCR
                    ZI_SlidePlayIncrOrder()
               
                Case ID_STOP_SHOW
                    ZI_SlideStop()
                    If IsWindowEnabled(GetDlgItem(hWnd, ID_DECR)) Then
                        EnableWindow(GetDlgItem(hWnd, ID_DECR), FALSE)
                        EnableWindow(GetDlgItem(hWnd, ID_PLAY), FALSE)
                        EnableWindow(GetDlgItem(hWnd, ID_PAUSE), FALSE)
                        EnableWindow(GetDlgItem(hWnd, ID_INCR), FALSE)
                    End If   
            End Select
            Function = 0
        Case WM_PAINT
            hdc = BeginPaint(hWnd, &ps)
            ' TODO: process here the WM_PAINT message...
            GetClientRect (hWnd, &rc)
            ZI_GradientPaintDC(hdc, 0, 0, rc.right, rc.bottom, RGB(228,227,227), RGB(168,167,191))
            EndPaint(hWnd, &ps)
            Function = 0
               
        Case WM_DESTROY
            PostQuitMessage(0)
            Function = 0
           
    End Select
End Function


James C. Fuller

Patrice,
  I was able to compile my bc9Slide to a 64bit MinGW app with just a couple of minor changes using
the MinGwTDM compiler suite.

I could not locate the wcscpy_s function so I used wcscpy instead.

It also whined on the PropertyItem in the ZI_GetImageInfoProperty declare so I just commented it out.

It appears 64bit dlls do not need a  .lib aka .a for MingGW ?

James

Patrice Terrier

Yes, i find the creation of 64-bit DLL easier than 32-bit, for example, there is no need to use a .def file to export the functions correctly without mangled names.  8)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com