Author Topic: Tutor_13 (C++ VS2022 GDImage64 tutorial)  (Read 6062 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1996
    • zapsolution
Tutor_13 (C++ VS2022 GDImage64 tutorial)
« on: August 10, 2023, 03:14:09 pm »
Thirteenth post of a series, translated from the "WinDev and PowerBASIC",
to explain the use of GDImage64 in procedural* programming mode with Visual Studio 2022.

About Tutor_13
This tutor introduces the use of a vertical sprite selector to perform drag & drop onto the main graphic control.
It is using two distinct GDImage controls, the main that is transparent (DWM composited), and a vertical sprite selector.

Vertical selector
This is the same concept as the horizontal contact sheet used in Tutor_10, except that you have to use drag & drop to drop the selected sprite at a specific location onto the main graphic control.

Drag & drop
This one is using the CreateDropImage procedure to create a WS_EX_LAYERED window to drag the selected sprite to its destination.

Contextual popup menu
It is fired when you right click the mouse on a specific sprite to set up its properties.
The commands are:
Display next frame, in case of sprite multi-frame, switch to next one in loop mode.
Note: you can also double click on the sprite to achieve the same result.
Flip horizontally, as the name implies.
Flip vertically, as the name implies.
Rotate counter clock, as the name implies.
Rotate clockwise, as the name implies.
Move up, increase the z-order.
On top, on top of the z-order.
Move down, decrease the z-order.
On bottom, on bottom of the z-order.
Clone, duplicate the sprite.
Lock, lock/unlock the sprite (the menu icon shows the current state).
Delete, remove this sprite from the graphic control.

GDImage logo
The Resource(L"logo.png") is a fixed sprite that couldn't be moved around using the ZD_SetObjectLocked API.
It also use the ZD_SetObjectHidden state, that means it couldn't be detected, and in case of zoom control it is unaffected by the zoom factor.
It is transparent to mouse events, sent to the underlaying sprite(s) in order of appearance (z-order).

Extra goodies
// Remove the CS_DROPSHADOW effect from the popup menu
HHOOK HookMenu = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC) HookMenuProc, 0, GetCurrentThreadId());

This procedure allows you to customize the tooltip color.
void CreateToolTip(IN HWND hWnd) {
    if (IsWindow(hWnd)) {
        // Add tooltip support to the hWnd GDImage control.
        HWND hTooltip = ZI_CreateToolTip(hWnd, L"");
        if (hTooltip) {
            SetWindowTheme(hTooltip, L"", L""); // Theme must be disabled to use custom colors.
            SendMessage(hTooltip, TTM_SETTIPTEXTCOLOR, RGB(0,0,0), 0);
            SendMessage(hTooltip, TTM_SETTIPBKCOLOR, RGB(177,197,255), 0);

        }
    }
}


GDImage 7.15
Is an experimental version converted to VS2022, and designed specifically to run all the Tutor applications.


   
* procedural programming mode, is based on direct use of the FLAT API (Windows SDK) that is the core meat of the OS.
« Last Edit: August 10, 2023, 09:55:05 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)