Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

mid 5741

@mid 5741
About
Posts
59
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • RichTextBox: How to wrap on character rather than word?
    M mid 5741

    Is it possible to configure a System.Windows.Forms.RichTextBox to wrap on characters rather than words? Setting RightMargin to the width of the client rectangle and turning off word wrap, I tried replacing every space character with a non-breaking space, but any lines with punctuation will wrap at the punctuation rather than on the rightmost character in the line. It seems like this should be an obvious setting, but I'm stumped.

    Henry David Thoreau wrote:

    Beware of all enterprises that require new clothes.

    Windows Forms tutorial question

  • SOLVED - Passing CObject to OnUpdate - compiler error C2039 [modified]
    M mid 5741

    You need to cast pHint to C_Parameters* before you can call hello on it.

    Henry David Thoreau wrote:

    Beware of all enterprises that require new clothes.

    C / C++ / MFC help csharp c++ visual-studio question

  • Do any body know the encoding formate of .rc file in VS 2005?
    M mid 5741

    It's ANSI in my environment.

    Henry David Thoreau wrote:

    Beware of all enterprises that require new clothes.

    C / C++ / MFC question visual-studio

  • Array of bytes to Korean chars array?
    M mid 5741

    You may have to change the font that your listview uses to show Korean. There's a universal Arial font that has CJK characters. By the way, I took your Korean characters and pasted them into a text file in VS2005 and saved it with 'Unicode - Codepage 1200' encoding. After the identifying BOM in the file, I get: 74 C7 C8 D0 AC B9 44 C5.

    Cyril Connolly wrote:

    Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.

    C# data-structures question

  • Array of bytes to Korean chars array?
    M mid 5741

    Where does the array of bytes come from? Have you tried different encodings, like UTF-8 or UTF-16?

    C# data-structures question

  • DAT recording
    M mid 5741

    There are hard drive- and solid state-based devices now. The main advantage over DAT is the lack of dropouts and the ability to transfer the music to your PC in faster than real time. They can also do 24-bit recording at sampling rates of 88.2 kHz and 96 kHz. Check out this[^] and this[^].

    Cyril Connolly wrote:

    Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.

    The Lounge com question

  • Who can explain this code for me?about virtual function
    M mid 5741

    ProcessIOMessage() is defined as virtual, so the compiler wants to add a vtable for the class. But, because it's an abstract class (due to the = 0) it cannot be instantiated and doesn't need the overhead of the vtable. __declspec(novtable) instructs the compiler to not generate a vtable. A more detailed explanation can be found here[^].

    Cyril Connolly wrote:

    Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.

    C / C++ / MFC question

  • Getting NullReferenceException instead of ArgumentNullException
    M mid 5741

    Are you aware of FxCop[^]? I don't know if it will identify the problem above, but I analyzed a project and FxCop found a couple of instances of not checking if an object was valid before using it.

    Cyril Connolly wrote:

    Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.

    C# csharp com question

  • Getting NullReferenceException instead of ArgumentNullException
    M mid 5741

    It's not a string exception, it's a runtime exception. You're calling a method on a null object.

    Cyril Connolly wrote:

    Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.

    C# csharp com question

  • Getting NullReferenceException instead of ArgumentNullException
    M mid 5741

    Have you checked myString to see if it's null or not?

    Cyril Connolly wrote:

    Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.

    C# csharp com question

  • Determine if VC++ 2005 SP1 runtime is installed?
    M mid 5741

    I meant programmatically determining if it's installed. -- modified at 22:46 Saturday 8th September, 2007 Nevermind. I found it: 1. Call the MsiQueryProductState API 2. Pass in the product code {7299052b-02a4-4627-81f2-1818da5d550d} for the x86 package, {071c9b48-7c32-4621-a0ac-3f809523288f} for the x64 package or {0f8fb34e-675e-42ed-850b-29d98c2ece08} for the ia64 package 3. Check the return value of this API. If it is anything other than INSTALLSTATE_DEFAULT, the package is not yet installed

    C / C++ / MFC c++ question

  • Determine if VC++ 2005 SP1 runtime is installed?
    M mid 5741

    What's the best way to determine if this runtime is installed?

    C / C++ / MFC c++ question

  • Access controls from other modules of a program
    M mid 5741

    You are definitely doing too much regarding Question #1. You don't need to create an object every time you need to fire an event. I'm sorry my example code wasn't better. I just typed it into a text editor. I should have grabbed it from a working project. Regarding Question #2, there's definitely a better way. I just stuck everything into one place for simplicity. I'd only confuse you more if I tried to describe a better way, so I'll make a working example in C++/CLI and send that to you. -- modified at 22:39 Monday 13th August, 2007 To be a little clearer and more correct, here's the form class with irrelevant stuff stripped out:

    #include "WorkerClass.h"

    namespace WinApp1
    {
    public ref class Form1 : public Form
    {
    public:

      Form1()
      {
         InitializeComponent();
    
         workerClass\_ = gcnew WorkerClass();
    
         workerClass\_->OnUpdateText += gcnew UpdateText( this, &Form1::UpdateTextHandler );
      }
    

    private:

      TextBox^ textBox\_;
      Button^ button\_;
    
      WorkerClass^ workerClass\_;
    
      void button\_\_Click( System::Object^ sender, System::EventArgs^ e )
      {
         workerClass\_->DoSomething();
      }
    
      void UpdateTextHandler( String^ text )
      {
         textBox\_->Text = text;
      }
    

    };
    }

    And, in another file called WorkerClass.h, here's WorkerClass, which was SomeClass in my previous example:

    namespace WinApp1
    {
    delegate void UpdateText( String^ );

    ref class WorkerClass
    {
    public:

      event UpdateText^ OnUpdateText;
    
      void DoSomething()
      {
         ++serialNumber\_;
         OnUpdateText( Convert::ToString( serialNumber\_ ) );
      }
    

    private:

      int serialNumber\_;
    

    };
    }

    You don't need to derive your class from WorkerClass. All you need is an event of type UpdateText^ to which Form1 can attach a handler.

    Managed C++/CLI c++ question winforms help

  • Access controls from other modules of a program
    M mid 5741

    I'm sorry. I took "This was a simple task before as I just used pointers" to mean that you had existing native C++ code calling the C++ module that does all the work and were moving that existing code into C++/CLI. In your case, you can define an event to update the text:

    delegate void UpdateText( String^ );

    ref class SomeClass
    {
    public:
    event UpdateText^ OnUpdateText;
    };

    public ref class Form1 : Form
    {
    public:

    Form1()
    {
      InitializeComponent();
      
      someClass\_ = gcnew SomeClass();
      
      someClass\_->OnUpdateText += gcnew UpdateText( this, &Form1::UpdateTextHandler );
    }
    

    private:

    SomeClass^ someClass\_;
    
    void UpdateTextHandler( String^ text )
    {
      textBox->Text = text;
    }
    

    };

    In the implementation of SomeClass, call OnUpdateText( "New text" ) when you want to update the text. -- modified at 22:59 Monday 13th August, 2007 [Some corrections made to above code.]

    Managed C++/CLI c++ question winforms help

  • What makes a class IDisposable?
    M mid 5741

    No need to get pissy. As I said earlier, I'm not advocating the use of what the language itself calls (or, apparently, used to call) a destructor; I'm just claiming that such a beast exists. From the C# Language Specification: [Note: In the previous version of this standard, what is now referred to as a "finalizer" was called a "destructor". Experience has shown that the term "destructor" caused confusion and often resulted to incorrect expectations, especially to programmers knowing C++. In C++, a destructor is called in a determinate manner, whereas, in C#, a finalizer is not. To get determinate behavior from C#, one should use Dispose. end note]

    Managed C++/CLI csharp c++ visual-studio question

  • What makes a class IDisposable?
    M mid 5741

    iddqd515 wrote:

    How in C# do you declare such a thing?

    ~Class()

    Managed C++/CLI csharp c++ visual-studio question

  • Access controls from other modules of a program
    M mid 5741

    I highly recommend getting Nishant Sivakumar's "C++/CLI In Action" book if you're looking for examples. He covers a lot of confusing stuff with remarkable clarity and brevity. How are you using pFunc? It's a pointer for the native code to use. If you want to use a native function pointer, you'd use GetDelegateForFunctionPointer() in managed code. Also, I'm not certain, but I'm concerned about the scope of your variables. When m goes out of the scope of Form1(void) it may be garbage collected.

    Managed C++/CLI c++ question winforms help

  • What makes a class IDisposable?
    M mid 5741

    Are you being purposefully daft? I understand what's going on; I'm arguing that "C# does not have destructors" is an untrue statement. I'm not repudiating the mechanics. Dispute this: The C# language specification allows for the definition of destructors for class types.

    Managed C++/CLI csharp c++ visual-studio question

  • What makes a class IDisposable?
    M mid 5741

    From the source code perspective, I have code in a destructor that gets called. That's it. I'm not concerned with what goes on underneath. We're debating semantics. When you write ~Class1() in C#, you've got a destructor, both in name and behavior. In native C++, one would expect a destructor to be called implicitly when an automatic variable goes out of scope. Such is not the case in C++/CLI. What's defined as a destructor in C++/CLI does not get called when an automatic variable goes out of scope. What's defined as a finalizer in C++/CLI gets called when an automatic variable goes out of scope. That, to me, is a big difference.

    Managed C++/CLI csharp c++ visual-studio question

  • What makes a class IDisposable?
    M mid 5741

    The second post in this thread answered the original question. Thanks, Mark.

    Managed C++/CLI csharp c++ visual-studio question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups