c3c icon indicating copy to clipboard operation
c3c copied to clipboard

GUI Windows C3C Example?

Open Spoiledpay opened this issue 3 years ago • 10 comments

Hello! Is there somewhere gui code demo for windows? Any example or functional app? Do you have a lib you can use or document template to create a Windows Form?

Spoiledpay avatar Jan 25 '23 17:01 Spoiledpay

There are no native GUI examples, but you can have a look here at the standard lib invoking Win32 functions: https://github.com/c3lang/c3c/blob/master/lib/std/threads/os/thread_win32.c3

So win32 functions can be called directly in this way.

If you want something that works out of the box that isn't native boxes, you can use Raylib. Here is one example using Raylib: https://github.com/c3lang/c3c/blob/master/resources/testfragments/raylibtest.c3

You can grab Raylib from the c3c/vendor, or use c3c.exe vendor-fetch raylib. It will give you a raylib.c3l file you just need to place somewhere so that the compiler can find it. For example, if it's in the current dir and you're not using projects yet, you add --libdir . --lib raylib to the compilation, e.g. c3c.exe compile-run --libdir . --lib raylib raylibtext.c3

lerno avatar Jan 25 '23 23:01 lerno

Hello, Thanks for the help. As shown, I was able to run the example test with raylib and compile the Tetris program.

GuiRaylib

Spoiledpay avatar Jan 25 '23 23:01 Spoiledpay

:+1: Were there any more steps you needed to do to get up and running?

lerno avatar Jan 26 '23 19:01 lerno

Hi! I downloaded the raylib lib for Windows. Then I followed the steps you mentioned.

Now I want to see if I can use the Standard Windows functions to create Winforms. And another thing I noticed. I didn't find the option to generate Winexe. It generates .exe. If you know, windows has the console and the winexe. And I didn't find this option in the C3C compiler. In case you noticed or I'm wrong, it opens a console and then the Tetris winform.

like: -target:winexe

thanks

Spoiledpay avatar Jan 26 '23 20:01 Spoiledpay

Hi! I discovered this visual build tool, where it generates a Winexe and the executable runs natively without a console window in the background on windows 10 and 11.

editbin.exe /subsystem:windows yourapp.exe

Spoiledpay avatar Jan 28 '23 14:01 Spoiledpay

I'm just thinking about how to properly support this in depth. For example, main could offer you to use: main(void* hInstance, String[] args, int showcmd), matching hInstance, the command line arguments, and showCmd respectively.

lerno avatar Jan 28 '23 18:01 lerno

I am working on fixing this problem, it's just been taking a little while.

lerno avatar Jan 29 '23 00:01 lerno

Ok, so what you want to do now is to add @winmain after your main, so for example:

fn void main(String[] args) @winmain { ... code ... }

This will make it pick the WINDOWS subsystem.

lerno avatar Jan 29 '23 13:01 lerno

Hi! Thank you for your development. I will still test your choice. Thanks.

Spoiledpay avatar Jan 29 '23 13:01 Spoiledpay

@Spoiledpay can I close this issue?

lerno avatar Jun 13 '23 12:06 lerno

@lerno I run into the exact same issue, I tested the @winmain with the raylib and it worked perfectly! I think you can close this.

murillobrand avatar Aug 02 '24 20:08 murillobrand

Thank you!

lerno avatar Aug 02 '24 23:08 lerno