Pelles C forum

C language => Work in progress => Topic started by: Vortex on April 01, 2023, 09:52:58 PM

Title: ChatGPT examples
Post by: Vortex on April 01, 2023, 09:52:58 PM
Hello,

Here are some Win32 control examples coded by ChatGPT. Some minor modifications were necessary before compiling the code with Pelles C.
Title: Re: ChatGPT examples
Post by: Pelle on April 02, 2023, 03:18:22 PM
Probably just me, but I find it somewhat reassuring than an actual person was needed to make it work...  ;)
Title: Re: ChatGPT examples
Post by: Vortex on April 02, 2023, 07:10:33 PM
Hi Pelle,

You are right, the coders are training the artificial engine by supplying the necessary code templates.

Here is another example, a bouncing window.
Title: Re: ChatGPT examples
Post by: Vortex on April 13, 2023, 09:41:18 PM
Hello,

Attached is a treeview example.
Title: Re: ChatGPT examples
Post by: John Z on April 14, 2023, 11:18:17 AM
Thank Vortex,

These are interesting examples even if simple.
They might look a lot like MS example code....

I, for one, would like to know how much fix-up
work you had to do to get them to work. You mentioned
in the first example that some adjustment was needed.

Making the treeview more involved, can it create a
treeview display of any selected directory and all subdirectories
under it?  Just wondering how complex the request can be and
if it handles a real world example.

John Z
Title: Re: ChatGPT examples
Post by: Vortex on April 17, 2023, 09:04:00 PM
Hi John,

Here are the steps to fix the progress bar sample :

- Add #include <commctrl.h> to define PROGRESS_CLASS

- Practical solution : move int nProgress = 0;  to the top of the code - static storage classe definiton in the original code.

- Initialize the missing timer :  SetTimer(hwnd, ID_TIMER, 50, NULL);

Asking ChatGPT to design a more sophisticated treeview example failed, the AI suddenly stopped typing the code after some progress :

Code: [Select]
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_SIZE:
        // Resize treeview control to fit window
        MoveWindow(GetDlgItem(g_hWnd, WC_TREEVIEW), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
        break;
    case WM_NOTIFY:
        if (((LPNMHDR)lParam)->code == TVN_ITEMEXPANDING)
        {
            // Populate subfolders when a node is expanded
            LPNMTREEVIEW lpnmtv = (LPN
}

No code after the last line.
Title: Re: ChatGPT examples
Post by: Vortex on April 17, 2023, 09:29:12 PM
Hello,

https://community.openai.com/t/chatgpt-sometimes-not-finish-its-code-or-sentence-how-do-i-solve-this/46476

https://www.reddit.com/r/OpenAI/comments/zd6hkk/bot_is_broken_when_asking_to_code_something_it/
Title: Re: ChatGPT examples
Post by: John Z on April 18, 2023, 12:17:40 AM
Very interesting!

Thanks Vortex.

John Z
Title: Re: ChatGPT examples
Post by: Vortex on April 18, 2023, 08:44:53 PM
Hi John,

You are welcome. To get the continuation of the ChatGPT coding session, I simply type :

Quote
continue

Attached is a Mandelbrot fractal example.
Title: Re: ChatGPT examples
Post by: John Z on April 21, 2023, 11:42:17 AM
Thanks Vortex,

Got it to look over.

Here is an interesting take on ChatGPT code.

https://www.theregister.com/2023/04/21/chatgpt_insecure_code/

John Z
Title: Re: ChatGPT examples
Post by: Vortex on April 21, 2023, 08:40:54 PM
Hi John,

Thanks for the article. Something is not clear, are the research results based on the free or paid ChatGPT service? Also, it's probably early yet to expect secure programming from ChatGPT as it's a very new AI system.
Title: Re: ChatGPT examples
Post by: frankie on April 22, 2023, 04:56:26 PM
ChatGPT use the information he has processed from huge web data.
Most of programming examples on the web are just simplified samples of programming techniques that, for the sake of simplicity, normally ignore complications related to safety and efficiency.
Maybe asking to it if the code is safe, efficient, etc. The machine can upgrade the code. But to what extent?
You'll never know when, and if, what is output is really correct, unless yourself are an expert; but if you are such an expert why ask to ChatGPT?
I asked many technical questions about programming, uC, embedded controls, the answer were almost always incomplete, if not wrong. I had to add "Are you sure? The datasheet says something different." The answer was almost always "You're right, I'm sorry" (sometime insisting on the error).
How many times we must re-ask to be sure that it had correctly processed all the available data? And how we know if the answer is finally correct? What if base data was itself wrong?
So in MHO it is nice to play around with ChatGPT, but it will still take a long time for ChatGPT to be trusted...
Title: Re: ChatGPT examples
Post by: Stefan Pendl on April 23, 2023, 10:14:56 AM
The AI bot learns how a child learns with trial and error.
Due to the speed it can learn it will not take a whole life to get to a knowledge level of a human.
On the other side there is not only bare knowledge in a humans world, but that part might be out of scope for a bot.
Title: Re: ChatGPT examples
Post by: Vortex on April 23, 2023, 11:40:09 AM
On the other side there is not only bare knowledge in a humans world, but that part might be out of scope for a bot.

Exactly. For example, intuition :

Quote
the ability to understand something instinctively, without the need for conscious reasoning.

At the moment, this is something that an AI cannot "understand".
Title: Re: ChatGPT examples
Post by: John Z on April 23, 2023, 01:07:32 PM
Probably a good topic to move to Chit-Chat  :)

Anyway it is more realistic to name it simulated intelligence IMHO.  SI rather than AI, and it is a very limited simulation at that as both Vortex and Stefan have pointed out.  It is stuck doing what it was instructed to do and how it was instructed to do it, by the algorithms within.  Having almost unlimited memory access does not equal intelligence, superior or otherwise.  A person with an eidetic memory can recall anything seen, and there are those that can recall any moment in their life, hyperthymesia, but these people are not characterized as super intelligence or extremely high IQ as defined today.  An "AI" that beat everyone at the game of GO because it was trained extensively on the game and the only purpose of the 'AI' was to win, initially succeeded in beating the worlds best human GO player.... but eventually it also lost a game because a human thought of a unique strategy enabling a win.  The 'AI' could not and did not 'foresee' the strategy.

John Z

P.S. An excellent SiFi series,or two, with Sentient Aware Digital Entities (SADE's) by S.H.Jucha
Silver Ships and Gate Ghosts
https://scottjucha.com/silverships.html
Title: Re: ChatGPT examples
Post by: Vortex on April 23, 2023, 01:11:23 PM
Question : Create a Windows based hello world example with Pelle's macro assembler Poasm.

ChatGPT's output :

Code: [Select]
; Program to print "Hello, World!" to the console in Windows

format PE console
entry start

section '.data' data readable writeable

message db 'Hello, World!', 0

section '.text' code readable executable

start:
    ; Print the message to the console
    push dword -11
    call [GetStdHandle]
    mov dword [handle], eax
    push dword 0
    push dword message
    push dword 13
    push dword [handle]
    call [WriteConsoleA]

    ; Exit the program
    push dword 0
    call [ExitProcess]

section '.idata' import data readable

library kernel32, 'kernel32.dll',\
        user32, 'user32.dll'

import kernel32,\
       ExitProcess, 'ExitProcess',\
       GetStdHandle, 'GetStdHandle',\
       WriteConsoleA, 'WriteConsoleA'

section '.data' data readable writeable

handle dd ?

Naturally, this is the syntax of the Flat Assembler and not Poasm.
Title: Re: ChatGPT examples
Post by: John Z on April 26, 2023, 10:44:57 PM
Google BARD released a pseudo-coder too now .... "Coders can choose from 20+ different coding languages too...."

https://www.tomsguide.com/news/googles-bard-ai-can-now-write-code-heres-how-to-use-it

John Z

Title: Re: ChatGPT examples
Post by: Vortex on April 27, 2023, 09:19:34 PM
Quote
Question : What are differences between the macro engines of Masm and Poasm?

Quote
Masm (Microsoft Macro Assembler) and Poasm (Pelle's Macro Assembler) are both macro assemblers that support the x86 architecture. While they are similar in many respects, there are some differences between their macro engines:

Syntax: Masm and Poasm use slightly different syntax for defining and invoking macros. Masm uses the MACRO and ENDM directives to define a macro and the INVOKE directive to invoke it, while Poasm uses the macro and endm directives to define a macro and the invoke directive to invoke it.

Parameter passing: Masm and Poasm handle parameter passing differently. Masm passes parameters using the stack, while Poasm uses registers.

Macro expansion: Masm and Poasm expand macros differently. Masm expands macros recursively, which can lead to excessive code duplication if macros are not written carefully. Poasm expands macros non-recursively, which can result in more efficient code generation.

Error checking: Masm and Poasm perform error checking differently. Masm checks for errors during the expansion phase, while Poasm checks for errors during the assembly phase.

Overall, both Masm and Poasm are powerful macro assemblers that are widely used in the industry. The choice between the two largely depends on personal preference and specific project requirements.

ChatGPT is serioulsy confused here.
Title: Re: ChatGPT examples
Post by: John Z on August 09, 2023, 01:28:28 AM
More test results
https://www.theregister.com/2023/08/07/chatgpt_stack_overflow_ai/

“ ChatGPT, OpenAI's fabulating chatbot, produces wrong answers to software programming questions more than half the time, according to a study from Purdue University. That said, the bot was convincing enough to fool a third of participants.”


John Z

Title: Re: ChatGPT examples
Post by: Vortex on August 09, 2023, 03:26:00 PM
Hi John,

The incorrect results are not unexpected. ChatGPT and similar tools will evolve and we will get no perfect but better results.
Title: Re: ChatGPT examples
Post by: KunJohn on September 23, 2023, 02:25:10 PM
I read somewhere recently that AI already uses probably 9 programming languages..but integrating AI software into an already diverse business environment requires the use of a range of programming tools, such as several languages, frameworks and libraries. These technologies often require extraordinary competence and expertise.
Title: Re: ChatGPT examples
Post by: Vortex on September 23, 2023, 08:56:37 PM
Hi KunJohn,

Welcome to Pelles C forum.

I agree with you. The artificial intelligence is powered by big compainies investing a lot of efforts and money. Time will help to improve the quality of the code written by the artificial intelligence.
Title: Re: ChatGPT examples
Post by: John Z on November 18, 2023, 11:19:18 AM
Windows 10 aficionados rejoice.

https://arstechnica.com/gadgets/2023/11/microsoft-is-revisiting-windows-10-by-backporting-the-copilot-ai-assistant/

https://www.theregister.com/2023/11/17/microsoft_to_bring_copilot_to/

CoPilot - MS ChatGPT coming to windows 10.

It just showed up on my Win11 this week.  Runs from a taskbar icon and opens a chat windows.  Says it can program something for me  ;)


John Z 
Title: Re: ChatGPT examples
Post by: Vortex on November 18, 2023, 06:47:15 PM
Another funny "assumption" of ChatGPT :

Code: [Select]
    // Enumerate exports
    FARPROC* pFunctions;
    DWORD numberOfFunctions = 0;
    pFunctions = NULL;

    // Get the number of functions in the DLL
    numberOfFunctions = (DWORD)GetProcAddress(hModule, NULL);
    if (numberOfFunctions == 0) {
        fprintf(stderr, "Failed to get the number of functions in the DLL.\n");
        fclose(outputFile);
        FreeLibrary(hModule);
        return;
    }

GetProcAddress(hModule, NULL) does not return the number of functions exported by a DLL.
Title: Re: ChatGPT examples
Post by: John Z on November 18, 2023, 11:19:41 PM
M$S CoPilot:
"write a function in WIN 64 C to return the number of functions exported by a DLL"
Answer:
Code: [Select]
Here is a sample C function that returns the number of functions exported by a DLL in Windows 64-bit:

```c
#include <windows.h>

int get_exported_functions_count(char* dll_path) {
    HMODULE hModule = LoadLibrary(dll_path);
    if (hModule == NULL) {
        return -1;
    }
    int count = 0;
    PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)hModule;
    PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((char*)hModule + dosHeader->e_lfanew);
    PIMAGE_EXPORT_DIRECTORY exportDir = (PIMAGE_EXPORT_DIRECTORY)((char*)hModule + ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
    DWORD* functions = (DWORD*)((char*)hModule + exportDir->AddressOfFunctions);
    for (int i = 0; i < exportDir->NumberOfFunctions; i++) {
        if (functions[i] != 0) {
            count++;
        }
    }
    FreeLibrary(hModule);
    return count;
}

here is how it says it works:
Code: [Select]
This function takes the path of the DLL as an argument and returns the number of functions
exported by the DLL. It uses the `LoadLibrary` function to load the DLL into memory, and
then it extracts the export directory from the DLL's PE header. Finally, it counts the number
of non-zero function addresses in the export directory to determine the number of exported functions.

Haven't tried it yet  :)

John Z
Title: Re: ChatGPT examples
Post by: Vortex on November 19, 2023, 10:58:54 AM
Hi John,

Thanks, your code works fine :

Code: [Select]
#include <windows.h>
#include <stdio.h>

// Source :
// https://forum.pellesc.de/index.php?topic=10825.msg38689#msg38689

int get_exported_functions_count(char* dll_path) {

    HMODULE hModule = LoadLibrary(dll_path);
    if (hModule == NULL) {
        return -1;
    }

    int count = 0;
    PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)hModule;
    PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((char*)hModule + dosHeader->e_lfanew);
    PIMAGE_EXPORT_DIRECTORY exportDir = (PIMAGE_EXPORT_DIRECTORY)((char*)hModule + ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
    DWORD* functions = (DWORD*)((char*)hModule + exportDir->AddressOfFunctions);

    for (unsigned int i = 0; i < exportDir->NumberOfFunctions; i++) {
        if (functions[i] != 0) {
            count++;
        }
    }
    FreeLibrary(hModule);
    return count;
}

int main(void) {
 
char *dll="kernel32.dll";
printf("%s exports %u functions.\n",dll,get_exported_functions_count(dll));

    return 0;
}
Title: Re: ChatGPT examples
Post by: TimoVJL on November 19, 2023, 11:08:10 AM
This avoid some problems.
Code: [Select]
HMODULE hModule = LoadLibraryEx(dll_path, NULL, LOAD_LIBRARY_AS_DATAFILE);
Title: Re: ChatGPT examples
Post by: Vortex on November 19, 2023, 11:26:02 AM
Hi Timo,

Your suggestion works fine :

Code: [Select]
// HMODULE hModule = LoadLibrary(dll_path);
   HMODULE hModule = LoadLibraryEx(dll_path, NULL, LOAD_LIBRARY_AS_DATAFILE);
Title: Re: ChatGPT examples
Post by: John Z on November 19, 2023, 12:35:50 PM
Hi John,

Thanks, your CoPilot code works fine :
Thanks for testing it Vortex! Amazing to me, very creditable code ....here are what CoPilot reported as references
Code: [Select]
Source: Conversation with Bing, 11/18/2023
(1) Exporting functions from a DLL with dllexport - Stack Overflow. https://stackoverflow.com/questions/538134/exporting-functions-from-a-dll-with-dllexport.
(2) Return function pointer of DLL functions - CodeProject. https://www.codeproject.com/questions/564590/returnplusfunctionpluspointerplusofplusdllplusfunc.
(3) How to call exported function from dll in C/C++? - Stack Overflow. https://stackoverflow.com/questions/10972499/how-to-call-exported-function-from-dll-in-c-c.
(4) How to get Functions exported from a dll file. https://social.msdn.microsoft.com/Forums/en-US/6490b46f-909f-43b0-9cb9-220d0b4812fc/how-to-get-functions-exported-from-a-dll-file?forum=vbinterop.
(5) c++ - x64 DLL export function names - Stack Overflow. https://stackoverflow.com/questions/28062446/x64-dll-export-function-names.
I haven't yet checked if any are an exact match, going to do that today.
Update:  None of the references show to be a direct source to copy code into the answer . . .

This avoid some problems.

Thanks TimoVJL - always good to be better and avoid issues   :)

John Z
Title: Re: ChatGPT examples
Post by: Vortex on December 01, 2023, 02:16:14 PM
This time, I received a better answer regarding my simple console application :

Code: [Select]
; hello.asm - Hello, World! example for Poasm (Console Application)

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\kernel32.lib

.data
HelloWorld db 'Hello, World!',0

.code
start:
    ; Get the standard output handle
    invoke GetStdHandle, STD_OUTPUT_HANDLE
    mov    ebx, eax

    ; Write the "Hello, World!" string to the console
    invoke WriteConsole, ebx, addr HelloWorld, sizeof HelloWorld - 1, 0, 0, 0

    ; Exit the program
    invoke ExitProcess, 0
end start

Title: Re: ChatGPT examples
Post by: WiiLF23 on January 06, 2024, 05:25:22 AM
GPT has practically built a entire P2P Winsock filesharing application (client + server DLL) and it is on steroids! I dont under estimate AI by any means.

The level of checks, overflow protections and much more are beyond my skill set. I have learned a great deal from using GPT. Most of what I've posted (except progress painting) is all AI-generated.

2 months of that, which has basically built the entire application from start to finish is just mind blowing.

Today, I now write a lot of it myself as I have studied every single prompt, with all of the "why" and "how" well utilized over time.

Yes.. GPT can write complete software from the point of a single header line. Thats almost scary.. it has trained me so endless code solutions I cant even begin to explain what it has provided for this compiler and IDE.

I will continue to use it in order to gain insight into C programming, functions and structures. Like I said.. it has developed the entire thing for me just by asking prompts and copying and pasting.

Bloody thing runs @ 1.8MB in memory and it is very optimized and cleans up at all points needed, far more than I could ever expect. Very optimized!

The only thing I question.. are security issues. It does not handle very well at all. Just for those wondering. I will hire an audit for that.

Title: Re: ChatGPT examples
Post by: Vortex on January 06, 2024, 11:20:36 AM
Hi WiiLF23,

Chat GPT is probably more successfull with high level languages at least for today :

Quote
I will continue to use it in order to gain insight into C programming, functions and structures. Like I said.. it has developed the entire thing for me just by asking prompts and copying and pasting.

I agree with you.
Title: Re: ChatGPT examples
Post by: MrBcx on January 06, 2024, 04:01:05 PM
Below are some of the things I now know and use ChatGPT for.

My initial prompts for code generation often specifies "plain c", "Win32 API", and "Windows 10".
Depending on what I'm doing, I'll also specify specific WinAPI libraries to be used, such as GDI or GDI+

ChatGPT ( https://chat.openai.com/  ) gives us 1500 chars for "Custom Instructions" which
can accomplish magic.  Because a lot of what I do involves BCX BASIC, the following are the
custom instruction I have stored under ChatGPT's Settings.

Code: [Select]
I developed BCX BASIC and code in  C17 and Win32API on Windows. 
You will help me solve coding problems. When providing BCX source code,
always convert parenthesis to square brackets when they refer to  arrays. 
All variables and function arguments must be type declared. 
FOR-NEXT loop variables, must be TYPE declared. 
For example:  FOR LONG  i =  1  to 10 STEP 2 ... and so on.  BCX functions
return their function result using "FUNCTION =".  Never use "RETURN" to exit
a function or sub.   
SUB and FUNCTION arguments must be wrapped around parenthesis. 
Variables in BCX must be DIM'ed.  BCX's default datatype is integer, not
SINGLE like other BASIC dialects.  When converting code from other dialects,
always DIM the variables, if one does not exist.
BCX uses "GLOBAL" not "DIM SHARED".
Do not dim and assign in the same statement, keep them separate.
BCX user-defined functions generally follow this format:
FUNCTION DegToRad(Degrees AS DOUBLE) AS DOUBLE
    DIM AS DOUBLE Radians
    Radians = Degrees * 0.01745 )
    FUNCTION = Radians
END FUNCTION
when targeting the Win32 API, BCX works best when you use published
Win32 variable types , such as HDC, HBITMAP, etc, when creating variables.
Do not use the "@" symbol for pointers, use the ADDRESSOF function.
when passing variable pointers to functions, BCX can use the full Win32 API,
just like any Win32 C17 program.

I have gotten back compilable BCX BASIC code from ChatGPT on the first shot about 50% of the time, the rest of the time the generated code usually contains a few minor errors mixed with the occasional hallucination.  Quickly getting a prototype, even a rough one, quickly is tremendously useful. 

I also routinely provide code to ChatGPT and ask it to review, explain, and provide refactoring opportunities.
Title: Re: ChatGPT examples
Post by: WiiLF23 on January 06, 2024, 08:21:39 PM
Below are some of the things I now know and use ChatGPT for.

My initial prompts for code generation often specifies "plain c", "Win32 API", and "Windows 10".
Depending on what I'm doing, I'll also specify specific WinAPI libraries to be used, such as GDI or GDI+

ChatGPT ( https://chat.openai.com/  ) gives us 1500 chars for "Custom Instructions" which
can accomplish magic.  Because a lot of what I do involves BCX BASIC, the following are the
custom instruction I have stored under ChatGPT's Settings.

Code: [Select]
I developed BCX BASIC and code in  C17 and Win32API on Windows. 
You will help me solve coding problems. When providing BCX source code,
always convert parenthesis to square brackets when they refer to  arrays. 
All variables and function arguments must be type declared. 
FOR-NEXT loop variables, must be TYPE declared. 
For example:  FOR LONG  i =  1  to 10 STEP 2 ... and so on.  BCX functions
return their function result using "FUNCTION =".  Never use "RETURN" to exit
a function or sub.   
SUB and FUNCTION arguments must be wrapped around parenthesis. 
Variables in BCX must be DIM'ed.  BCX's default datatype is integer, not
SINGLE like other BASIC dialects.  When converting code from other dialects,
always DIM the variables, if one does not exist.
BCX uses "GLOBAL" not "DIM SHARED".
Do not dim and assign in the same statement, keep them separate.
BCX user-defined functions generally follow this format:
FUNCTION DegToRad(Degrees AS DOUBLE) AS DOUBLE
    DIM AS DOUBLE Radians
    Radians = Degrees * 0.01745 )
    FUNCTION = Radians
END FUNCTION
when targeting the Win32 API, BCX works best when you use published
Win32 variable types , such as HDC, HBITMAP, etc, when creating variables.
Do not use the "@" symbol for pointers, use the ADDRESSOF function.
when passing variable pointers to functions, BCX can use the full Win32 API,
just like any Win32 C17 program.

I have gotten back compilable BCX BASIC code from ChatGPT on the first shot about 50% of the time, the rest of the time the generated code usually contains a few minor errors mixed with the occasional hallucination.  Quickly getting a prototype, even a rough one, quickly is tremendously useful. 

I also routinely provide code to ChatGPT and ask it to review, explain, and provide refactoring opportunities.

That is great to hear! I have become wise to its hallucinations and dummy responses. In that case, you reset the entire session by opening a new chat. I do this quite aggressively to keep the inquiry relevant and not pull up old history that alters its responses further. You have to catch that quickly, but it is beyond rewarding.

I use stricly

"For Pelles C, show me how to <your desire>"

Or for code assessment:

"In Pelles C, I have <code description>, and I need to <your desire>"

I find when you mention "Show me in pure C" it just brings up Linux-intended code. Sure, thats great if you are setup for cross-development but I am not so it is fluff to me. I keep it on topic for Pelles C, so it already comprehends the headers in use and general expectations.

Side note:

GPT easily understands subclassing, it sucks at painting unless you really dumb it down step by step (like the MessageBar topic I posted, all AI generated). When it comes to painting, it really lacks in that area.
Title: Re: ChatGPT examples
Post by: John Z on January 07, 2024, 09:44:51 PM
Hi WiiLF23,

At some point I am forced to produce a custom TreeView control as this is the heart of my application. Not at all easy to do. Source code is on github so maybe it is possible. I need node padding, custom color highlighting, and gradient effects.

So will you give ChatGPT the task of creating the subclassed treeview with the ability to independently set/control all visual elements of the treeview display?  Might it be better and/or more complete than GitHub?  Beyond me, I've used Bard exactly once so I'm well behind in this tool.

John Z

P.S. what is 'node padding' ?
Title: Re: ChatGPT examples
Post by: WiiLF23 on January 11, 2024, 07:21:43 PM
Hi WiiLF23,

At some point I am forced to produce a custom TreeView control as this is the heart of my application. Not at all easy to do. Source code is on github so maybe it is possible. I need node padding, custom color highlighting, and gradient effects.

So will you give ChatGPT the task of creating the subclassed treeview with the ability to independently set/control all visual elements of the treeview display?  Might it be better and/or more complete than GitHub?  Beyond me, I've used Bard exactly once so I'm well behind in this tool.

John Z

P.S. what is 'node padding' ?

In reality, its subclassing really anything and following the paint events and messages specific to that control. I've realized how to do this to all elements of a ListView (background, alternating rows, header columns) and works fine. I also did a full custom paint for tabs as well. I dont see why this is not possible for TreeView without any help from AI. I just needed to know the event message macros and go from there, AI was helpful for that.

At this point, and how seamless styling each control is I have practically written a UI framework lol the amount of drawing and paint procedures deserve a DLL and entry point functions pointed at a controls handle.

This will let me wrap and style anything from the UI framework DLL and move all of the drawing to the DLL and out of the main application.

"node padding" just means row spacing for each full-row selected node in the treeview control. VS has margins and padding, so usually its known by referring back to that. In pelles C, its all manual.