inline functions

  • Thread starter Thread starter Will Pittenger
  • Start date Start date
Will Pittenger said:
That
means that if your control uses DrawFrameControl for objects that look like
buttons, they will look like buttons regardless of which Windows version you
are on.

Not in xp
All you would ever paint is the graphic. That is
what you use DrawFrameControl for.

That is not correct, you have to use uxtheme-drawing for xp
Draw3dRect (MFC only) lets you draw the
drop border you need for custom edit box-like areas.
DrawEdge (MFC and GDI)
is what you would use if you wanted a group box style etched (or raised)
line, or a diagonal 3d line.

dotnet uses GDI+, that's the reason those methods exists in the WindowsForms
namespace and not in Drawing.
DirectX and OpenGL sound like the sledge hammer providing a
slight tap.

i agree that are not yet ready for normal apps, but seems that is changing
 
The .NET GDI implementation is a medium-thickness wrapper around
the direct Win32 GDI calls. You can take in HBITMAPS, HWNDs,
HDCs, etc. You can create brushes, but I can't see where you can
create a .NET brush from an HBRUSH handle. I'm not a GDI expert,
so please forgive me, I'm probbly

Again, C# is just a language, we're really talking about .NET here,
..NET has all the functionality, C# is just a language.
If you so liked, you could write mostly equivalent code in VB.NET,
COBOL.NET, Python.NET, J#, etc.

-c


Will Pittenger said:
If your C# code is called on to draw something by older C-style code, that
C-style code is probably going to pass HBRUSHs and HWNDs rather than the
C#/.NET equivalents. (You might be reimplementing a DLL that an older C
program relied on. You are keeping the older program.)
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
You can call all but a handful of Win32 APIs from .NET.

So if you can do it through GDI, then you can do it in Win32.
A lot of the GDI is implemented in the .NET Framework already.

I'm not familiar with your specific case, but it's probably
doable in .NET, though I'm not sure why'd you'd be doing such
things. It seems C++ developers like to break from the norm
and rewrite the entire UI and you end up with horrible UIs
that are inconsistent with the rest of the OS. The .NET
framework provides dozens of controls that are all XP-themeable.
You'd have a hard time finding a reason where those aren't
good enough (well, fancier DataGrids are pretty handy, but
as far as basic controls like textboxes, etc).

-c

Will Pittenger said:
Why get DirectX or OpenGL in involved to just a bunch of button
and
other
control classes? Besides, DrawFrameControl uses the same Windows
code
that
Windows itself uses to draw caption bar buttons, radio buttons, scrollbars,
and more. (The control's WM_PAINT handler calls
DrawFrameControl.)
That
means that if your control uses DrawFrameControl for objects that
look
like
buttons, they will look like buttons regardless of which Windows version you
are on. You might have written a button class that displays
graphics
for
Windows 3.1 and it would look like a Windows 3.1 button until you
ran
the
program under Windows 9x. Then Windows would make your button
look
like a
Windows 9x button. If you later provided a manifest, you could
skin
your
button -- with no code. All you would ever paint is the graphic. That is
what you use DrawFrameControl for. Draw3dRect (MFC only) lets you draw the
drop border you need for custom edit box-like areas. DrawEdge
(MFC
and GDI)
is what you would use if you wanted a group box style etched (or raised)
line, or a diagonal 3d line. I think that Jay Harlow provided
what I
was
looking for. DirectX and OpenGL sound like the sledge hammer providing a
slight tap.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Managed DirectX 9. Anything you could possibly want.

What is CDC? Why would you want to use that over DX anyhow?

Also, there's an OpenGL implementation for .NET (written in
C#, remember, C# is just a language, it doens't really provide
anything, .NET provides all the functionality).

-c

Almost forgot. CDC provides THREE members which draw 3D
edges
and/or
rectangles. How many does Graphics in C# provide? I see none.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
The scenario that I had in mind was you have to use a DLL
that
is
already
on
a user's machine. You are required to coexist with a larger and
older MFC
based program. Most of what you need is in one of its DLLs.
Perhaps that
DLL has tools for accessing a file format that you have no control
or
knowledge of. I have had to put up with that many times. Good
luck.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++
to
make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a
very
long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework
library
with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension
library.
Such
a
library might have functions taking as parameters and/or
returning
CStrings
and CWnds. (Or for that matter a generic C++ style class.)
What
would be
the equivalent of pure virtual functions and multiple
derivation? I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember,
.NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like
has
all
the
good stuff and almost none of the bad of C++. To
each
his
own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived
ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++
code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better
determine
at run-time which optimizations will have the most impact.

-c

message
Would JIT apply to a local executable? I do not
anticipate
doing
any
web
stuff for a while. I am looking at doing some
things
that
I
think
that C++
is better equipped for than C# (which seems to be
castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
"Grant Richins [MS]"
However,
the warranties,
and wrote
in
 
Note that I said all but a handful. Unfortunately I don't
know the entire Win32 API and how they all relate to .NET,
but I wouldn't be suprised if a handful didn't work in .NET.

As far as process rights, like activating a token privilege,
I know that most of those work. I'm not sure about your specific
case.

As far as exit windows for reboot, I'm pretty sure that works,
but again, there are various parameters to ExitWindows and
ExitWindowsEx, and some of those might not be possible in .NET,
but I could be wrong.

Most of the Win32 API works, the problem is various Functions
take or return complicated structures that have variable
sized memory patterns which can be complicated, or, in some
cases, impossible to do with .NET's managed memory space.

-c

Will Pittenger said:
I was told earlier that the Win32 functions for exiting Windows and checking
or changing process rights were not available through .NET. Are you going
to tell me something different?
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
You can call all but a handful of Win32 APIs from .NET.

So if you can do it through GDI, then you can do it in Win32.
A lot of the GDI is implemented in the .NET Framework already.

I'm not familiar with your specific case, but it's probably
doable in .NET, though I'm not sure why'd you'd be doing such
things. It seems C++ developers like to break from the norm
and rewrite the entire UI and you end up with horrible UIs
that are inconsistent with the rest of the OS. The .NET
framework provides dozens of controls that are all XP-themeable.
You'd have a hard time finding a reason where those aren't
good enough (well, fancier DataGrids are pretty handy, but
as far as basic controls like textboxes, etc).

-c

Will Pittenger said:
Why get DirectX or OpenGL in involved to just a bunch of button
and
other
control classes? Besides, DrawFrameControl uses the same Windows
code
that
Windows itself uses to draw caption bar buttons, radio buttons, scrollbars,
and more. (The control's WM_PAINT handler calls
DrawFrameControl.)
That
means that if your control uses DrawFrameControl for objects that
look
like
buttons, they will look like buttons regardless of which Windows version you
are on. You might have written a button class that displays
graphics
for
Windows 3.1 and it would look like a Windows 3.1 button until you
ran
the
program under Windows 9x. Then Windows would make your button
look
like a
Windows 9x button. If you later provided a manifest, you could
skin
your
button -- with no code. All you would ever paint is the graphic. That is
what you use DrawFrameControl for. Draw3dRect (MFC only) lets you draw the
drop border you need for custom edit box-like areas. DrawEdge
(MFC
and GDI)
is what you would use if you wanted a group box style etched (or raised)
line, or a diagonal 3d line. I think that Jay Harlow provided
what I
was
looking for. DirectX and OpenGL sound like the sledge hammer providing a
slight tap.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Managed DirectX 9. Anything you could possibly want.

What is CDC? Why would you want to use that over DX anyhow?

Also, there's an OpenGL implementation for .NET (written in
C#, remember, C# is just a language, it doens't really provide
anything, .NET provides all the functionality).

-c

Almost forgot. CDC provides THREE members which draw 3D
edges
and/or
rectangles. How many does Graphics in C# provide? I see none.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
The scenario that I had in mind was you have to use a DLL
that
is
already
on
a user's machine. You are required to coexist with a larger and
older MFC
based program. Most of what you need is in one of its DLLs.
Perhaps that
DLL has tools for accessing a file format that you have no control
or
knowledge of. I have had to put up with that many times. Good
luck.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++
to
make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a
very
long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework
library
with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension
library.
Such
a
library might have functions taking as parameters and/or
returning
CStrings
and CWnds. (Or for that matter a generic C++ style class.)
What
would be
the equivalent of pure virtual functions and multiple
derivation? I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember,
.NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like
has
all
the
good stuff and almost none of the bad of C++. To
each
his
own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived
ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++
code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better
determine
at run-time which optimizations will have the most impact.

-c

message
Would JIT apply to a local executable? I do not
anticipate
doing
any
web
stuff for a while. I am looking at doing some
things
that
I
think
that C++
is better equipped for than C# (which seems to be
castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
"Grant Richins [MS]"
However,
the warranties,
and wrote
in
 
So if I am calling System.Windows.Forms.ControlPaint.DrawButton, what would
be the ButtonState value that would correspond to DFCS_HOT when calling
DrawFrameControl?

--
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Jay B. Harlow said:
Will,
Most of the 3d edges and/or rectangles functions are in the
System.Windows.Forms.ControlPaint class.

I would recommend considering creating a Managed wrapper for your MFC legacy
DLL. Something along the lines of:
http://msdn.microsoft.com/library/d...nstrateswrappingcdllwithmanagedextensions.asp

Hope this helps
Jay

Will Pittenger said:
Almost forgot. CDC provides THREE members which draw 3D edges and/or
rectangles. How many does Graphics in C# provide? I see none.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
already
derivation?
I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember, ..NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some things that I
think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However, the .NET
runtime/JIT
is
allowed to inline functions, and often does.

--
--Grant
This posting is provided "AS IS" with no warranties, and
confers
no
rights.


Does C# inline functions? I do not see a inline keyword.
Is
there an
implicit inline? Can the compiler select functions for
auto-inlining?
I
am
more used to C++ where all these things are possible.
 
There is none in the Framework.

You'd have to call DrawFrameControl manually.

The .NET Framework does not encompass the entire Win32 API,
which is why you have to call the methods sometime. If you
wish to use that as an excuse to forgo all the other great
features .NET has for that one function, that's great for
you, I guess.

public struct RECT
{
int left;
int top;
int right;
int bottom;
}

[DllImport("gdi32.dll")]
private static extern DrawFrameControl(
IntPtr hdc,
ref RECT lprc,
uint uType,
uint uState
)

public const DFC_BUTTON = 0x4;

public const DFCS_HOT = 0x1000;

....

RECT r = new RECT()
r.left = 5;
r.top = 5;
r.right = 20;
r.bottom = 10;

DrawFrameControl( button1.Handle, ref r, DFC_BUTTON, DFCS_HOT );

-c



Will Pittenger said:
So if I am calling System.Windows.Forms.ControlPaint.DrawButton, what would
be the ButtonState value that would correspond to DFCS_HOT when calling
DrawFrameControl?

--
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Will,
Most of the 3d edges and/or rectangles functions are in the
System.Windows.Forms.ControlPaint class.

I would recommend considering creating a Managed wrapper for your
MFC
legacy
DLL. Something along the lines of:
http://msdn.microsoft.com/library/d...nstrateswrappingcdllwithmanagedextensions.asp
Hope this helps
Jay

is
already older
MFC Perhaps
that
class.)
What derivation?
Remember,
.NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some things that I
think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However,
the
.NET
runtime/JIT
is
allowed to inline functions, and often does.

--
--Grant
This posting is provided "AS IS" with no warranties, and
confers
no
rights.


"Will Pittenger" <[email protected]> wrote
in
message
Does C# inline functions? I do not see a inline keyword.
Is
there an
implicit inline? Can the compiler select functions for
auto-inlining?
I
am
more used to C++ where all these things are possible.
 
Actually, no. I would prefer to stay with the .NET as it is handier.
However, I can not find the appropriate stuff half of the time. In this
case, all Microsoft had to do was add the appropriate value to the
ButtonStyle enum. Problem solved. I say that as it sounds like
ControlPaint uses DrawFrameControl behind the scenes for many of its
methods. DrawButton probably evaluates to just a call to DrawFrameControl
with DFC_BUTTON added for you. (That parameter is not in the UI, but since
DrawButton draws only generic buttons, it can be assumed.) I expect the
ButtonStyle values to be defined to match the DFCS values in the SDK. Just
typecast the enum to an int and you are done. In fact, you could declare
you import of DrawFrameControl to do the type cast for you if the enum is
declared properly.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
There is none in the Framework.

You'd have to call DrawFrameControl manually.

The .NET Framework does not encompass the entire Win32 API,
which is why you have to call the methods sometime. If you
wish to use that as an excuse to forgo all the other great
features .NET has for that one function, that's great for
you, I guess.

public struct RECT
{
int left;
int top;
int right;
int bottom;
}

[DllImport("gdi32.dll")]
private static extern DrawFrameControl(
IntPtr hdc,
ref RECT lprc,
uint uType,
uint uState
)

public const DFC_BUTTON = 0x4;

public const DFCS_HOT = 0x1000;

...

RECT r = new RECT()
r.left = 5;
r.top = 5;
r.right = 20;
r.bottom = 10;

DrawFrameControl( button1.Handle, ref r, DFC_BUTTON, DFCS_HOT );

-c



Will Pittenger said:
So if I am calling System.Windows.Forms.ControlPaint.DrawButton, what would
be the ButtonState value that would correspond to DFCS_HOT when calling
DrawFrameControl?

--
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
MFC
http://msdn.microsoft.com/library/d...nstrateswrappingcdllwithmanagedextensions.asp
Hope this helps
Jay

Almost forgot. CDC provides THREE members which draw 3D edges and/or
rectangles. How many does Graphics in C# provide? I see none.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
The scenario that I had in mind was you have to use a DLL that is
already
on
a user's machine. You are required to coexist with a larger and older
MFC
based program. Most of what you need is in one of its DLLs. Perhaps
that
DLL has tools for accessing a file format that you have no control or
knowledge of. I have had to put up with that many times. Good luck.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++ to make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a very long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework library with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension library.
Such
a
library might have functions taking as parameters and/or returning
CStrings
and CWnds. (Or for that matter a generic C++ style
class.)
What
would be
the equivalent of pure virtual functions and multiple derivation?
I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#.
Remember,
.NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived
ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some things that I
think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However, the
.NET
runtime/JIT
is
allowed to inline functions, and often does.

--
--Grant
This posting is provided "AS IS" with no warranties, and
confers
no
rights.


message
Does C# inline functions? I do not see a inline keyword.
Is
there an
implicit inline? Can the compiler select functions for
auto-inlining?
I
am
more used to C++ where all these things are possible.
 
I agree, it's curious they left that one out. There are several
cases like that, unfortunately.

The WinForms/GDI stuff was hastely put together, it seems
as there are at least one or two spots there you can allocate
a Graphics object from an HBITMAP and have no way to free it
except make a PInvoke call to gdi32.dll::Delete() or DeleteDC
or something like that.

My guess is that 2.0 will be much, much better at least
in that area.

-c

Will Pittenger said:
Actually, no. I would prefer to stay with the .NET as it is handier.
However, I can not find the appropriate stuff half of the time. In this
case, all Microsoft had to do was add the appropriate value to the
ButtonStyle enum. Problem solved. I say that as it sounds like
ControlPaint uses DrawFrameControl behind the scenes for many of its
methods. DrawButton probably evaluates to just a call to DrawFrameControl
with DFC_BUTTON added for you. (That parameter is not in the UI, but since
DrawButton draws only generic buttons, it can be assumed.) I expect the
ButtonStyle values to be defined to match the DFCS values in the SDK. Just
typecast the enum to an int and you are done. In fact, you could declare
you import of DrawFrameControl to do the type cast for you if the enum is
declared properly.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
There is none in the Framework.

You'd have to call DrawFrameControl manually.

The .NET Framework does not encompass the entire Win32 API,
which is why you have to call the methods sometime. If you
wish to use that as an excuse to forgo all the other great
features .NET has for that one function, that's great for
you, I guess.

public struct RECT
{
int left;
int top;
int right;
int bottom;
}

[DllImport("gdi32.dll")]
private static extern DrawFrameControl(
IntPtr hdc,
ref RECT lprc,
uint uType,
uint uState
)

public const DFC_BUTTON = 0x4;

public const DFCS_HOT = 0x1000;

...

RECT r = new RECT()
r.left = 5;
r.top = 5;
r.right = 20;
r.bottom = 10;

DrawFrameControl( button1.Handle, ref r, DFC_BUTTON, DFCS_HOT );

-c



Will Pittenger said:
So if I am calling System.Windows.Forms.ControlPaint.DrawButton,
what
would
be the ButtonState value that would correspond to DFCS_HOT when calling
DrawFrameControl?

--
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
"Jay B. Harlow [MVP - Outlook]" <[email protected]> wrote
in
message
Will,
Most of the 3d edges and/or rectangles functions are in the
System.Windows.Forms.ControlPaint class.

I would recommend considering creating a Managed wrapper for
your
MFC
legacy
DLL. Something along the lines of:
http://msdn.microsoft.com/library/d...nstrateswrappingcdllwithmanagedextensions.asp
Hope this helps
Jay

Almost forgot. CDC provides THREE members which draw 3D
edges
and/or
rectangles. How many does Graphics in C# provide? I see none.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
The scenario that I had in mind was you have to use a DLL
that
is
already
on
a user's machine. You are required to coexist with a larger
and
older
MFC
based program. Most of what you need is in one of its DLLs. Perhaps
that
DLL has tools for accessing a file format that you have no control or
knowledge of. I have had to put up with that many times.
Good
luck.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++
to
make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a
very
long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework
library
with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension library.
Such
a
library might have functions taking as parameters and/or
returning
CStrings
and CWnds. (Or for that matter a generic C++ style class.)
What
would be
the equivalent of pure virtual functions and multiple
derivation?
I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember,
.NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like
has
all the
good stuff and almost none of the bad of C++. To
each
his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived
ultra-performance
scenarios, .NET has many advantages over unmanaged
C/C++
code.
Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

"Will Pittenger" <[email protected]> wrote
in
message
Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some
things
that I
think
that C++
is better equipped for than C# (which seems to be
castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
"Grant Richins [MS]"
wrote in However,
the warranties,
and wrote
in
 
You could (and should) multithread the application so that it is possible to
deal with input at the same time as painting. You could even turn the
painting priority down in comparison to the input priority. This doesn't
make the painting faster, but it gets around your crash into the
mountain/other boat scenario.

Niall

Will Pittenger said:
Here is another hypothetical scenario for you, also based on real world
experience:

You are working on a computer program that will fly airplanes. One program,
running on just one computer (with perhaps backups that do nothing unless
there is a major problem) displays a map of where you are and routes
commands from the controls to the flight system. (The stick and rudder
pedal are just computer controls, like on many modern aircraft.) You have
to update the screen quickly so the pilot knows where he or she is.
However, you do not want to spend any serious amount of time (as measured in
a percentage of CPU cycles used) painting the screen. If you spend too much
time painting, the airplane could be headed towards a big mountain, but
never responds to the pilot's attempt to turn it away from that mountain
because it is too busy updating the screen. If you are a passenger on that
plane, what do you want updating the screen: Windows GDI, MFC, C# and
Graphics, OpenGL, or DirectX? If a fancy look were important, you might
vote for DirectX or OpenGL. But with lives on the line, you very quickly
consider fancy graphics to be extra baggage. At that point, I vote for the
Windows GDI. Now if .NET implements its stuff at a lower level than I have
the impression that it does, perhaps it would work. Not otherwise.

Now in a real airplane, there would be many computers to drive just the
displays. The controls would be on a second set of systems. Still, we ran
into that problem where the software runs boats. We were not talking about
something that sold for hundreds of million of dollars. Customers spent
only a small fraction of their money on the computers and software. A
luxurious interior is typically more important. You get one computer, and
you are lucky if it is a top of the line laptop. Most of the marine worthy
laptops are slow even new even compared to just other laptops.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


Chad Myers said:
How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++ to make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a very long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework library with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension library. Such
a
library might have functions taking as parameters and/or returning
CStrings
and CWnds. (Or for that matter a generic C++ style class.) What
would be
the equivalent of pure virtual functions and multiple derivation? I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember, .NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate doing
any
web
stuff for a while. I am looking at doing some things that I think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However, the .NET
runtime/JIT
is
allowed to inline functions, and often does.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers
no
rights.


Does C# inline functions? I do not see a inline keyword. Is
there an
implicit inline? Can the compiler select functions for
auto-inlining?
I
am
more used to C++ where all these things are possible.
 
Not really. The applications like that I worked on were multi-threaded. If
the drawing was too slow, the CPU was still unavailable because of Windows'
problems pre-empting threads. From what I understand, Unix and possibly
Linux would solve that problem, but the typically users of that kind of
application have no idea what the difference between a parallel cable and a
USB cable is. Do not even think of attempting to get them to understand
Unix. You would have a nightmare of a technical support problem.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Niall said:
You could (and should) multithread the application so that it is possible to
deal with input at the same time as painting. You could even turn the
painting priority down in comparison to the input priority. This doesn't
make the painting faster, but it gets around your crash into the
mountain/other boat scenario.

Niall

Will Pittenger said:
Here is another hypothetical scenario for you, also based on real world
experience:

You are working on a computer program that will fly airplanes. One program,
running on just one computer (with perhaps backups that do nothing unless
there is a major problem) displays a map of where you are and routes
commands from the controls to the flight system. (The stick and rudder
pedal are just computer controls, like on many modern aircraft.) You have
to update the screen quickly so the pilot knows where he or she is.
However, you do not want to spend any serious amount of time (as
measured
in
a percentage of CPU cycles used) painting the screen. If you spend too much
time painting, the airplane could be headed towards a big mountain, but
never responds to the pilot's attempt to turn it away from that mountain
because it is too busy updating the screen. If you are a passenger on that
plane, what do you want updating the screen: Windows GDI, MFC, C# and
Graphics, OpenGL, or DirectX? If a fancy look were important, you might
vote for DirectX or OpenGL. But with lives on the line, you very quickly
consider fancy graphics to be extra baggage. At that point, I vote for the
Windows GDI. Now if .NET implements its stuff at a lower level than I have
the impression that it does, perhaps it would work. Not otherwise.

Now in a real airplane, there would be many computers to drive just the
displays. The controls would be on a second set of systems. Still, we ran
into that problem where the software runs boats. We were not talking about
something that sold for hundreds of million of dollars. Customers spent
only a small fraction of their money on the computers and software. A
luxurious interior is typically more important. You get one computer, and
you are lucky if it is a top of the line laptop. Most of the marine worthy
laptops are slow even new even compared to just other laptops.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++ to make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a very long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework library with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension library.
Such
a
library might have functions taking as parameters and/or returning
CStrings
and CWnds. (Or for that matter a generic C++ style class.) What
would be
the equivalent of pure virtual functions and multiple derivation? I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember, .NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some things that I
think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However, the ..NET
runtime/JIT
is
allowed to inline functions, and often does.

--
--Grant
This posting is provided "AS IS" with no warranties, and
confers
no
rights.


Does C# inline functions? I do not see a inline keyword.
Is
there an
implicit inline? Can the compiler select functions for
auto-inlining?
I
am
more used to C++ where all these things are possible.
 
What problems pre-empting threads? I've seen some damn-near
real time apps run on Windows without any pre-empting problems.

With a finely tuned app that's aware of thread priorities and
quanta guidelines, you can get it to behave pretty well.

Such optimizations would be required on Unix as well.

As far as Linux... if you suggest Linux's threading/proc model
is better than Windows, perhaps you should read some more.

Keep in mind Windows == Windows NT/2K/XP/2K3.

Windows 9x is heretofore referred to as the Bastard Spawn of Hell.

-c

Will Pittenger said:
Not really. The applications like that I worked on were multi-threaded. If
the drawing was too slow, the CPU was still unavailable because of Windows'
problems pre-empting threads. From what I understand, Unix and possibly
Linux would solve that problem, but the typically users of that kind of
application have no idea what the difference between a parallel cable and a
USB cable is. Do not even think of attempting to get them to understand
Unix. You would have a nightmare of a technical support problem.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Niall said:
You could (and should) multithread the application so that it is
possible
to
deal with input at the same time as painting. You could even turn the
painting priority down in comparison to the input priority. This doesn't
make the painting faster, but it gets around your crash into the
mountain/other boat scenario.

Niall

One
program,
You
have measured spend too
much passenger on
that vote for
the than I
have Still, we
ran talking
about
computer,
and marine
worthy
derivation?
I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember, ..NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some things that I
think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However,
the
 
A program whose drawing code is not efficient is not a "finely tuned app
that's aware of thread priorities and quanta guidelines" application. You
proved my point.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Chad Myers said:
What problems pre-empting threads? I've seen some damn-near
real time apps run on Windows without any pre-empting problems.

With a finely tuned app that's aware of thread priorities and
quanta guidelines, you can get it to behave pretty well.

Such optimizations would be required on Unix as well.

As far as Linux... if you suggest Linux's threading/proc model
is better than Windows, perhaps you should read some more.

Keep in mind Windows == Windows NT/2K/XP/2K3.

Windows 9x is heretofore referred to as the Bastard Spawn of Hell.

-c

Will Pittenger said:
Not really. The applications like that I worked on were multi-threaded. If
the drawing was too slow, the CPU was still unavailable because of Windows'
problems pre-empting threads. From what I understand, Unix and possibly
Linux would solve that problem, but the typically users of that kind of
application have no idea what the difference between a parallel cable and a
USB cable is. Do not even think of attempting to get them to understand
Unix. You would have a nightmare of a technical support problem.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Niall said:
You could (and should) multithread the application so that it is
possible
to
deal with input at the same time as painting. You could even turn the
painting priority down in comparison to the input priority. This doesn't
make the painting faster, but it gets around your crash into the
mountain/other boat scenario.

Niall

Here is another hypothetical scenario for you, also based on real world
experience:

You are working on a computer program that will fly airplanes. One
program,
running on just one computer (with perhaps backups that do nothing unless
there is a major problem) displays a map of where you are and routes
commands from the controls to the flight system. (The stick and rudder
pedal are just computer controls, like on many modern aircraft.)
You
have
to update the screen quickly so the pilot knows where he or she is.
However, you do not want to spend any serious amount of time (as measured
in
a percentage of CPU cycles used) painting the screen. If you spend too
much
time painting, the airplane could be headed towards a big mountain, but
never responds to the pilot's attempt to turn it away from that mountain
because it is too busy updating the screen. If you are a passenger on
that
plane, what do you want updating the screen: Windows GDI, MFC, C# and
Graphics, OpenGL, or DirectX? If a fancy look were important, you might
vote for DirectX or OpenGL. But with lives on the line, you very quickly
consider fancy graphics to be extra baggage. At that point, I vote for
the
Windows GDI. Now if .NET implements its stuff at a lower level than I
have
the impression that it does, perhaps it would work. Not otherwise.

Now in a real airplane, there would be many computers to drive just the
displays. The controls would be on a second set of systems. Still, we
ran
into that problem where the software runs boats. We were not talking
about
something that sold for hundreds of million of dollars. Customers spent
only a small fraction of their money on the computers and software. A
luxurious interior is typically more important. You get one
computer,
and
you are lucky if it is a top of the line laptop. Most of the marine
worthy
laptops are slow even new even compared to just other laptops.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
Oh yeah, one other thing... why on EARTH would you want to use
MFC when you have .NET now? I can't even fathom the concept...!!

:)

-c


How should I call functions in a MFC extension library

That's difficult, but if it's a COM interface, it can be done.
Otherwise, you'll have to use Managed Extensions for C++ to make
a wrapper.

That's not a fair criticism of C#, really, because you can't
use .NET assemblies in C++ either.

What would be the equivalent of pure virtual functions

Abstract classes and methods

and multiple derivation

Multiple inheritence, you mean? There was a concious decision
not to support MI in .NET because ... well, that's a very long
debate, but it's not because they couldn't do it, it's because
they didn't want to do it and felt it was wrong to do it.

Let's turn the tables...

What if I wanted didn't want to do any of my memory management
in C++?

What if I wanted to have a comprehensive framework library with
nearly everything you could want built in and supported by
the runtime and compiler?

What if I wanted to make my code cross-platform without any
fancy magic or special #defines?

What if I wanted a pure OO language without any legacy
baggage?

-c


Great. How should I call functions in a MFC extension library.
Such
a
library might have functions taking as parameters and/or returning
CStrings
and CWnds. (Or for that matter a generic C++ style class.) What
would be
the equivalent of pure virtual functions and multiple
derivation?
I
am
sorry, but the jury is still out.
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
JIT applies to all .NET assemblies, not just C#. Remember, .NET
is a system, C# is merely a language on top of it.

As far as C# being castrated, to me, it seems like has all the
good stuff and almost none of the bad of C++. To each his own,
I guess.

They're adding Generics in C# for .NET 2.0 which are similar
to Templates in C++.

As far as finding things C++ does better than .NET, you'll
have a hard time. In all but the most contrived ultra-performance
scenarios, .NET has many advantages over unmanaged C/C++ code.

Check this out:
http://tinyurl.com/3890 [MSDN article]

In many cases, because IL is JIT'd, it runs faster than
equivalent unmanaged code because the JIT can better determine
at run-time which optimizations will have the most impact.

-c

Would JIT apply to a local executable? I do not anticipate
doing
any
web
stuff for a while. I am looking at doing some things that I
think
that C++
is better equipped for than C# (which seems to be castrated).
----------
Will Pittenger
E-Mail: mailto:[email protected]
All mail filtered by Qurb (www.qurb.com)
message
The C# compiler does not inline functions. However,
the
.NET
runtime/JIT
is
allowed to inline functions, and often does.

--
--Grant
This posting is provided "AS IS" with no warranties, and
confers
no
rights.


Does C# inline functions? I do not see a inline keyword.
Is
there an
implicit inline? Can the compiler select functions for
auto-inlining?
I
am
more used to C++ where all these things are possible.
 
Back
Top