Hello,
I think firefly is not generating a function required for a custom control to be created/initialized. Im trying to create a custom OCX control via the ATLAXWIN method, by specifying the Class name in the caption field: "Shell.Explorer".
Note: I am trying to do it this way because adding an OCX control with the classname "Shell.Explorer" does not show the control.
Anyway, when i use the custom control method, Firefly generates the following code:
'------------------------------------------------------------------------------
' Create BROSWER [CustomControl] control.
'------------------------------------------------------------------------------
hWndControl = CSS3_BROSWER_INIT( _
"ATLAXWIN", _
"Shell.Explorer", _
hWndForm, _
%WS_EX_LEFT OR %WS_EX_LTRREADING, _
%WS_CHILD OR %WS_VISIBLE, _
11, FLY_ClientOffset + 112, _
597, 160 )
It is, however, forgetting to add the CSS3_BROSWER_INIT function and the compile fails.
I tried adding the CSS3_BROSWER_INIT function myself, but, I need to use the pWindow class to add controls to the form and i dont have access outside the Controls creation function.
Any ideas or workarounds?
Note that I am trying to add the control this way to be able to make use of the resizing functions included in the properties of the custom control as well as the High DPI awareness. The following function kind of works, but im not sure it won't explode in my face, as SDK and DDT don't always get along together very well:
Function CSS3_BROSWER_INIT(cClass As String, _
cCaption As String, _
hWndFormp As Dword, _
cEstyle As Dword, _
cWstyle As Dword, _
sp1 As Long, _
sp2 As Long, _
sp3 As Long, _
sp4 As Long) As Dword
Local hCtrl As Dword
Control Add cClass, hWndFormp, IDC_CSS3_BROSWER, cCaption, sp1, sp2, sp3, sp4, cWstyle, cEstyle
Control Handle hWndFormp, IDC_CSS3_BROSWER To hCtrl
Function = hCtrl
End Function
When you add the Custom Control tool to a form you will need to double click on it in order to generate the default "_INIT" message handler. You only need to do this once. If you don't do it then the compile will fail (like you have experienced) because the INIT does not exist.
You should be able to retrieve the pWindow of the Form by using Jose's built in functions:
' ========================================================================================
' Retrieves a pointer to the CWindow class and returns a reference counted object variable.
' ========================================================================================
FUNCTION CWindow_GetObjectFromWindowHandle (BYVAL hwnd AS DWORD) AS IUnknown
Hello Paul, I have double clicked it several times and it doesnt seem to add anything. How can i tell?
Correction, it finally did it. After many many tries. If i erase the function and double click the control again, it doesnt add anything until several double-clicks later.
Thanks! I didn't know about CWindow_GetObjectFromWindowHandle().
:)
It is working almost as expected now (doesn't respect resizing rules) what can i try?
Also, just curious... why did you implement it this way? It looks just like a regular encapsulation function (not a message handler), i dont see the point in requiring a double click to create this function, I mean, any inicialization for a custom control can be done in the CREATE function for the form...
But knowing your programming I'm sure there must be a reason? :)