Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Evaluation - Testing example AddCtrls OI9.4

I have this in a form create event script.
Taken from AddCtrls example exactly.

CtrlArray = ""

// Add the label, placing it in the same place it was added to the form
hWnd = Get_Property(@Window:".LABEL", "HANDLE")
OrigSize = Get_Property(@Window:".LABEL", "ORIG_SIZE")
Convert @FM to @VM in OrigSize
CtrlArray<-1> = hWnd:@VM:OrigSize

// Add the editline, placing it in the same place it was added to the form
hWnd = Get_Property(@Window:".EDITLINE", "HANDLE")
OrigSize = Get_Property(@Window:".EDITLINE", "ORIG_SIZE")
Convert @FM to @VM in OrigSize
CtrlArray<-1> = hWnd:@VM:OrigSize

// Add the controls
call Send_Message(@Window:".OLE_PANEL", "OLE.AddCtrls", CtrlArray)

return 1

The controls are disappearing but not showing in the panel. Panel is named OLE_PANEL.
Is there one more step?

Comments

  • Also tried the AddNamedForm example.
    The form I was using was not set to visible.
    When I ran the panel test form, the for I was setting is shown on the desktop but not in the panel.

    Just mentioning in case is a clue to what I am stuffing up.

    Testing is via 'Test Run' in the form designer
  • Just an obvious question without studying your code too closely, are the controls on the form in an x/y position that would be visible within the size of the Panel control?
  • If the big rectangle on the left is the SRP Panel control and the label and editline on the right are the controls you are trying to add to the SRP Panel control, their x-positions are beyond the width of the SRP Panel control. Thus, you are adding them but they are too far to the right to be visible. Am I missing something?
  • In your code, you are passing the original X, Y coordinates of the control to the AddCtrls method instead of defining a new position. If you set the Width and Height properties of the panel to match the larger form, then you would see scroll bars that would allow you scroll to the right to see the embedded control.
  • Sorry guys, I misinterpreted the x control, I was assuming it would be auto adjusted. So, i would assume they would need to go on a 2nd page alighed with the page 1 panel to use the original x,y.

    I will make that changed.
  • If your goal is to position controls using Form Designer first, I recommend using the SetForm method instead. It just takes an OI form and drops it in. One call.
  • Having used it extensively, I'd second the recommendation to use SetForm over AddCtrls.
    With monitor sizes and resolutions these days, I think AddCtrls adds limited value. If you need to use a panel to fit more controls on the form, you've probably got too many controls. One useful purpose I guess would be if you wanted to vary which controls were available to the user depending on some setting. You could have all the possible controls on the window and then use AddCtrls instead of the visible property to display just the ones that are relevant.
    I don't know which would be the better approach. It would likely be very much dependant on the desired outcome.

    I haven't tried the AddNamedForm method and I see you had problems with it though it should be much the same as SetForm. Maybe just try SetForm and see how you go. I've got to admit, the issue you described with AddNamedForm actually sounds familiar to me (with SetForm) but I don't remember doing anything specific to resolve it so maybe it was a version thing.
  • If you need to use a panel to fit more controls on the form, you've probably got too many controls.

    No argument with the recommendation to use SetForm versus AddCtrls. But for what it is worth, I have always liked the idea of using AddCtrls to create virtual space as a way to emulate what a browser does. Many of the mobile apps today provide forms for people to fill out (patient agreement forms, professional service agreements, automobile service agreements, etc.) and these always require the user to scroll and navigate to get all the content.
  • You and your sensible rebuttals.

    A use case I didn't consider. Probably because I've only ever had one instance where I've been required to do something along those lines and I used the tree control to do it. That worked for me but now I can see the value of AddCtrls.

    Thanks for enlightening me.
  • OI10
    I used SetForm and it works whereas AddNamedForm doesnt.

    The issue I am seeing with SetForm is the form flashing up first before showing in the panel.
    The form is set as 'Hidden' but there is code for the create event with a forward event, so I assume that is the cause.
    Is there a method to avoid the 'Flash up'
  • No, you have to redesign the code to avoid the VISIBLE property from being set too early.
Sign In or Register to comment.