January 22, 200917 yr comment_919647 Bagaimana untuk kita create satu object/control di dalam form secara runtime berdasarkan hwnd sesuatu object ? Saya kebuntuan.Test ContainerCODEOption ExplicitPrivate IWindowDef_Form As TestOCX.frmContainerPrivate Sub Class_Initialize() Set IWindowDef_Form = New TestOCX.frmContainerEnd SubPrivate Sub Class_Terminate() Call Unload(IWindowDef_Form) Set IWindowDef_Form = NothingEnd SubPublic Property Get IWindowDef_Hwnd() As Long If Not IWindowDef_Form Is Nothing Then IWindowDef_Hwnd = IWindowDef_Form.fContainer.hWnd End IfEnd PropertyPublic Property Get IWindowDef_Width() As Long If Not IWindowDef_Form Is Nothing Then IWindowDef_Width = IWindowDef_Form.fContainer.Width End IfEnd PropertyPublic Property Let IWindowDef_Width(value As Long) If Not IWindowDef_Form Is Nothing Then IWindowDef_Form.fContainer.Width = value End IfEnd PropertyPublic Property Get IWindowDef_Height() As Long If Not IWindowDef_Form Is Nothing Then IWindowDef_Height = IWindowDef_Form.fContainer.Height End IfEnd PropertyPublic Property Let IWindowDef_Height(value As Long) If Not IWindowDef_Form Is Nothing Then IWindowDef_Form.fContainer.Height = value End IfEnd PropertyPublic Property Get IWindowDef_Top() As Long If Not IWindowDef_Form Is Nothing Then IWindowDef_Top = IWindowDef_Form.fContainer.Top End IfEnd PropertyPublic Property Let IWindowDef_Top(value As Long) If Not IWindowDef_Form Is Nothing Then IWindowDef_Form.fContainer.Top = value End IfEnd PropertyPublic Property Get IWindowDef_Left() As Long If Not IWindowDef_Form Is Nothing Then IWindowDef_Left = IWindowDef_Form.fContainer.Left End IfEnd PropertyPublic Property Let IWindowDef_Left(value As Long) If Not IWindowDef_Form Is Nothing Then IWindowDef_Form.fContainer.Left = value End IfEnd PropertyTest formCODEOption Explicit'Private clsTestOCX As TestOCX.clsTestPrivate clsTestOCX As ObjectPrivate Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Sub Form_Load() Dim m_res As Long' Set clsTestOCX = New TestOCX.clsTest Set clsTestOCX = CreateObject("TestOCX.clsTest") m_res = SetParent(clsTestOCX.IWindowDef_Hwnd, Frame1.hWnd) clsTestOCX.IWindowDef_Height = Frame1.Height clsTestOCX.IWindowDef_Width = Frame1.Width clsTestOCX.IWindowDef_Left = 0 clsTestOCX.IWindowDef_Top = 0' Frame1.hWnd = clsTestOCX.IWindowDef_HwndEnd SubSeperti yang kita tahu property Hwnd adalah read-only.Setakat ni trick yg saya tahu adalah denganCODESetParent(clsTestOCX.IWindowDef_Hwnd, Frame1.hWnd)ada cadangan lain ? Edited January 22, 200917 yr by fatah Report
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.