C
C#•3y ago
Exilon

Window opacity not being effected in a method?

Hello, I've been trying to change the opacity of my window through code for a while now but I've had no success. I'm changing the Window.Opacity number in my function but I've had no success. As of now, I've tried setting the background to a SolidBrushColor and setting the opacity from there to no success. I'm also trying INotifyPropertyChanged still to no avail. There are no errors either. The opacity just isn't affected. Here is the code of the overlay window that needs its opacity changed:
public partial class overlay : Window, INotifyPropertyChanged
{
public static overlay? thisOverlay;
DoubleAnimation fade = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(5)));

public event PropertyChangedEventHandler? PropertyChanged;

private double _windowOpacity;
public double WindowOpacity
{
get => _windowOpacity;
set
{
if (_windowOpacity == value)
return;

_windowOpacity = value;
OnPropertyChanged();
}
}

public overlay()
{
InitializeComponent();
this.Loaded += Overlay_Loaded;
WindowOpacity = 0.2;
}

private void Overlay_Loaded(object sender, RoutedEventArgs e)
{
thisOverlay = this;

}
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

public void setOpacity() // Function is ran outside of this class
{
this.WindowOpacity = 0.5; // This doesn't work
Trace.WriteLine("Works"); // This prints
}
public partial class overlay : Window, INotifyPropertyChanged
{
public static overlay? thisOverlay;
DoubleAnimation fade = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(5)));

public event PropertyChangedEventHandler? PropertyChanged;

private double _windowOpacity;
public double WindowOpacity
{
get => _windowOpacity;
set
{
if (_windowOpacity == value)
return;

_windowOpacity = value;
OnPropertyChanged();
}
}

public overlay()
{
InitializeComponent();
this.Loaded += Overlay_Loaded;
WindowOpacity = 0.2;
}

private void Overlay_Loaded(object sender, RoutedEventArgs e)
{
thisOverlay = this;

}
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

public void setOpacity() // Function is ran outside of this class
{
this.WindowOpacity = 0.5; // This doesn't work
Trace.WriteLine("Works"); // This prints
}
Tell me if you would like to see any XAML code or MainWindow.cs.
259 Replies
Exilon
ExilonOP•3y ago
@Ero sorry for the delay but here is the code. tell me if you want to see any more Here is the XAML:
<Window x:Class="NAME.overlay"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NAME"
mc:Ignorable="d"
Title="overlay" Height="450" Width="800" WindowState="Maximized" WindowStyle="None" Topmost="True" AllowsTransparency="True" Opacity="{Binding WindowOpacity}" Visibility="Hidden">
</Window>
<Window x:Class="NAME.overlay"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NAME"
mc:Ignorable="d"
Title="overlay" Height="450" Width="800" WindowState="Maximized" WindowStyle="None" Topmost="True" AllowsTransparency="True" Opacity="{Binding WindowOpacity}" Visibility="Hidden">
</Window>
Jester
Jester•3y ago
well if you want to do some interop there is the method SetLayeredWindowAttributes an other one is the undocumented SetWindowCompositionAttribute (i cant really recommend this one) tl;dr: windows doesnt like transparent windows unless its an uwp window?
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Exilon
ExilonOP•3y ago
What should I set to public? I've added DataContext=this; to my code and it sorta worked.
public overlay()
{
InitializeComponent();
this.Loaded += Overlay_Loaded;
WindowOpacity = 0.2;
DataContext = this;
}
public overlay()
{
InitializeComponent();
this.Loaded += Overlay_Loaded;
WindowOpacity = 0.2;
DataContext = this;
}
The opacity is now set here this works
public void SetOpacity(overlay window) // Function is ran outside of this class
{
window.WindowOpacity = 1; // This doesn't work
Trace.WriteLine("Works"); // This prints
}
public void SetOpacity(overlay window) // Function is ran outside of this class
{
window.WindowOpacity = 1; // This doesn't work
Trace.WriteLine("Works"); // This prints
}
but I still am not able to change the opacity during runtime Im passing this as the parameter
ero
ero•3y ago
You shouldn't be setting that in code They specifically said to insert that into the xaml
Exilon
ExilonOP•3y ago
Really? What should I be inserting into xaml?
ero
ero•3y ago
try inserting this XAML after xmlns:local DataContext="{Binding RelativeSource={RelativeSource Self}}"
Exilon
ExilonOP•3y ago
Oh I already did lemme remove the defenition in code
Yawnder
Yawnder•3y ago
(affected)
Exilon
ExilonOP•3y ago
I still don't know the difference 💀 Still nothing :( Lemme test something real quick
Yawnder
Yawnder•3y ago
Something is affected by something else. You will almost never use effected.
Exilon
ExilonOP•3y ago
ok thx lol btw @Ero
public void CSGOFlash() // Function is ran outside of this class
{
WindowOpacity = 1; // This doesn't work
Opacity = 1; // or this :(
WindowState = WindowState.Normal; // This works????
Trace.WriteLine("Works"); // This prints
}
public void CSGOFlash() // Function is ran outside of this class
{
WindowOpacity = 1; // This doesn't work
Opacity = 1; // or this :(
WindowState = WindowState.Normal; // This works????
Trace.WriteLine("Works"); // This prints
}
I did some testing. Something is wrong with my opacity idk what maybe its a property I set
ero
ero•3y ago
What does this program do exactly...?
Exilon
ExilonOP•3y ago
Its a button that turns another transparent window opaque Supposed to be really simple
ero
ero•3y ago
no the entire program either way i can't repro this. works fine for me
Exilon
ExilonOP•3y ago
Can you send me some code please? Im using pinvoke to create that window if that helps
public partial class App : Application
{
protected unsafe override void OnStartup(StartupEventArgs e)
{
const long WS_EX_COMPOSITED = 0x02000000L;
const long WS_EX_TRANSPARENT = 0x00000020L;


overlay window = new();
window.Show();
IntPtr windowHandle = new WindowInteropHelper(window).Handle;

nint currentStyles = User32.GetWindowLongPtr_IntPtr(windowHandle, User32.WindowLongIndexFlags.GWL_EXSTYLE);
if (currentStyles == 0) throw new Win32Exception();

nint result = (nint)User32.SetWindowLongPtr(windowHandle, User32.WindowLongIndexFlags.GWL_EXSTYLE, (void*)(currentStyles | WS_EX_COMPOSITED | WS_EX_TRANSPARENT));
if (result == 0) throw new Win32Exception();

base.OnStartup(e);
}

}
}
public partial class App : Application
{
protected unsafe override void OnStartup(StartupEventArgs e)
{
const long WS_EX_COMPOSITED = 0x02000000L;
const long WS_EX_TRANSPARENT = 0x00000020L;


overlay window = new();
window.Show();
IntPtr windowHandle = new WindowInteropHelper(window).Handle;

nint currentStyles = User32.GetWindowLongPtr_IntPtr(windowHandle, User32.WindowLongIndexFlags.GWL_EXSTYLE);
if (currentStyles == 0) throw new Win32Exception();

nint result = (nint)User32.SetWindowLongPtr(windowHandle, User32.WindowLongIndexFlags.GWL_EXSTYLE, (void*)(currentStyles | WS_EX_COMPOSITED | WS_EX_TRANSPARENT));
if (result == 0) throw new Win32Exception();

base.OnStartup(e);
}

}
}
Not sure if this helps at all but here
ero
ero•3y ago
why... do you do this exactly...?
Exilon
ExilonOP•3y ago
To make that window not interactable
ero
ero•3y ago
but honestly since i suspect that this is a cheat for csgo, i'm not sure i will help much more
Exilon
ExilonOP•3y ago
You're not the first lol I'm making an app to flashbang users randomly lol
ero
ero•3y ago
kinda worse?
Exilon
ExilonOP•3y ago
Its not malicious It can be closed and you open it yourself its just for fun
Jester
Jester•3y ago
ws_ex_transparent makes a window transparent for clicks not visibly
Exilon
ExilonOP•3y ago
Ik. Thats exactly the point
Jester
Jester•3y ago
okay good
Exilon
ExilonOP•3y ago
I have a feeling that that might be whats causing the problem though
Jester
Jester•3y ago
<:PES_Think:639363477458255874> i have an idea
ero
ero•3y ago
so click-through, essentially
Exilon
ExilonOP•3y ago
Yep Also why are overlays always expected to be cheats?
Jester
Jester•3y ago
make a white layered window, make it see trough with setlayerdwindowattributes and to do the flash make it opaque again
Exilon
ExilonOP•3y ago
Wait so you want me to make another window?
Jester
Jester•3y ago
idk id do all of this with the win32 api and not in wpf or whatever this is
Exilon
ExilonOP•3y ago
Isnt that in C++?
Jester
Jester•3y ago
you can use it in c# too
Exilon
ExilonOP•3y ago
oh I might use Win32 API as a last resort
Jester
Jester•3y ago
or you do the interop manually or you use a nuget pqckage ti generate it for you like terrafx or cswin32
Exilon
ExilonOP•3y ago
someone recommended a overlay library to me that I don't want to use but it seems like I might have to That sounds extremely complicated for an app that is supposed to be really simple.
Jester
Jester•3y ago
just a flash bang? id say 50-100 lines of code (in the whole project) when using win32 depending on how you do it
Exilon
ExilonOP•3y ago
Thats what I thought too lmao Do you have a tutorial on using Win32 with Cs?
Jester
Jester•3y ago
i always say id make one but i dont you rigister the window class, then create a window, pump handle its messages, maybe use a timer to do the flashes on an interval
Exilon
ExilonOP•3y ago
Ok... Win32 Is usually used with C++ though right?
Jester
Jester•3y ago
c/c++ in an unsafe c# context you can basically write c code (its still c# but you know what i mean) writing the interop yourself is too much work thats why i usually use cswin32 to generate it for me but if you use terrafx it also has classes to create win32 windows with directx or vulkan graphics
Exilon
ExilonOP•3y ago
Ok and what difference does pinvoke and cswin32 have?
Jester
Jester•3y ago
nothing really, the difference is it writes the pinvoke code for you
Jester
Jester•3y ago
GitHub
GitHub - microsoft/CsWin32: A source generator to add a user-define...
A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project. - GitHub - microsoft/CsWin32: A source generator to add a user-defined set of Win32 P/In...
Jester
Jester•3y ago
ofc idk how well you know the win32 api it can be quite a steep learning curve to create a simple window how about a white top most maximized borderless window you just minimiza and maximize to do the KEKW solution no?
Exilon
ExilonOP•3y ago
bruh it look bad lol Also isn't that for winforms?
Jester
Jester•3y ago
doesnt really matter which project
Exilon
ExilonOP•3y ago
It mentions program.cs which is in winforms tho. not wpf iirc.
Jester
Jester•3y ago
you dont need a program.cs just NativeMethods.json and NativeMethods.txt
Exilon
ExilonOP•3y ago
Okay Ill check this out in another project later If thats easier
Jester
Jester•3y ago
i usually put that nuget package in its own class library project thingy next to my actual project
Exilon
ExilonOP•3y ago
ummmmmmmmmm ok @Jester So i just install CsWin32, add NativeMethods.json and NativeMethods.txt, type methods that I want to use and copy and paste the method name into NativeMethods.txt right?
Jester
Jester•3y ago
yup, put the config you want in the json and then the method names in the txt
Exilon
ExilonOP•3y ago
Do you mind sending an example of adding the WS_EX_TRANSPARENT tag to the window?
Jester
Jester•3y ago
creating a window or an existing window? CreateWindowExW(WS_EX_TRANSPARENT | ..., ...
Exilon
ExilonOP•3y ago
Create window I add this to NativeMethods.txt? the method name
Jester
Jester•3y ago
yes RegisterClassW, CreateWindowExW, GetMessage, PostQuitMessage, DestroyWindow, DefWindowProc, DispatchMessage you need at least these to create a working window
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
no each on a new line no comma
Exilon
ExilonOP•3y ago
Ah ok and any libs I should be importing?
Jester
Jester•3y ago
nope not explicit
Exilon
ExilonOP•3y ago
ok
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
Windows.Win32.PInvoke.Create... you will need a bunch of namespaces
Exilon
ExilonOP•3y ago
Ummm
Exilon
ExilonOP•3y ago
Oh
Exilon
ExilonOP•3y ago
its not in here is it meant to be>
Jester
Jester•3y ago
you can find the file it generates somewhere in the solution explorer
Exilon
ExilonOP•3y ago
?
Jester
Jester•3y ago
under analyzers
Exilon
ExilonOP•3y ago
oh okay its there at least
Jester
Jester•3y ago
good a simple test is SetCursorPos SetCursorPos(0, 0); should put your cursor in the left upper corner of your monitor
Exilon
ExilonOP•3y ago
just checking, this is what my NativeMethods.json should look like right?
Jester
Jester•3y ago
i set single file to true and then there are a few other options but looks good
Exilon
ExilonOP•3y ago
And this is how NativeMethods.txt should look right?
Jester
Jester•3y ago
yes
Exilon
ExilonOP•3y ago
SetCursorPos doesn't exist in the current context
Jester
Jester•3y ago
got the namespace? it might take a second for it to realise it got generated as well
Exilon
ExilonOP•3y ago
Nope Can I use more than 1 namespace at a time?
Jester
Jester•3y ago
yes like any other namespace using Windows.Win32; using static Windows.Win32.Pinvoke; etc
Exilon
ExilonOP•3y ago
Ahhhhh Lol I was doing it wrong What namespace specifically should I be using?
Jester
Jester•3y ago
it puts different headers across different namespaces sonyou might have to look around
Exilon
ExilonOP•3y ago
Ah ok
Jester
Jester•3y ago
got it to work?
Exilon
ExilonOP•3y ago
Yep! lemme test it nvm
Exilon
ExilonOP•3y ago
This happened when building
Exilon
ExilonOP•3y ago
The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
Jester
Jester•3y ago
so did you put thr package in a class library project and this code in a console project or wpf?
Exilon
ExilonOP•3y ago
WPF
Jester
Jester•3y ago
you need to make a reference from this wpf project to that class library
Exilon
ExilonOP•3y ago
Ok what is the dir its installed in?
Jester
Jester•3y ago
no
Exilon
ExilonOP•3y ago
I cd'd into the project dir (the one the sln is in) and installed there oh
Jester
Jester•3y ago
right click and then add project reference i think
Exilon
ExilonOP•3y ago
Exilon
ExilonOP•3y ago
This window?
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
euh can you show your project explorer
Exilon
ExilonOP•3y ago
Sure
Exilon
ExilonOP•3y ago
Oh is it in here?
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
i only see 1 project in your solution
Exilon
ExilonOP•3y ago
OHHH
Jester
Jester•3y ago
the class library project should be in the same solution to be simple
Exilon
ExilonOP•3y ago
How do you add a class library to a sln?
Jester
Jester•3y ago
right click on the solution ans then add new project
Exilon
ExilonOP•3y ago
Class lib or WPF class lib?
Jester
Jester•3y ago
normal class lib
Exilon
ExilonOP•3y ago
I drop the NativeMethods in the class lib?
Jester
Jester•3y ago
yes and install the nuget package in the class lib not in the wpf project
Exilon
ExilonOP•3y ago
Ohhh How do I remove it from the WPF project?
Jester
Jester•3y ago
manage nuget uninstall
Exilon
ExilonOP•3y ago
This window?
Jester
Jester•3y ago
yes its empty <:PES_Think:639363477458255874>
Exilon
ExilonOP•3y ago
I didnt install VIA nuget
Jester
Jester•3y ago
ohh
Exilon
ExilonOP•3y ago
I installed through dotnet add
Jester
Jester•3y ago
uhhh
Exilon
ExilonOP•3y ago
Whatever Ill deal with that later brb ill be gone for 30 min
Exilon
ExilonOP•3y ago
@Jester Im back. I've imported the CsWin32 lib into the class library and added both NativeMethods. What do I do now?
Jester
Jester•3y ago
add project reference from twitch to the classlib
Exilon
ExilonOP•3y ago
Add the reference of twitch TO classlib?
Exilon
ExilonOP•3y ago
just making sure
Jester
Jester•3y ago
no the opposite
Exilon
ExilonOP•3y ago
done
Jester
Jester•3y ago
the namespaeces should work now
Exilon
ExilonOP•3y ago
Is there anything I have to put in Class1.cs?
Jester
Jester•3y ago
no you can remove that
Exilon
ExilonOP•3y ago
So it should look like this yes?
Jester
Jester•3y ago
yes
Exilon
ExilonOP•3y ago
and by namespace, you mean using Win32ClassLib;?
Jester
Jester•3y ago
windows.win32?
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
Win32
Exilon
ExilonOP•3y ago
The type or namespace name 'win32' does not exist in the namespace 'Windows' (are you missing an assembly reference?) oky oh it works lmfao
Jester
Jester•3y ago
Cheergi
Exilon
ExilonOP•3y ago
This is still here
Exilon
ExilonOP•3y ago
nearly there thoughh
Jester
Jester•3y ago
in the pinvoke static class PInvoke
Exilon
ExilonOP•3y ago
Oh yea using static Windows.Win32.PInvoke; i forgot where it was lol
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
ah yes in the json there is an option to use public classes instead of internal
Exilon
ExilonOP•3y ago
What is it? or where do I find it?
Jester
Jester•3y ago
in the website the json schema refers to
Exilon
ExilonOP•3y ago
Okies. Also whats the point of putting the library in a seperate class library?
Jester
Jester•3y ago
well its easier to reuse the library in other projects i guess and in the earluer previews vs would become unusably laggy if you didnt do that
Exilon
ExilonOP•3y ago
ok
Exilon
ExilonOP•3y ago
Wtf is all of this?
Exilon
ExilonOP•3y ago
It w it kinda works Idk what caused this tho
Jester
Jester•3y ago
idk
Exilon
ExilonOP•3y ago
:/
Exilon
ExilonOP•3y ago
Is it okay to have the class lib inside the project?
Jester
Jester•3y ago
thonk
Exilon
ExilonOP•3y ago
Lemme try
Jester
Jester•3y ago
i would think not but idk
Exilon
ExilonOP•3y ago
IT WORKS IM SUCH A GIGABRAIN IDIOT
Jester
Jester•3y ago
peepoDumb
Exilon
ExilonOP•3y ago
Even the cursor moves!
Jester
Jester•3y ago
lets goo now this was the easy part trollface
Exilon
ExilonOP•3y ago
This is immensely epic fuck
Exilon
ExilonOP•3y ago
fuck me so I can't just use CreateWindowExW();? This is all in C++ :(
Jester
Jester•3y ago
with just this method you cant make a window not sure why it leaves out the procedure and message pump
Exilon
ExilonOP•3y ago
💀
Jester
Jester•3y ago
you need at least all of these
Exilon
ExilonOP•3y ago
I have them in the text file...
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style

// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);

if (hwnd == NULL)
{
return 0;
}
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style

// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);

if (hwnd == NULL)
{
return 0;
}
This is what I have to do right> I assume you have to import using static Windows.Win32.Foundation.HWND;
Jester
Jester•3y ago
no it using Windows.Win32.Foundation;
Exilon
ExilonOP•3y ago
oky ayy And I create a window with these params?
Jester
Jester•3y ago
yes thats the basic window if you need some constants like WM_something you can also put those names in the txt
Exilon
ExilonOP•3y ago
The name 'CreateWindowExW' does not exist in the current context ok It there another namespace?
Jester
Jester•3y ago
there are many
Exilon
ExilonOP•3y ago
Okay... Anything specifically that I need to insert to get CreateWindowExW
Jester
Jester•3y ago
it should be in the PInvoke class all methods should be
Exilon
ExilonOP•3y ago
hmmm HWND hwnd = CreateWindowExW(); this is the line if it help helps
Jester
Jester•3y ago
you need to pass the parameters
Exilon
ExilonOP•3y ago
If i just put WS_EX_TRANSPARENT in the txt file will it be useable?
Jester
Jester•3y ago
yes but it might be turned into an enum thats in some namespace the intellisense should show you that
Exilon
ExilonOP•3y ago
:/ intellisense isnt showing me anything :/ Found it myself
Jester
Jester•3y ago
yes it can struggle a little with the generated code Sadge
Exilon
ExilonOP•3y ago
:/ Whats the second param?
Jester
Jester•3y ago
look it up in the docs they tell you all the details
Exilon
ExilonOP•3y ago
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style

// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);

if (hwnd == NULL)
{
return 0;
}
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style

// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);

if (hwnd == NULL)
{
return 0;
}
class name apparently that would just be Window right? What is hInstance? also for some reason CreateWindowExW doesn't exist in the context but CreateWindowEx does are they the same?
Jester
Jester•3y ago
class name should be the same as the name in the windowclass you registered before doing create window
Exilon
ExilonOP•3y ago
Ah
Jester
Jester•3y ago
depending on your json it refers to the utf16 version(as c# strings) or ascii version can be null
Exilon
ExilonOP•3y ago
so Window overlay; i pass overlay as a param
Jester
Jester•3y ago
no
Exilon
ExilonOP•3y ago
"overlay" no?
Jester
Jester•3y ago
WNDCLASS its name field its in the docs i linked
Exilon
ExilonOP•3y ago
okie dokie
Jester
Jester•3y ago
well uuhhh youre probably going to need an unsafe context and pointers
Exilon
ExilonOP•3y ago
💀
Jester
Jester•3y ago
thats what you get with C api's
Exilon
ExilonOP•3y ago
Crap
Jester
Jester•3y ago
yeah the syntax isnt exactly the same that would be fixed (char* className = too much for me to type i have stuff to do) WNDCLASS wc = default;
Exilon
ExilonOP•3y ago
This is for C#?
Jester
Jester•3y ago
yes
Exilon
ExilonOP•3y ago
because it says it cannot convert string to char
Jester
Jester•3y ago
fixed statement - C# reference
Use the C# fixed statement to pin a moveable variable for the duration of the statement.
Jester
Jester•3y ago
thats bcuz c# is managed
Exilon
ExilonOP•3y ago
ohoh
Jester
Jester•3y ago
in c# pointers are even more risky <:PES_Cool:513334287198584834>
Exilon
ExilonOP•3y ago
I havent even gotten around to learning them
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
close
Exilon
ExilonOP•3y ago
unsafe context hmmm
Jester
Jester•3y ago
at the bottom of the docs there is a string example here
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
Thinkies the [] thats not a thing in c# and the ; at the end
Exilon
ExilonOP•3y ago
Okay. Even the example doesnt work
Jester
Jester•3y ago
did you enable unsafe
Exilon
ExilonOP•3y ago
probably not lol how would i do that?
Jester
Jester•3y ago
properties of the project
Exilon
ExilonOP•3y ago
Jester
Jester•3y ago
yes
Exilon
ExilonOP•3y ago
Its been on the whole time
Jester
Jester•3y ago
<a:aPES_Think:493353113332219924> then whats wrong
ero
ero•3y ago
tell us the error? mismatched {} it looks like to me
Jester
Jester•3y ago
likely
Exilon
ExilonOP•3y ago
What the fuck? its fine but when i add unsafe {} it freaks out
Jester
Jester•3y ago
this thread will take a week
Exilon
ExilonOP•3y ago
Honestly lol You said a 100 lines forgot to mention that every other word gives an error You know what I might do Ill try take another route at doing this maybe make another branch but ill keep learning Win32 cuz it seems useful
Jester
Jester•3y ago
thats true i made it sound easy
Exilon
ExilonOP•3y ago
lol
Jester
Jester•3y ago
im a win32 enjoyer gigachad
Exilon
ExilonOP•3y ago
Are there any tutorials on this I can use so I can pester you less?
Jester
Jester•3y ago
for c# probably not many
Exilon
ExilonOP•3y ago
I wish but unfortunately, I have not enjoyed win32 lol what about cpp? Is it worth learning or am I gonna end up dying myself?
Jester
Jester•3y ago
well personally i keep it C i have no idea how to use the std
ero
ero•3y ago
if you're going low level, you might as well go the lowest level reasonably possible which is c
Exilon
ExilonOP•3y ago
I still dont know the difference lmao
Jester
Jester•3y ago
do all the win32 stuff in a C dll and then interop that dll you made into C# KEKW you onky need a few easy calls inbetween
Exilon
ExilonOP•3y ago
Literally just keep it at c lmao
Jester
Jester•3y ago
i want someone to port .net to c
Exilon
ExilonOP•3y ago
Isnt Win32 .Net?
Jester
Jester•3y ago
win32 is from the ancient windows days long before c#
Exilon
ExilonOP•3y ago
Oh
ero
ero•3y ago
it's literal kernel stuff
Exilon
ExilonOP•3y ago
So the neato stuff that WPF can do isnt on Win32
ero
ero•3y ago
it all kinda builds upon win32 everything does, really
Jester
Jester•3y ago
yea
Exilon
ExilonOP•3y ago
Lol
Jester
Jester•3y ago
kernel => win32 => basically anything on windows
Exilon
ExilonOP•3y ago
@Jester Wait so can Win32 code be ported into WPF? Like converted not written in CS
Jester
Jester•3y ago
idk what you mean
Exilon
ExilonOP•3y ago
You know how I've kinda been writing C code in cs?
Jester
Jester•3y ago
yes
ero
ero•3y ago
you haven't lol
Exilon
ExilonOP•3y ago
Kinda Idk how to explain it
ero
ero•3y ago
you write c# code in c#
Jester
Jester•3y ago
unsafe c# is quite c-ish especially with interop
Exilon
ExilonOP•3y ago
Is there a way to convert C code into C#?
Jester
Jester•3y ago
id like to know thst would be nice
Exilon
ExilonOP•3y ago
ok :<
ero
ero•3y ago
convert how? you can write code that's equivalent, sure also maybe look into clangsharp? #allow-unsafe-blocks will know more
Exilon
ExilonOP•3y ago
THATS A CHANNEL!? Lmao okay ill look into it
Jester
Jester•3y ago
thats a channel for nerds trollface
Exilon
ExilonOP•3y ago
lol
Want results from more Discord servers?
Add your server