Recent Posts

Pages: [1] 2 3 ... 10
64-bit SDK programming / Re: zTrace version 3.00
« Last post by Patrice Terrier on April 26, 2017, 03:28:22 pm »
The first post of this thread has been updated with a new version.

delete [] SelItem;
was unexpectedly missing from the case IDM_Print

New menu option: "Use Unicode in zDebug.txt"
to switch between ANSI or UNICODE
in case of ANSI, a UTF-8 BOM header is now being used.
UTF-8 BOM is a sequence of bytes (EF BB BF) that allows the reader to identify a file as being encoded in UTF-8.

Thanks to Andrey Unis who reported these to me.
64-bit SDK programming / Re: zTrace version 3.00
« Last post by Patrice Terrier on April 26, 2017, 08:58:41 am »
from Andrey Unis

By the way with only 14Kb, it could be used to debug any unicode 64-bit application...
Can make 11kb...
By the way, there are few mistakes...
function zDebug() includes NUL characters to log file
WideCharToMultiByte(CP_ACP, 0, sMessage, -1, buffer, BufferSize - 1, 0, 0);
(but better remake this function to support unicode chars (for example chinese language))

function ToolProc()
Code: [Select]
         MoveMemory(&pMM, (MINMAXINFO*) lParam, sizeof(pMM));
         SetRect(&rc, 0, 0, MIN_WIDTH, MIN_HEIGHT);
         AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);  // Adjust Window To True Requested Size
         pMM.ptMinTrackSize.x = rc.right;
         pMM.ptMinTrackSize.y = rc.bottom;
Code: [Select]
SetRect(&rc, 0, 0, MIN_WIDTH, MIN_HEIGHT);
AdjustWindowRectEx(&rc, WND_Style, FALSE, WND_ExStyle);  // Adjust Window To True Requested Size
((LPMINMAXINFO)lParam)->ptMinTrackSize.x = rc.right;
((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rc.bottom;

case IDM_Print:
  long* SelItem = new long[nSelItems];
memory leak, missed: delete [] SelItem ;

my variant (11kb) attached
64-bit SDK programming / Re: Boing64 (OpenGL layered animation)
« Last post by Patrice Terrier on April 25, 2017, 01:48:08 pm »
The zip file attached to the first post has been updated, to better show the mixing of an image and 3D OpenGL altogether (see RenderAnimation).
64-bit SDK programming / Boing64 (OpenGL layered animation)
« Last post by Patrice Terrier on April 24, 2017, 03:44:16 pm »
Do you remember that?

The AMIGA Boing Ball, was a mythical object in the computer industry created during a night at the 1984 CES by Dale Luck and R. J. Mical.

This reworked 64-bit version is only 19 Kb in size including the icon resource.
It is using the same concept exposed in the T-Rex animation posted here:
except that the multi-frame animation has been replaced by a real 3D object.

It uses a popup transparent layered window to render the sphere animation with OpenGL.
Not much to say about the C++ source code, that should be self explanatory for those familiar with the low level procedural SDK programming style.

RenderAnimation is the masterpiece where the Amiga logo and the OpenGL 3D sphere are mixed together into the same DC using DrawAndSetupAlphaChannel.

Code: [Select]
void RenderAnimation(IN HWND hWnd) {
    RECT rw = { 0 };
    BLENDFUNCTION bf = { 0 };
    POINT lp = { 0 }, ptSrc = { 0 };
    SIZEL lpSize = { 0 };

    LONG_PTR graphics = 0, imgAttr = 0, lpCallback = 0, callbackdata = 0;

    static long imgW, imgH, xDir, yDir;

    GetWindowRect(hWnd, &rw); = rw.right - rw.left; = rw.bottom -;
    lp.x = rw.left; lp.y =;

    HDC DesktopDC = GetDC(0);

    // Create our memory DC
    HDC hMemDC = CreateCompatibleDC(DesktopDC);
    HBITMAP hBmp = CreateDIB(DesktopDC,,, 32);
    if (hBmp) {
        SelectObject(hMemDC, hBmp);

        if (gP.shadow == 0) {
            WCHAR szFile[MAX_PATH] = { 0 };
            Path_Combine(szFile, EXEresource(), L"amiga.png");
            GdipLoadImageFromFile(szFile, gP.shadow);
            if (gP.shadow) { GetImageSize(gP.shadow, imgW, imgH); }

        // Draw the OpenGL scene
        wglMakeCurrent(gP.gldc, gP.glrc);
        DrawAndSetupAlphaChannel(hMemDC, -13, -14);

        if (gP.shadow) {
            if (GdipCreateFromHDC(hMemDC, graphics) == 0) {
                GdipSetInterpolationMode(graphics, 2);
                GdipDrawImageRectRectI(graphics, gP.shadow, 1, 14, imgW, imgH, 0, 0, imgW, imgH, 2, imgAttr, lpCallback, callbackdata);

        // Update the layered window
        bf.BlendOp             = AC_SRC_OVER;
        bf.BlendFlags          = 0;
        bf.AlphaFormat         = AC_SRC_ALPHA; // Use source alpha
        bf.SourceConstantAlpha = 255;
        UpdateLayeredWindow (hWnd, DesktopDC, &lp, &lpSize, hMemDC, &ptSrc, 0, &bf, ULW_ALPHA);


        // Move the layered window around the screen
        long PlayIt = 0;
        if (xDir == 0) { xDir = MOVE_STEP; yDir = MOVE_STEP; }
        if (xDir > 0) {
            if (gP.x + FRAME_SizeX - 21 > GetSystemMetrics(SM_CXSCREEN)) { xDir = -xDir; PlayIt = -1; }
        } else {
            if (gP.x < 0) { xDir = -xDir; PlayIt = -1; }
        if (yDir > 0) {
            if (gP.y + FRAME_SizeY - 21 > GetSystemMetrics(SM_CYSCREEN)) { yDir = -yDir; PlayIt = -1; }
        } else {
            if (gP.y < 0) { yDir = -yDir; PlayIt = -1; }
        if (PlayIt) { PlayWav(); }
        gP.x += xDir; gP.y += yDir;
        MoveWindow(hWnd, gP.x, gP.y, FRAME_SizeX, FRAME_SizeY + LOGO_SizeY, 0);

    ReleaseDC(0, DesktopDC);

To stop the demo, catch the ball and press the ESCAPE key. Or shut it down from the task bar.

Nostalgia of my eighties!  :)

64-bit SDK programming / zTrace version 3.00
« Last post by Patrice Terrier on April 18, 2017, 07:00:57 pm »
zTrace 3.00 (for 64-bit only)

This Visual Studio 2017 community project, has been totaly reworked to reduce the size down from 91 to 14 Kb.
(with the same technic used to produce the tiny MBox64 OpenGL visual plugins.)

zTrace is a small DLL utility to display debugging information into a popup window tool, and/or a text file.
It uses a distinct thread to work in parallel of the current application you want to debug.

zTrace is very useful at development time to check whether a program operates properly.
It has been modeled onto the WinDev's Trace API, the original Win32 version was written in PowerBASIC.

I first wrote zTrace to debug my addon graphic DLL tools, but it works also very well with any 32-bit or 64-bit EXE.
When i took the decision to convert WinLIFT and GDImage to C++, it was the first on my list, because i couldn't develop anymore without it.

zTrace uses exclusively the core flat API, that is the only common denominator to all the languages i use, and the only way to get rid of extra dependencies.
The source code is provided in pure SDK coding style like documented into Charles Petzold 5th edition (the SDK coder Bible).

zTrace is UNICODE based.

Syntax to use:
zTrace(L"Wide String Information")

Parameter detail:
one single unicode (WCHAR) string, holding the information to display in the trace window.

Trace window:
The information passed as parameter is displayed on the next line of the zTrace window.
The trace window is automatically opened when zTrace is called, by default, this window is opened at the top left corner of the screen.
The zTrace window shuts down automatically when you close the application being debugged.

zDebug.txt report:
Works exactly like the zTrace window, except that the information is written to a text file.
The report is automatically created when zDebug is called, it is saved into the same folder than the debugged application.
zDebug can be used alone or combined with zTrace (when the option is checked in the popup menu).
zDebug is very handy when the debugged application shuts down unexpectedly or when the application as a short life duration, that won't give you enough time to read what is written in the zTrace window.
A new fresh zDebug.txt is created each time you start a new zDebug session.

Contextual popup menu (right mouse click on the trace window):
"Use horizontal scrollbar", show or hide the horizontal scrollbar.
"Send selection to printer", print the selected lines (or the whole list when none).
"Copy selection to clipboard", copy the selected lines (or the whole list when none) to clipboard.
"Clear content", clear the content of the Trace window.
"Trace window TopMost", open the Trace window on top of all the other windows (including the windows from the other applications).
"Create zDebug.txt report", the zDebug.txt report is created into the debugged application's folder.
"Save window coordinates", store the size and position of the zTrace window for the next session.

Screen shot:

Helper function, for EXPLICIT linking:
Code: [Select]
#define long_proc typedef long (__stdcall *zProc)

long zTrace(IN WCHAR* sPtr) {
    long nRet = 0;
    static HMODULE hDll;
    if (hDll == 0) {
        if (sizeof(LONG_PTR) == 8) {
            hDll = LoadLibrary(L"zTrace64");;
        else {
            hDll = LoadLibrary(L"zTrace32");
    if (hDll) {
        static zProc hProc;
        if (hProc == 0) { hProc = (zProc)GetProcAddress(hDll, "zTrace"); }
        if (hProc) { nRet = hProc(sPtr); }
    return nRet;

I want to say thank you to Fred and James for letting me know how to reduce drastically the size of a 64-bit application.

Settings used to create this tiny 14 Kb 64-bit DLL

zTrace Property Pages
The calling Convention for 64-bit is always using __fastcall (/Gr).
And in 64-bit no need to use a .def file to avoid the decorated names.

Include + Pragma
Code: [Select]
#include <windows.h>
#include "..\TCLib\Strings.cpp"

#pragma warning(disable: 4996) // remove Unsafe notifications
#pragma warning(disable: 4312) // remove warning C4312: 'type cast': conversion from 'long' to 'HMENU' of greater size

See it here:

delete [] SelItem;
was unexpectedly missing from the case IDM_Print

New menu option: "Use Unicode in zDebug.txt"
to switch between ANSI or UNICODE
in case of ANSI, a UTF-8 BOM header is now being used.
UTF-8 BOM is a sequence of bytes (EF BB BF) that allows the reader to identify a file as being encoded in UTF-8.
64-bit SDK programming / Re: MIDI Piano
« Last post by Patrice Terrier on April 18, 2017, 11:00:54 am »
I have your versions of MIDIpiano working on both WinDev 21 and Visual Studio 2017. They are an excellent tutorial between PB, C and P-Code.
Chris Maher

You are right, the core API SDK syntax is the same on all of them, this is the only common denominator understood by all programming languages.
And that is the only way to { easily } switch between all of them.  8)
64-bit SDK programming / MIDI Piano (skinned version)
« Last post by Patrice Terrier on April 16, 2017, 04:52:47 pm »
This is the skinned version, the main EXE size is only 36 Kb (almost 1/3 of the original PB's 32-bit version).

If you want to disable the skin engine, just REM out the lines shown below in blue.

        if (skInitEngine (L"Reader.sks", L"")) {               // REM out these 2 lines if you want
            if (skSkinWindow(gP.hMain, (WCHAR*) SYSTOOLTIP)) { // to disable the WinLIFT skin engine.

                // Show the main window
                ShowWindow(gP.hMain, nCmdShow);

                while (GetMessage(&msg, NULL, 0, 0)) {
WIP / The Abyss visual plugin project (VS 2017)
« Last post by Patrice Terrier on April 07, 2017, 05:11:15 pm »

This OpenGL Visual Studio 2017 community project is for you, to be used with MBox64  :)

64-bit SDK programming / Audio capture
« Last post by Patrice Terrier on April 06, 2017, 02:29:35 pm »
Audio capture

C++ 64-bit Visual Studio community 2017 project,
to capture in stereo mix mode any sound playing on a multiplex audio card.

For the best audio quality, you must setup the record mode of the audio card in "stereo mix", and disable the microphone.

More about this on this link

How to use AudioCap :
1 - Start AudioCap.
2 - Start playing a movie (with a sound track) or a local or internet audio file (streaming).
3 - Press the [Start capture] button, to see the oscilloscope PCM WIMDATA curve.
4 - Check "Capture to Wave" if you want to create the "capture.wav", or check "Monitoring only" if you want to see only the peak level.
WIP / Re: Graphics Container Style
« Last post by Emil Weiss on April 03, 2017, 08:01:43 pm »
What do you have in your GraphicsProc callback?


Code: [Select]
function GraphicsProc(WinHandle: HWND; Msg: UINT; wP: WParam; lP: LParam): longint; stdcall;

  result := DefWindowProc(WinHandle, Msg, wP, lP);

if use AC_SRC_ALPHA Blending no longer work

without i have a White Background.
PngAnim work fine with AlphaBlend on W7 to.

only what i can do draw Gradient after Alphablend so the White Background is ownerdraw
Code: [Select]
UseBackColor := MakeColor(32, 0, 100, 128);
GDIP_DrawGradientVertical(hTempDC, 1, 1, rc.Right, rc.Bottom, UseBackColor, UseBackColor);

that work.. i think is not the right way.
Changes the colors of the Images.

Pages: [1] 2 3 ... 10