Recent Posts

Pages: 1 ... 6 7 [8] 9 10
71
The concept / Tutor_04 (C++ VS2022 GDImage64 tutorial)
« Last post by Patrice Terrier on June 09, 2023, 09:38:40 am »
Fourth 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_04
This tutor introduces the use of WIDGET sprites.

A GDImage widget is a custom animation composed of several graphic components linked together to act as a single entity.
They can be anchored, locked or dragged around with the mouse or the arrow keys (not implemented in this demo).
 
The widgets are created in the GDImageCreateWidgets() procedure.
They are: Depth, Temperature, Water flow, Compass, Wind.

Using the WidgetDepth(...) as an example.
It is composed of 4 prites: IDS_DEPTHBACK, IDS_DEPTHCURSOR, IDS_DEPTHTEXT, IDS_DEPTHLABEL.
They are linked together using the ZD_SetObjectLinked(ObjID, Linked_To_This_ID) API
The first parameter is the current sprite ID, linked to second, that is the leading sprite ID.
The leading sprite itself, use the same ID for the two parameters.

Code: [Select]
hBitmap = ZI_CreateBitmapFromFile(Resource(L"Profondeur.png"), nW, nH);
nUseX = nX; nUseY = nY; nUseW = nW; nUseH = nH;
ZD_DrawBitmapToCtrl(hGDImageCtrl, nX, nY, hBitmap, ZD_ColorARGB(255, 0), IDS_DEPTHBACK, ZS_VISIBLE);
ZD_SetObjectLinked(IDS_DEPTHBACK, IDS_DEPTHBACK);

hBitmap = ZI_CreateBitmapFromFile(Resource(L"Bubble.png"), nW, nH);
ZD_DrawBitmapToCtrl(hGDImageCtrl, nBubbleX, nBubbleY, hBitmap, ZD_ColorARGB(255, 0), IDS_DEPTHCURSOR, ZS_VISIBLE);
ZD_SetObjectLinked(IDS_DEPTHCURSOR, IDS_DEPTHBACK);

Note: ZD_SetObjectLinked() let them act as a single entity, if you want to drag them around with the mouse.
If you want to keep them at a fixed location, then use the ZD_SetObjectLocked(...) API.

The GDImageRenderAnimation() procedure is used by the timer to update the widgets.
Calling WidgetDepth, WidgetTemperature, WidgetNavigation, SetCape, SetKnts, WidgetWind, WidgetFlow, SetLatitude, SetLongitude, RedrawWheel.

IMPORTANT: All the widgets are using the ZD_DRAW_DEFERRED constant, except the very last one (RedrawWheel),
to have them all redrawn in one single shot, rather than individually.

The GDImage control is using the WS_BORDER style to let you see its client size inside of the main window.

BACKGROUND:
The GDImage graphic control, and the main window share the same bitmap wallpaper,
see the GDImageUpdateBackround() procedure and the ZI_CreateSkinBackground(...) API.
The bitmap is also updated while processing the WM_SIZE message, with the ResizeGDImageCtrl() procedure.

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


   
* procedural programming mode, is based on direct use of the FLAT API (Windows SDK) that is the core meat of the OS.
72
The concept / Tutor_03 (C++ VS2022 GDImage64 tutorial)
« Last post by Patrice Terrier on June 06, 2023, 03:18:01 pm »
Third 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_03
This tutor introduces the use of clone sprites within a GDImage control.
The same bitmap is used by the {reference} sprite, and its clone(s) without wasting the memory.

Each clone has its own set of properties inherited from the {reference} sprite, and they can also be customized.
They are created in the GDImageCreateSprite() procedure.
All sprites/clones are stored along the z-order, from bottom to top, in their order of appearance.
In the CHM help file, search for: ZD_SetObjectZorder and ZD_GetObjectZorder.
Each sprite/clone can have a different label (friendly name), and specific anchor property .

BACKGROUND:
The GDImage graphic control, and the main window are using the same bitmap wallpaper,
see the GDImageUpdateBackround() procedure and the ZI_CreateSkinBackground(...) API.
The bitmap is also updated while processing the WM_SIZE message, with the ResizeGDImageCtrl() procedure.

ANIMATION:
They are handled from the WM_TIMER message and the Animate() procedure.

TEXT ROTATION:
This sprite is using a private font stored in the \Resource folder.
A private font can only be used by the application, without installing it first in Windows.

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


   
* procedural programming mode, is based on direct use of the FLAT API (Windows SDK) that is the core meat of the OS.
73
The concept / Tutor_02 (C++ VS2022 GDImage64 tutorial)
« Last post by Patrice Terrier on June 04, 2023, 10:03:13 pm »
Second 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_02
This tutor introduces the use of sprites within a GDImage control.
They work like icons on the Windows desktop, and you can drag them around with the mouse.
They can also be used to build a complete graphic interface, and mimic window's child controls.

It is possible to create events to process specific messages in the GDImage control.
See in the addGDImageControl how the ZI_EventMessageEx is used to preprocess the messages in the GDImageCallBack function.

All child controls are created in the CreateControls() procedure.
The sprites are loaded from the LoadSpriteResource() procedure.
All sprites are stored along the z-order, from bottom to top, in their order of appearance.
In the CHM help file, search for: ZD_SetObjectZorder and ZD_GetObjectZorder.
Each sprite can use a label property (friendly name), it is shown in the status bar when you click on a specific object with the left mouse button
The label property can also be used to display a tooltip using the ZI_SetToolTipText API.

Sprite properties:
Code: [Select]
ZD_HIDE               = 0;          // FALSE
ZD_SHOW               = 1;          // TRUE
ZS_HIDDEN             = ZD_HIDE;
ZS_VISIBLE            = ZD_SHOW;    // VISIBLE, same as WS_VISIBLE
ZS_SCROLL             = 2;          // MOVE with scroll bars, default is FIX (do not scroll)
ZS_DRAFT              = 4;
ZS_INACTIVE           = 2;

ZD_ORDER_TOP          = 0xFFFFFF;
ZD_ORDER_BOTTOM       = 0xFFFF;

ZD_Normal             = 0; // Orientation unchanged (default)
ZD_Flip               = 1; // Swap top / bottom
ZD_Reverse            = 2; // Swap left / right

Sprite types:
Code: [Select]
OBJECT_TEXT           = 1;
OBJECT_ELLIPSE        = 2;
OBJECT_RECT           = 3;
OBJECT_CURVE          = 4;
OBJECT_ARROW          = 5;
OBJECT_POLYLINE       = 6;
OBJECT_BITMAP         = 7;
OBJECT_BEZIER         = 8;
OBJECT_POLYPOLYGON    = 9;
OBJECT_TEXTBITMAP     = 10;

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

It is also possible to use anchor properties with the sprite ZD_SetObjectAnchorMode API.

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


   
* procedural programming mode, is based on direct use of the FLAT API (Windows SDK) that is the core meat of the OS.
74
The concept / Tutor_01 (C++ VS2022 GDImage64 tutorial)
« Last 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" 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.
75
64-bit SDK programming / OpenGL texture animation
« Last post by Patrice Terrier on June 02, 2023, 11:42:05 am »
This C++ 64-bit Visual Studio 2022 demo, is the transcription of a WinDev project writtten in 2021,
and posted on the PC-Soft repository here:
https://repository.windev.com/resource.awp?file_id=281474976711144;glimage-opengl-textures

The animated textures are stored in \X64\Release\resource folder

Description
As soon as you start OpenGL programming, it is essential to be able to use quality textures.
Mipmapping, variable opacity, anti-aliasing are all techniques used to produce professional quality 3D renderings.
GDImage supports all of these techniques to produce textures of any size, from the following image formats:
tga, dds, bmp, tif, tiff, dib, gif, ico, jpg, jpeg, png.

You can change the texture on the fly using Explorer's drag and drop.
The window has 2 textures, one for the fixed background and the other opaque or using variable opacity which can be manipulated with the mouse.

Note: The default texture is using a GDImage PNG animation.

76
64-bit SDK programming / Splash Screen Plus
« Last post by Patrice Terrier on May 25, 2023, 11:33:07 am »
This GDImage64 project has been converted from WinDev to C++ 64-bit, and there is also a PowerBASIC 32-bit version.
It uses a layered window to render GDImage PNG animation, altogether with multiple sprite effects.

The 64-bit code has been optimized to fit within a very small 16384 bytes executable.
Using specific project properties based on the TClib.lib (Tiny C Lib) to replace the default Visual Studio setup.

To start the demo, click on the "On Off" button, then select either next (>>) or prev (<<) to change of splash screen.
To stop the demo, press the close button (X).




Other links about GDImage PNG animations
http://www.objreader.com/index.php?topic=69.0
http://www.objreader.com/index.php?topic=67.0

About the PowerBASIC version
This is the exact transcription of the C++ 64-bit project.
A good example, showing how the core SDK syntax can ease the conversion from one language to another

The 64-bit C++ version is using Unicode, while the 32-bit is using Ansi.
Both resulting EXE size are rather small, 18 Kb for PowerBASIC 32-bit, and 13 Kb for C++ 64-bit.

 

77
Tips & Tricks / Charles Petzold 5e edition
« Last post by Patrice Terrier on May 24, 2023, 09:31:27 am »
For those wanting to learn the core SDK FLAT API
Here is the best book ever written about Windows programming.



78
Ho I didn't see these videos ! my bad ! I'm going to watch them !

EDIT : Yes I've already seen the first one :) but didn't see the second.

I already download the trial version on the site that's the demos I look at :)

EDIT 2 : In fact most of the examples I looked at use the SDK approach. For now I search for more examples with the DDT approach. PowerBasic is new for me, that's why I try for now to use the stock approach with some libs. I should experiment myself may be.
79
Have you seen these videos?
http://www.objreader.com/index.php?topic=400.0

You can also download the old demos provided with the PowerBASIC GDImage 5.00 trial version
http://www.zapsolution.com/preview/gdimage.zip
80
Please apologize for the double post. I look at this lib and examples. I miss some basic skeleton to understand how it works. The documentation is good but a mini skeleton  shows how to implement it could be great.
Pages: 1 ... 6 7 [8] 9 10