S
SpotNet
Hello NewsGroup,
More out of curiosity, now I'd love to know which is a better way, if one
can think in such terms in this context. If I implement the ChooseColor API
function, the documentation states (briefly);
BOOL ChooseColor(LPCHOOSECOLOR lpcc);
lpcc is defined as "...[in, out] Pointer to a CHOOSECOLOR structure that..."
and you know or know where to read the rest of it.
I can interpret hence implement this in two ways (I know this may sound
trivial, I just want to know);
1) CHOOSECOLOR as a class;
private class CCHOOSECOLOR
{
internal Int32 lStructSize = 0;
... //And the rest of it
}
Hence the API call as;
[DllImport("Comdlg32.dll", EntryPoint = "ChooseColor")]
private static extern bool ChooseColor([In, Out] CCHOOSECOLOR lpcc);
internal static bool ChooseColorApi([In, Out] CCHOOSECOLOR lpcc)
{
return ChooseColor(lpcc);
}
---------------------------------------------------------------------------------
2) CHOOSECOLOR as a structure;
private struct CHOOSECOLOR
{
internal Int32 lStructSize;
... //And the rest of it
}
Hence the API call as;
[DllImport("Comdlg32.dll", EntryPoint = "ChooseColor")]
private static extern bool ChooseColor(ref CCHOOSECOLOR lpcc);
internal static bool ChooseColorApi(ref CCHOOSECOLOR lpcc)
{
return ChooseColor(ref lpcc);
}
Both work real well so to get pedantic on you all (sorry about that) would
there be any advantage or disadvantage on one way over the other? Hence
would the be a preferable way? The reason I ask the difference between [In,
Out] and ref is because if I use [In, Out] in the struct version nothing
works and I get errors vice versa as well. Also nothing (obviously) works if
[In, Out] or ref are left out.
Thanks NewGroup, this is no show stopper for me and I only ask out of
curiosity.
Regards,
SpotNet
More out of curiosity, now I'd love to know which is a better way, if one
can think in such terms in this context. If I implement the ChooseColor API
function, the documentation states (briefly);
BOOL ChooseColor(LPCHOOSECOLOR lpcc);
lpcc is defined as "...[in, out] Pointer to a CHOOSECOLOR structure that..."
and you know or know where to read the rest of it.
I can interpret hence implement this in two ways (I know this may sound
trivial, I just want to know);
1) CHOOSECOLOR as a class;
private class CCHOOSECOLOR
{
internal Int32 lStructSize = 0;
... //And the rest of it
}
Hence the API call as;
[DllImport("Comdlg32.dll", EntryPoint = "ChooseColor")]
private static extern bool ChooseColor([In, Out] CCHOOSECOLOR lpcc);
internal static bool ChooseColorApi([In, Out] CCHOOSECOLOR lpcc)
{
return ChooseColor(lpcc);
}
---------------------------------------------------------------------------------
2) CHOOSECOLOR as a structure;
private struct CHOOSECOLOR
{
internal Int32 lStructSize;
... //And the rest of it
}
Hence the API call as;
[DllImport("Comdlg32.dll", EntryPoint = "ChooseColor")]
private static extern bool ChooseColor(ref CCHOOSECOLOR lpcc);
internal static bool ChooseColorApi(ref CCHOOSECOLOR lpcc)
{
return ChooseColor(ref lpcc);
}
Both work real well so to get pedantic on you all (sorry about that) would
there be any advantage or disadvantage on one way over the other? Hence
would the be a preferable way? The reason I ask the difference between [In,
Out] and ref is because if I use [In, Out] in the struct version nothing
works and I get errors vice versa as well. Also nothing (obviously) works if
[In, Out] or ref are left out.
Thanks NewGroup, this is no show stopper for me and I only ask out of
curiosity.
Regards,
SpotNet