ObjReader Community

GDImage => The concept => Topic started by: Patrice Terrier on June 03, 2023, 08:45:28 am

Title: Tutor_01 (C++ VS2022 GDImage64 tutorial)
Post by: Patrice Terrier on June 03, 2023, 08:45:28 am
First post of a series, translated from the "WinDev tutorial",
to explain the use of GDImage64 in procedural* programming mode with Visual Studio 2022.

About Tutor_01
This is a GDImage "Hello World" project, based on "Programming Windows (http://www.objreader.com/index.php?topic=403.msg6336#msg6336)" by Charles Petzold.

All the child controls are created in the CreateControls() procedure.
Among them, CreateWindowExW(0, GDImageClassName, Resource((WCHAR*) L"paintbrush.png"), ...), is the one used by every GDImage container.
Resource((WCHAR*) L"paintbrush.png"), means use this image to paint the background of the control, it works like the desktop wallpaper background in Windows.

If the size of the image is larger that the window, then scrollbars are used to move the content.
This is shown in context when you press the "Capture screen" button,
and GDImageCaptureScreen() is the code that performs the capture.

You can also use a gradient to paint the background with
        // Use a GDImage gradient color to paint the background
        ZI_SetProperty(hCtrl, ZI_GradientTop, ZD_ARGB(255, 0,0,64));
        ZI_SetProperty(hCtrl, ZI_GradientBottom, ZD_ARGB(255, 0,240,255));

So far the Status Bar is not used.

All child controls are anchored within the main window using the ZI_SetAnchorMode API, and the appropriate ANCHOR_PROPERTY.

Last but not least,
the size of the standalone binary EXE is only 15 Kb.

(http://www.objreader.com/download/images/Tutor_01.jpg)
   
* procedural programming mode, is based on direct use of the FLAT API (Windows SDK) that is the core meat of the OS.
Title: Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
Post by: Shao Voon Wong on June 20, 2023, 01:37:59 pm
Quote
Among them, CreateWindowExW(0, GDImageClassName, Resource((WCHAR*) L"paintbrush.png"), ...), is the one used by every GDImage container.
Resource((WCHAR*) L"paintbrush.png"), means use this image to paint the background of the control, it works like the desktop wallpaper background in Windows.

You hack the WindowName to load an image as a background. Is there a way to specify a starting coordinate to display the image?
Title: Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
Post by: Patrice Terrier on June 20, 2023, 02:04:58 pm
The image background is a specific case, it is used to paint the whole background, rather than using a gradient.
none of the ZOBJECT properties can be used with it.
The only thing you can do is to flatten all or some of the sprites onto it, and save the resulting image as a new one.

To put an image at a specific location, use it as a sprite image, and keep it at the bottom of the z-order.
BTW I made a small change into the GDImage z-order function that is now using a rewritten quick sort under the hood.
That is GDImage version 7.11, that will be provided in the next coming carousel Tutor_06.

A sprite image could be scalled, rotated, alphablended, mirrored, cloned, etc.
Title: Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
Post by: Shao Voon Wong on June 24, 2023, 07:19:56 am
I see TCLib.LIB in every tutorial project folder. What is it used for? Where is its header file for calling its functions?
Title: Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
Post by: Patrice Terrier on June 24, 2023, 09:47:35 am
TCLIB.dll is an acronym fot Tiny C Library, it is written in pure C.
It is a replacement for the MS C Runtime to reduce program size, without using a compressor.

More about this, in Frederick Harris's section.
http://www.objreader.com/index.php?topic=369.msg6200#msg6200