I am trying to add controls to a form by using the PB CONTROL ADD commands, but it does not seem to work. How do I add controls that are not in the FireFly Workspace Tools?
Thanks,
Robert
My initial thought would be that don't work since it's a DDT (Dynamic Dialog Tools) command and all windows and controls in FF are built with genuine Windows API calls.
Having no experience(/need) in adding controls at run-time / by hand with FF yet, I don't have a short answer ready for how to do that, but I'd assume looking at the generated files from a FF project, you'd find the answer there looking at how FF builds the forms with controls.
Robert,
It might not be best practices (mixing DDT with SDK), but you can definitely do it. Think of DDT as a wrapper for SDK. At some level the PB run-time code must be using genuine Windows API calls to create "DDT controls".
Please provide an example of the code you are trying. Also, more info please. Any compiler errors? Does the control show up at all, does it show up but you can't get messages from it, send messages to it, etc.
Maybe using the DDT commands would work but I wouldn't recommend it. You can easily create sdk style created controls. Just look at the generated source code for the CreateWindowEx function.
Maybe it would be easier for you to create the control at design time and simply set its WS_VISIBLE style off. When you need to show the control simply do a ShowWindow api call. You can even move the control into place via MoveWindow or SetWindowPos.
There are 2 reasons why I want to add controls.
First, I want to use XPRINT PREVIEW to print to a graphic control. The syntax is "XPRINT PREVIEW hWin, ID". What FF control can I use, and how do I give the XPRINT statement the hWIN and ID it needs? I wanted to use "CONTROL ADD GRAPHIC" but it did not work.
Second, I want to use the GRAPHIC commands. How do I marry them to a FF picture control?
Thanks,
Robert
You can get the handle and id from a control of sdk code with PB9 and PB10
sample:
WINDOW GET PARENT HWND_FORMX_CONTROLX TO DIALOGX&
WINDOW GET ID HWND_FORMX_CONTROLX TO IDX&
I tried what you suggested but it still does not work. I have a form with one Picture control and one Button. If I cannot print to a Picture, then what FF control is there that I can print to? Here is my code:
Global hhh As Long
Global iii As Long
'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
Window Get parent HWND_FORM1_PICTURE1 To hhh
Window Get Id HWND_FORM1_PICTURE1 To iii
XPrint Attach Default
XPrint preview hhh, iii
XPrint Print "this is a test"
XPrint Close
End Function
I don't know if xprint works on controls other than a native PB GRAPHIC control? I have never tried it. There are a couple of examples of using Graphic Control and Graphic Window with FF. I'll have to dig out those links.
Window Get Parent is easily done via the API function GetParent(HWND_FORM1_PICTURE1). However, if your Picture control is created on the Form then you already know that the parent is the Form (HWND_FORM1).
If you know the HWND of a control then you also know the ID. There is no need to use Window Get Id. Hit the F4 button to bring up the list of IDC's and HWNDs. The ID in this case would be IDC_FORM1_PICTURE1.
Here is the post with the Graphic Control demos....
http://www.planetsquires.com/protect/forum/index.php?topic=2300.0
Thank you for the info. We got hammered by another storm and have been without power, phone and internet for days. I will try the samples as soon as I can. As always, your support is appreciated.
Robert