• Advertisement

chrisliando

Member
  • Content count

    146
  • Joined

  • Last visited

Community Reputation

100 Neutral

About chrisliando

  • Rank
    Member
  1. Hi, I am developing with Visual C++ MFC, the IDE I used is the Visual Studio 2008. My problem is: Compared to Visual Studio 6, when I add Control Variable to a Control, let say IDC_Edit which the control variable I named m_Edit1. Why does the code for DoDataExchange ( RED colored on attached code below ) won't automatically created? so that I had to create it myself.. What make question on my mind is on Visual Studio 6, it is automatically created. Below codes taken from Visual Studio 6. void CSample1Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSample1Dlg) DDX_Text(pDX, IDC_EDIT1, m_Edit1); //}}AFX_DATA_MAP } How to solve this problem since everyone including me obviously cannot memorize all the DDX command / syntax on their mind..and it is very possible that if someone coding, they sometimes forgot to add that command since they used to think that it will be created automatically. If this happen to a large scale application, it will be difficult to trace why a lot of process / flow does not work as the logic control. Or is there any customization on settings or menu to make it automatically create that line? Thank you very much.
  2. Hi, I am using Visual C++ MFC to develop an application consist of a Tree Control. The IDE I used is the Visual Studio 2008. At the beginning, there has been a text file (CSV format) named List.dat like this, so I don't create the file: GROUP,FIRST GROUP <--------Parent 1 00005,CHK,1,AAAAA <--------Child of Parent 1 00008,CHK,1,BBBBB <--------Child of Parent 1 00015,CHK,0,CCCCC <--------Child of Parent 1 00001,CHK,0,DDDDD <--------Child of Parent 1 00002,CHK,1,EEEEE <--------Child of Parent 1 00011,RAD,0,OPTION,2 <--------Child of Parent 1 0,OPTION-1 <--------Child of 00011 1,OPTION-2 <--------Child of 00011 GROUP,SECOND GROUP <--------Parent 2 00007,CHK,1,ZZZZZ <--------Child of Parent 2 NOTE: The text Parent 1, Child of Parent 1, etc is just my remark to make it clear.. So it is not part of the file. What I have to do is read the text file and display its content in a form of a Tree Control like this: This is how the application will be: <Folder Image>FIRST GROUP .....................<Checked CheckBox Image>AAAAA .....................<Checked CheckBox Image>BBBBB .....................<UNChecked CheckBox Image>CCCCC .....................<UNChecked CheckBox Image>DDDDD .....................<Checked CheckBox Image>EEEEE .....................<Folder Image>OPTION ..........................................<Checked RadioButton Image>OPTION-1 ..........................................<UNChecked RadioButton Image>OPTION-2 <Folder Image>SECOND GROUP .....................<Checked CheckBox Image>ZZZZZ [OK Button][Cancel Button] EXPLANATION: 1. Folder Image means Windows Folder symbol. FIRST GROUP, SECOND GROUP and OPTION use a Folder Image because they have a few child (they act as PARENT). 2. In front of AAAAA is a Checked CheckBox image referring to this line from List.dat: 00005,CHK,1,AAAAA CHK means CheckBox, 1 means it is CHECKED. 3. Line 00011,RAD,0,OPTION,2 means: RAD is a RadioButton 0: the checked RadioButton is the first RadioButton (which index is 0). 2: there are 2 members in a form of RadioButton 4. The code 00005, 00011 is just a code to make this easier to save the changes, but I don't know how to use them. It is not a sorted number, just random. PROBLEM: 1. How to read the text file so that I can display all its content in a good and correct order? 2. How to display the Tree node as CheckBox, Radio Button and Folder? 3. If I Check / Uncheck the CheckBox AND/OR the RadioButton during the application ran, when I click OK, the application will exit, save the changes and updating List.dat. If I click Cancel, the application will exit and all the changes made will NOT be saved and the file remains like the original... e.g: The original content: 00005,CHK,1,AAAAA after I change it in the application will be: 00005, CHK, 0, AAAAA How to change the content of the text file? Any help will be appreciated.. Thank you very much..
  3. I want to HORIZONTALLY scroll 2 listView at the same time. I add a HScrollBar and put it over the ORIGINAL listView scrollBar. But by adding HScrollBar, the last listView item cannot be seen well. How to make the last listView item seen well? I have tried like this to get the 2nd listView and the 2nd ScrollBar move but nothing's happened: private: static int const WM_HSCROLL = 0x0115; private: System::Void Form1_Load(Object^ sender, System::EventArgs^ e) { // HScrollBar this->hsb1->Left = this->listView1->Left; this->hsb1->Top = this->listView1->Bottom - 21; this->hsb1->Width = this->listView1->Width; this->hsb1->Height = 20; this->hsb1->SmallChange = 5; this->hsb1->Minimum = 0; this->hsb1->Maximum = listView1->Columns[0]->Width + listView1->Columns[1]->Width + listView1->Columns[2]->Width;//listView1->Columns->Count - 1; this->hsb2->Left = this->listView2->Left; this->hsb2->Top = this->listView2->Bottom - 21; this->hsb2->Width = this->listView2->Width - 1; this->hsb2->Height = 20; this->hsb2->Minimum = 0; this->hsb2->Maximum = listView1->Columns[0]->Width + listView1->Columns[1]->Width + listView1->Columns[2]->Width;//listView2->Columns->Count - 1; this->hsb2->SmallChange = 5; this->hsb1->ValueChanged += gcnew EventHandler(this, &Form1::hsb_ValueChanged); this->hsb2->ValueChanged += gcnew EventHandler(this, &Form1::hsb_ValueChanged); this->Controls->Add(this->hsb1); this->Controls->Add(this->hsb2); this->hsb1->BringToFront(); this->hsb2->BringToFront(); // HScrollBar } //end of Form1_Load private: void hsb_ValueChanged(Object ^sender, System::EventArgs ^e) { SendMessage(listView1->Handle, WM_HSCROLL, 0, 0); SendMessage(listView2->Handle, WM_HSCROLL, 0, 0); } But nothing's happen when I slide the HScrollBar. What was wrong? Thank you very much.
  4. I've got a problem here in invoking event in a class that was derived from a ListView. I added a new event called OnVScroll to check if the user slide the listView scrollbar. The purpose is if user slide listView1 scrollbar then listView2 also synchronized. Here is the code: static int const SBS_VERT = 1; static int const SB_THUMBPOSITION = 4; [DllImport("user32.dll", CharSet=CharSet::Auto, CallingConvention=CallingConvention::StdCall)] static IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); [DllImport("user32.dll")] static int GetScrollPos(IntPtr hWnd, int nBar); [DllImport("user32.dll")] static int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); ref class MyListView: ListView { public: MyListView() { WM_HSCROLL = 0x0114; WM_VSCROLL = 0x0115; WM_MOUSEWHEEL = 0x020A; } Void MyListView::OnVScroll(System::Windows::Forms::Message %m) { } //end of OnVScroll private: int WM_HSCROLL; int WM_VSCROLL; int WM_MOUSEWHEEL; protected: virtual void WndProc(System::Windows::Forms::Message %m) override { if( m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL || m.Msg == WM_MOUSEWHEEL ) MyListView::OnVScroll(m); else ListView::WndProc(m); } }; //end of class MyListView*/ On the event OnVScroll, I want to call : SendMessage(lvSource->Handle, m.Msg, m.WParam, m.LParam); I've placed this code OUTSIDE MyListView class, along with other built-in events like Button1_Click, etc: private: System::Void MyListView::OnVScroll( System::Windows::Forms::Message %m ) { SendMessage( lvSource->Handle, m.Msg, m.WParam, m.LParam ); } //end of OnVScroll But it generated error like this: Results.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C2838: 'OnVScroll' : illegal qualified name in member declaration MyDiff.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C2838: 'OnVScroll' : illegal qualified name in member declaration AssemblyInfo.cpp What is wrong and how to fix this? Thank you very much.
  5. I've got a problem here in invoking event in a class that was derived from a ListView. I added a new event called OnVScroll to check if the user slide the listView scrollbar. The purpose is if user slide listView1 scrollbar then listView2 also synchronized. Here is the code: static int const SBS_VERT = 1; static int const SB_THUMBPOSITION = 4; [DllImport("user32.dll", CharSet=CharSet::Auto, CallingConvention=CallingConvention::StdCall)] static IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); [DllImport("user32.dll")] static int GetScrollPos(IntPtr hWnd, int nBar); [DllImport("user32.dll")] static int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); ref class MyListView: ListView { public: MyListView() { WM_HSCROLL = 0x0114; WM_VSCROLL = 0x0115; WM_MOUSEWHEEL = 0x020A; } Void MyListView::OnVScroll(System::Windows::Forms::Message %m) { } //end of OnVScroll private: int WM_HSCROLL; int WM_VSCROLL; int WM_MOUSEWHEEL; protected: virtual void WndProc(System::Windows::Forms::Message %m) override { if( m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL || m.Msg == WM_MOUSEWHEEL ) MyListView::OnVScroll(m); else ListView::WndProc(m); } }; //end of class MyListView*/ On the event OnVScroll, I want to call : SendMessage(lvSource->Handle, m.Msg, m.WParam, m.LParam); I've placed this code OUTSIDE MyListView class, along with other built-in events like Button1_Click, etc: private: System::Void MyListView::OnVScroll( System::Windows::Forms::Message %m ) { SendMessage( lvSource->Handle, m.Msg, m.WParam, m.LParam ); } //end of OnVScroll But it generated error like this: Results.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C2838: 'OnVScroll' : illegal qualified name in member declaration MyDiff.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(487) : error C2838: 'OnVScroll' : illegal qualified name in member declaration AssemblyInfo.cpp What is wrong and how to fix this? Thank you very much.
  6. I've tried this code below but it is error like this: Results.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(262) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(262) : error C2838: 'OnVScroll' : illegal qualified name in member declaration MyDiff.cpp c:\chris\sample test\diffengtest\mydiff\Results.h(262) : error C3254: 'MyDiff::Results' : class contains explicit override 'OnVScroll' but does not derive from an interface that contains the function declaration c:\chris\sample test\diffengtest\mydiff\Results.h(262) : error C2838: 'OnVScroll' : illegal qualified name in member declaration What happen? Thank you. Codes: ref class MyListView: ListView { public: MyListView() { WM_HSCROLL = 0x0114; WM_VSCROLL = 0x0115; WM_MOUSEWHEEL = 0x020A; } System::Void OnVScroll(Message %m); private: int WM_HSCROLL; int WM_VSCROLL; int WM_MOUSEWHEEL; protected: virtual void WndProc(Message %m) override { if( m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL || m.Msg == WM_MOUSEWHEEL ) MyListView::OnVScroll(m); else ListView::WndProc(m); } }; //end of class MyListView private: void MyListView::OnVScroll(Message %m) { SendMessage(lvSource->Handle, m.Msg, m.WParam, m.LParam); } //end of OnVScroll
  7. I cannot do that because it has been a rule that everyone must use Visual C++. Thank you for your advice.
  8. Hi I've been so confused with these VB codes: Public Event WindowProcedure(ByRef uMsg As Message) RaiseEvent WindowProcedure(uMsg) How to change them to Visual C++? Thank you very much.
  9. I use Visual C++ and .Net 2.0. I need to create a derived class. The purpose is I want to create new events inside that class. How to create the event inside that class? Can you please give me examples? Thank you very much.
  10. Hi I am using C++ Whidbey and .Net 2.0. I use 2 listViews in Details view. I want to scroll BOTH listView AT THE SAME TIME using VScrollBar component, so I disabled the original listView scrollbars. I have successfully scroll the listView content but only from up to bottom, but I cannot do the reverse when the listView contents has reached bottom, it cannot returned upward.. I was confused how to check the VScrollBar value if it always the same with the increment. Please help me to scroll from bottom back to up. Thank you very much. Here is my code: using namespace System::Runtime::InteropServices; [DllImport("user32.dll")] static bool ShowScrollBar(System::IntPtr hWnd, int wBar, bool bShow); [DllImport("user32.dll")] static bool EnableScrollBar(System::IntPtr hWnd, UInt32 wSBflags, UInt32 wArrows); [DllImport("user32.dll")] static IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UIntPtr wParam, IntPtr lParam); private: static int const SB_VERT = 1; private: static int const ESB_DISABLE_BOTH = 0x3; private: static int const ESB_ENABLE_BOTH = 0x0; private: static int const WM_VSCROLL = 0x115; private: System::Void Results_Load(System::Object^ sender, System::EventArgs^ e) { EnableScrollBar(this->lvSource->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH); EnableScrollBar(this->lvDestination->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH); } private: System::Void vScrollBar1_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { if ( vScrollBar1->Value < vScrollBar1->Maximum ) SendMessage(this->lvSource->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0)); SendMessage(this->lvDestination->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0)); }
  11. [.net] Scrolling listView

    Thank you. But how to use this on listView Scroll event? I still don't understand how to catch listView scroll.. Thank you.
  12. I use Visual C++ and .Net 2.0. I have 2 listViews, lv1 and lv2. All in Details View. If I use the MouseWheel to scroll / use the listView scrollbar to scroll the content (Horizontally or Vertically) on either lv1 or lv2 then the other will synchronized (scroll at the same time). I have successfully Scroll both listView but I must use Buttons, button1 for scrollup and button2 for scrolldown and they only scroll vertically like this: [DllImport("user32.dll")] static bool ShowScrollBar(System::IntPtr hWnd, int wBar, bool bShow); [DllImport("user32.dll")] static bool EnableScrollBar(System::IntPtr hWnd, UInt32 wSBflags, UInt32 wArrows); [DllImport("user32.dll")] static IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UIntPtr wParam, IntPtr lParam); private: static int const SB_VERT = 1; private: static int const ESB_DISABLE_BOTH = 0x3; private: static int const ESB_ENABLE_BOTH = 0x0; private: static int const WM_VSCROLL = 0x115; private: System::Void Results_Load(System::Object^ sender, System::EventArgs^ e) { EnableScrollBar(this->lvSource->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH); EnableScrollBar(this->lvDestination->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH); } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { SendMessage(this->lvSource->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallDecrement)), System::IntPtr(0)); SendMessage(this->lvDestination->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallDecrement)), System::IntPtr(0)); } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { SendMessage(this->lvSource->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0)); SendMessage(this->lvDestination->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0)); } I have got code from Internet: using System; using System.Windows.Forms; public class MyListView : ListView { protected override void WndProc(ref Message m) { if (m.Msg == 0x115) { // Trap WM_VSCROLL int code = m.WParam.ToInt32() & 0xffff; int pos = m.WParam.ToInt32() >> 16; Console.WriteLine("Scroll, code = {0}, pos = {1}", code, pos); } base.WndProc(ref m); } } I have a few questions here: (1) How to trap WM_HSCROLL? Does the constant WM_VSCROLL is used to detect if users slide the listView vertical scrollbar? (2) I must create events VScroll and HScroll, right? (3) What do I get from the overriden void? You know like a function, it will return a value. So how about the override void WndProc? What value / result do I get in order to continue to create event VScroll and HScroll? (4) How to detect if users use their MouseWheel to scroll listView contents? Thank you very much. [Edited by - chrisliando on February 27, 2008 6:53:06 PM]
  13. (1) I am using Visual C++ 2005 Express Edition (Whidbey) and .Net framework 2.0. I would like to know how to create, compile and set a DLL for ready to be used. I have got codes in C#. They consists of several .cs files and they have the same namespace, like this: using System; using System.Collections; namespace Build { .... } so all of them(.cs files) have the same header like above and the output is "Build.dll". In case of configuring the Visual C++ compiler settings or options, please tell me how to configure it out. (2) Is it possible to execute / use C# based dll in C++ Whidbey? If it is possible, please tell me how to do that. (3) For building a DLL in C++ Whidbey, what file do I need to work with in 1 Project/Solution? ".h" or ".cpp" files? Because when I looked at the C# codes, they use ".cs" files. I knew that in C# ".h" files are not available so it must use the ".cs" files. How is that in C++? Thank you very much..
  14. I've got problem converting these from VB to C++ Whidbey. It was generate errors: c:\chris\sample test\synchronize_scrolling\Form1.h(204) : error C2061: syntax error : identifier 'clsWindowSubClass' The location: Original VB code: Public Sub SyncScrollBars(ByVal Handle As IntPtr, _ ByVal SubClass As clsWindowSubClass, _ ByVal Window As Object, _ ByRef WindowsMessage As Message) objParent.SyncScrollBars(MyBase.Handle, Me, _ objWindow, WindowMessage) It's Parameter 2 which become the problem, which are Me in VB and this in C++. My effort in C++: void SyncScrollBars( IntPtr Handle, clsWindowSubClass ^SubClass, Object^ Window, ref class Message WindowsMessage ) objParent-&gt;SyncScrollBars( this-&gt;Handle, this, objWindow, WindowMessage ); and this error also occured: c:\chris\sample test\synchronize_scrolling\Form1.h(253) : error C2660: 'Project::Form1::clsRTFScrollSync::SyncScrollBars' : function does not take 4 arguments at this part: objParent-&gt;SyncScrollBars( this-&gt;Handle, this, objWindow, WindowMessage ); How to change it? I was confused. If you might to see the website, here is the link: http://www.codeproject.com/KB/cpp/RTFSynchronizedScrolling.aspx Thank you. Here is the FULL VB source code: Imports System.Runtime.InteropServices Public Class clsRTFScrollSync Private Declare Auto Function SendScrollPosMessage _ Lib "user32.dll" Alias "SendMessage"( _ ByVal hWnd As IntPtr, _ ByVal Msg As Integer, _ ByVal wParam As IntPtr, _ ByRef lParam As POINT) As Integer Private Const WM_USER = &H400 Private Const EM_GETSCROLLPOS = WM_USER + 221 Private Const EM_SETSCROLLPOS = WM_USER + 222 Private Structure POINT Public x As Integer Public y As Integer End Structure Private aControls As New ArrayList Private sbScrollBarType As Windows.Forms.ScrollBars Public Property ScrollBarToSync() As Windows.Forms.ScrollBars Get Return sbScrollBarType End Get Set(ByVal Value As Windows.Forms.ScrollBars) sbScrollBarType = Value End Set End Property Public Sub AddControl(ByVal RTFControl As Object) Dim objControlSubClass As New clsWindowSubClass(RTFControl.Handle, _ RTFControl, Me) aControls.Add(objControlSubClass) End Sub Public Sub SyncScrollBars(ByVal Handle As IntPtr, _ ByVal SubClass As clsWindowSubClass, _ ByVal Window As Object, _ ByRef WindowsMessage As Message) Static blnIgnoreMessages As Boolean If blnIgnoreMessages = True Then Exit Sub blnIgnoreMessages = True Dim blnChangeVertPos As Boolean = False Dim blnChangeHorizPos As Boolean = False Dim lngVertPos, lngHorizPos As Long Dim stcScrollPoint As New Point Dim ptrScrollPoint As IntPtr SendScrollPosMessage(Handle, EM_GETSCROLLPOS, _ New IntPtr(0), stcScrollPoint) lngVertPos = stcScrollPoint.y lngHorizPos = stcScrollPoint.x If (sbScrollBarType = RichTextBoxScrollBars.Both Or _ sbScrollBarType = RichTextBoxScrollBars.Vertical) Then blnChangeVertPos = True If (sbScrollBarType = RichTextBoxScrollBars.Both Or _ sbScrollBarType = RichTextBoxScrollBars.Horizontal) Then blnChangeHorizPos = True If blnChangeVertPos = True Or blnChangeHorizPos = True Then Dim objSubClass As clsWindowSubClass Dim objWindowMessage As New Windows.Forms.Message For Each objSubClass In aControls If objSubClass.Handle.ToInt32 &lt;&gt; Handle.ToInt32 Then SendScrollPosMessage(objSubClass.Handle, EM_GETSCROLLPOS, _ New IntPtr(0), stcScrollPoint) If blnChangeHorizPos = True Then stcScrollPoint.x = lngHorizPos If blnChangeVertPos = True Then stcScrollPoint.y = lngVertPos SendScrollPosMessage(objSubClass.Handle, EM_SETSCROLLPOS, _ New IntPtr(0), stcScrollPoint) End If Next End If blnIgnoreMessages = False End Sub End Class Public Class clsWindowSubClass Inherits System.Windows.Forms.NativeWindow Private objWindow As Object Private objParent As clsRTFScrollSync Public Sub New(ByVal Handle As IntPtr, ByVal Window As Object, ByVal Parent As clsRTFScrollSync) objWindow = Window objParent = Parent MyBase.AssignHandle(Handle) End Sub Protected Overrides Sub WndProc(ByRef WindowMessage As _ system.Windows.Forms.Message) MyBase.WndProc(WindowMessage) objParent.SyncScrollBars(MyBase.Handle, Me, _ objWindow, WindowMessage) End Sub End Class Here is what I've tried to convert into C++ Whidbey: public: ref class clsRTFScrollSync { [DllImport("user32.dll")] //, EntryPoint = "SendMessage", CharSet = CharSet::Auto, SetLastError = true, ExactSpelling = true)]; static int SendScrollPosMessage(IntPtr hWnd, int Msg, IntPtr ^wParam, POINT ^lParam); private: static int const WM_USER = 1024; private: static int const EM_GETSCROLLPOS = WM_USER + 221; private: static int const EM_SETSCROLLPOS = WM_USER + 222; private: ref struct POINT{ public: int x; public: int y; }; private: ArrayList ^aControls; //jgn lupa init gcnew ArrayList private: ScrollBars ^sbScrollBarType; // As Windows.Forms.ScrollBars public: property ScrollBars ^ScrollBarToSync { ScrollBars ^get() { return sbScrollBarType; } void set(ScrollBars ^Value) { sbScrollBarType = Value; } } public: void AddControl(Control ^RTFControl) { clsWindowSubClass ^objControlSubClass; objControlSubClass-&gt;New(RTFControl-&gt;Handle, RTFControl, this); aControls = gcnew ArrayList(); aControls-&gt;Add(objControlSubClass); } public: void SyncScrollBars( IntPtr Handle, clsWindowSubClass ^SubClass, Object^ Window, ref class Message WindowsMessage ) { static bool blnIgnoreMessages;// As Boolean //if( blnIgnoreMessages == true ) //exit(0); // Sub blnIgnoreMessages = true; bool blnChangeVertPos = false; bool blnChangeHorizPos = false; long lngVertPos, lngHorizPos; Point^ stcScrollPoint = gcnew Point(); IntPtr ^ptrScrollPoint; SendScrollPosMessage( Handle, EM_GETSCROLLPOS, gcnew IntPtr(0), stcScrollPoint ); lngVertPos = stcScrollPoint-&gt;Y; lngHorizPos = stcScrollPoint-&gt;X; //sbScrollBarType = ScrollBars:: if ( sbScrollBarType == ScrollBars::Both || sbScrollBarType == ScrollBars::Vertical ) blnChangeVertPos = true; if (sbScrollBarType == ScrollBars::Both || sbScrollBarType == ScrollBars::Horizontal) blnChangeHorizPos = true; if ( blnChangeVertPos == true || blnChangeHorizPos == true ) { clsWindowSubClass ^objSubClass; Message ^objWindowMessage = gcnew Message(); for each (objSubClass in aControls) { if ( Convert::ToInt32(objSubClass-&gt;Handle) != Convert::ToInt32(Handle) ) { SendScrollPosMessage(objSubClass-&gt;Handle, EM_GETSCROLLPOS, gcnew IntPtr(0), stcScrollPoint); if ( blnChangeHorizPos == true ) stcScrollPoint-&gt;X = lngHorizPos; if ( blnChangeVertPos == true ) stcScrollPoint-&gt;Y = lngVertPos; SendScrollPosMessage(objSubClass-&gt;Handle, EM_SETSCROLLPOS, gcnew IntPtr(0), stcScrollPoint); } } //for each } //if ( blnChangeVertpos == true || blnChangeHorizPos == true ) blnIgnoreMessages = false; } //end of void SyncScrollBars }; //end of class clsRTFScrollSync ref class clsWindowSubClass : System::Windows::Forms::NativeWindow { private: Object ^objWindow; // As Object private: clsRTFScrollSync ^objParent; public: void New( IntPtr Handle, Object ^Window, clsRTFScrollSync ^Parent ) { objWindow = Window; objParent = Parent; this-&gt;AssignHandle(Handle); } protected: virtual void WndProc( System::Windows::Forms::Message WindowMessage ) override { this-&gt;WndProc(WindowMessage); objParent-&gt;SyncScrollBars( this-&gt;Handle, this, objWindow, WindowMessage ); } }; [Edited by - mittens on February 24, 2008 3:33:47 PM]
  15. Is it possible to do that? How to do that? Have you ever do it? If yes, please tell me how.. Thank you very much.
  • Advertisement