Sign in to follow this  
chrisliando

[.net] What is Subclass (VB) in Visual C++ or C#?

Recommended Posts

I've got codes in VB .Net and they use Subclass keywords here: private: Subclass sClass1; private: Subclass sClass2; private: Subclass sClass3; I just need to know what Subclass is in Visual C++ or C#. How to change it into VC syntax? Thank you very much. private: void Form1_Load(object sender, System.EventArgs e) { // clear the rtb text RichTextBox1->Text = ""; RichTextBox2->Text = ""; //RichTextBox3.Text = ""; // setup the sSubclass sClass1 = gcnew Subclass(RichTextBox1.Handle); sClass2 = gcnew Subclass(RichTextBox2.Handle); sClass3 = gcnew Subclass(RichTextBox3.Handle); int i; // put some formated text in the RichTextBox's while ( i < 100 ) { RichTextBox1->AppendText(" this is a string " + i + Constants.vbCrLf); RichTextBox2->AppendText(" this is a string " + i + Constants.vbCrLf); //RichTextBox3->AppendText(" this is a string " + i + Constants.vbCrLf); if ( i % 4 == 0 ) { RichTextBox1->.AppendText(" this is a longer string to force HScroll " + i + Constants.vbCrLf); RichTextBox2->AppendText(" this is a longer string to force HScroll " + i + Constants.vbCrLf); //RichTextBox3->AppendText(" this is a longer string to force HScroll " + i + Constants.vbCrLf); } i += 1; } } public void sClass_WindowProcedure(ref Message uMsg) { switch (uMsg::Msg) { case WM_VSCROLL: // WM_VSCROLL Message's for RTB's if (uMsg::HWnd.Equals(RichTextBox1.Handle)) { //Debug.WriteLine(GetLowWord(uMsg.WParam.ToInt32)) sClass2.WindowProcedure -= sClass_WindowProcedure; Message msg1; Message msg2; msg1 = uMsg.Create(RichTextBox2.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); msg2 = uMsg.Create(RichTextBox3.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); sClass2.SendWndProc(msg1); sClass2.SendWndProc(msg2); sClass2.WindowProcedure += sClass_WindowProcedure; } if (uMsg.HWnd.Equals(RichTextBox2.Handle)) { sClass2.WindowProcedure -= sClass_WindowProcedure; Message msg1; Message msg2; msg1 = uMsg.Create(RichTextBox1.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); msg2 = uMsg.Create(RichTextBox3.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); sClass2.SendWndProc(msg1); sClass2.SendWndProc(msg2); sClass2.WindowProcedure += sClass_WindowProcedure; } if (uMsg.HWnd.Equals(RichTextBox3.Handle)) { sClass2.WindowProcedure -= sClass_WindowProcedure; Message msg1; Message msg2; msg1 = uMsg.Create(RichTextBox1.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); msg2 = uMsg.Create(RichTextBox2.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); sClass2.SendWndProc(msg1); sClass2.SendWndProc(msg2); sClass2.WindowProcedure += sClass_WindowProcedure; } break; case WM_HSCROLL: // WM_HSCROLL Message's for RTB's if (uMsg.HWnd.Equals(RichTextBox1.Handle)) { //Debug.WriteLine(GetLowWord(uMsg.WParam.ToInt32)) sClass2.WindowProcedure -= sClass_WindowProcedure; Message msg1; Message msg2; msg1 = uMsg.Create(RichTextBox2.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); msg2 = uMsg.Create(RichTextBox3.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); sClass2.SendWndProc(msg1); sClass2.SendWndProc(msg2); sClass2.WindowProcedure += sClass_WindowProcedure; } if (uMsg.HWnd.Equals(RichTextBox2.Handle)) { sClass2.WindowProcedure -= sClass_WindowProcedure; Message msg1; Message msg2; msg1 = uMsg.Create(RichTextBox1.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); msg2 = uMsg.Create(RichTextBox3.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); sClass2.SendWndProc(msg1); sClass2.SendWndProc(msg2); sClass2.WindowProcedure += sClass_WindowProcedure; } if (uMsg.HWnd.Equals(RichTextBox3.Handle)) { sClass2.WindowProcedure -= sClass_WindowProcedure; Message msg1; Message msg2; msg1 = uMsg.Create(RichTextBox1.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); msg2 = uMsg.Create(RichTextBox2.Handle, uMsg.Msg, uMsg.WParam, uMsg.LParam); sClass2.SendWndProc(msg1); sClass2.SendWndProc(msg2); sClass2.WindowProcedure += sClass_WindowProcedure; } break; } }

Share this post


Link to post
Share on other sites
Subclass is not a VB.net keyword, so I have no idea what you're talking about. And what is "private: Subclass sClass1;"? You say it's from a VB.net project, but that is not VB syntax. It looks more like a variable declaraction in C++. If that's the case, then Subclass is the name of a type declared somewhere. It's not a type that's declared in the standard library, so without more information about it I konw if anyone is going to be able to help you.

Share this post


Link to post
Share on other sites
Oops sorry, I give you the one that I have changed to Visual C++. The codes in VB is here:

http://www.codeproject.com/KB/vb/VbNetScrolling.aspx

After you saw that, please tell me if there is any keywords that can be converted to C++.

Thank you very much.

Share this post


Link to post
Share on other sites
Subclass isn't a keyword there, its a class defined in that code


Public Class Subclass
'===================================================================

' NativeWindow Subclassing

'===================================================================

Inherits System.Windows.Forms.NativeWindow
Public Event WindowProcedure(ByRef uMsg As Message)

Public Sub New(ByVal pWindowHandle As IntPtr)
MyBase.AssignHandle(pWindowHandle)
End Sub

Protected Overrides Sub WndProc( _
ByRef uMsg As System.Windows.Forms.Message)
MyBase.WndProc(uMsg)
RaiseEvent WindowProcedure(uMsg)
End Sub

Public Sub SendWndProc(ByRef uMsg As System.Windows.Forms.Message)
MyBase.WndProc(uMsg)
End Sub

End Class

Share this post


Link to post
Share on other sites
Quote:
Original post by chrisliando
Ok..I did not look at it...

You need to spend a lot more time working on your own before you come around here asking for help. At the very least, read your own code samples. When you don't put any effort into your own education, it annoys people. When people get annoyed, they will begin to ignore you, and then you won't get any help at all.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this