Author Topic: Tutor_01 (C++ VS2022 GDImage64 tutorial)  (Read 4673 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Tutor_01 (C++ VS2022 GDImage64 tutorial)
« 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" 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.


   
* 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 18, 2023, 10:32:50 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Shao Voon Wong

  • Newbie
  • *
  • Posts: 12
Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
« Reply #1 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?

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
« Reply #2 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.
Patrice
(Always working with the latest Windows version available...)

Shao Voon Wong

  • Newbie
  • *
  • Posts: 12
Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
« Reply #3 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?

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Tutor_01 (C++ VS2022 GDImage64 tutorial)
« Reply #4 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
Patrice
(Always working with the latest Windows version available...)