Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ Problems

Name: Anonymous 2008-12-11 23:49

I'm using Visual C++ 2005 to make a simple little program. I'm getting compiler errors with the following:

private: System::Void BoxMouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
    if ( e.Button == MouseButtons.Left ) {
        //Shit goes here
    }
}

I've tried the MSDN site, using examples directly from it, but no surprise at all when the shit didn't work.

Name: Anonymous 2008-12-12 0:55

void
e->Button
MouseButtons::Left

Name: Anonymous 2008-12-12 0:59

>>2
Explain more.

Name: Anonymous 2008-12-12 2:35

The event object "e" is passed as a managed reference (MouseEventArgs^).  To get at its members means you use the stabbity -> operator, just as if it were a native pointer (SomeType*).  The . operator is for local stack type instances (native or managed) or things passed as a native reference (SomeType&) or CLR tracking reference (ManagedType%).

Name: Anonymous 2008-12-12 2:38

>>I've tried the MSDN site, using examples directly from it, but no surprise at all when the shit didn't work.

Every MSDN example is buggy to some extent.  I don't know if it's that they don't test any of it, or want to stop copypasta coding or what.

Name: Anonymous 2008-12-12 7:26

>>1
Why are you using that horrible abomination called C++/CLI? If you want to use the .NET framework just use C#.

Name: Anonymous 2008-12-12 8:17

>>6
C# can be pretty terrible at interop at times. Though it's not as bad as F#, I guess.

Name: Anonymous 2008-12-12 12:35

Even Microsoft don't expect people to use Sepples/CLI for more than glue layers between new and legacy code. 

Just put your interop there, and then for the rest of the code you can choose java-on-steroids, lol OCaml sorta, FIOC or slow as fuck.

Name: Anonymous 2008-12-12 15:17

>>4
Using

if (e->Button = MouseButtons::Left) {

gives this:

error C2039: 'Left' : is not a member of System::Windows::Forms::Control::MouseButtons'
error C2039: 'set' : is not a member of 'System::Windows::Forms::MouseEventArgs::Button'

I should probably just go back to Delphi. =/

Name: Anonymous 2008-12-12 15:25

>>9
use c#; it's crap, but still way better than sepples or borland.

Name: Anonymous 2008-12-12 15:39

>>9
I just took this piece of code out of the MouseButtons Enumeration MSDN, pasted it into a brand new WinForms C++ project in VS2008, and it built for me with

      if ( e->Button == System::Windows::Forms::MouseButtons::Left )

so it's hard to tell from just the snippet what's up.

Name: Anonymous 2008-12-12 15:43

>>11
Well, that worked. Why the fuck are there different pages for the same things? The page that I found had the snippet that I started this topic with.

Thanks.

Name: Anonymous 2008-12-12 17:04

>>9
Add a reference to the System.Windows.Forms assembly to resolve the missing symbols

Name: Anonymous 2008-12-12 18:50

if ( e->Button == System::Windows::Forms::MouseButtons::Left ) {
    LOW EXPECTATIONS
}

Name: Anonymous 2011-02-04 16:33

Name: Anonymous 2011-02-04 17:40


Don't change these.
Name: Email:
Entire Thread Thread List