Jump to content
Developer Wiki and Function Reference Links ×

Image background for CreateLayout


Recommended Posts

I am trying to emulate a layout that I have created in Excel. Excel allow a layout to have a background image on which I have positioned CreateStaticText, CreatePullDownMenu, CreateEditText, etc.

 

A more accurate explanation is that I want a layout with a background image of a gate and position data entry boxes around to ask the operator width, height, hinge location, etc.

 

Can there be an image background in CreateLayout ?

Link to comment

There is no official way to do it, however if you used CreateImageControl2() to insert the image as the first item in the dialog, you could probably then use SetBelowItem() with a large negative Y value to place the next item over the image and subsequent items below that. You will need to create a VWR file to store the image, which is simply a zip file of the image or images (without a parent folder), which you then just change the file suffix from .zip to .vwr.  If your zip/vwr file was called MyImages.vwr, and the image in there was called image1.png (use png images), then the call to place the image would be something like this:

 

CreateImageControl2        (Dialog1, ItemID, 500, 400, 'MyImages/image1.png');

 

The VWR file lives in the Plug-ins folder and 500/400 is the pixel size you want the image to appear in the dialog. Just make sure to preserve the image proportions. For example, this would work if the actual image was 1000 x 800 pixels, or 1500 x 1200, etc.

Link to comment

Great start Julian,

 

I am getting a big red cross though.

 

The png file I made was 32 bit 346 x 476 pixels. I used windows "send to compressed file" and changed the file name to Gates.vwr and moved it to the "Plug-ins" folder.

 

procedure CreateGateAPopUpLayout;
  begin
  GateADialog1 := CreateLayout ('Component Data', False, 'OK', 'Cancel');
  CreateImageControl2 (GateADialog1, 4, 346, 476, 'Gates/GateA.png');
  CreateStaticText (GateADialog1, 5, 'Height:', 15);
  
  SetFirstLayoutItem (GateADialog1, 4);
  SetBelowItem (GateADialog1, 4, 5, 0, -50);
  end;

Should be:  GateA.thumb.png.c6b4f537319838bee2f7c1a9c4482c71.png Result: 150001543_Annotation2020-06-01104445.thumb.png.37839b8563bcb5f100720b06a4284328.png

 

Link to comment

After hours of trying different variations, I've got it.

 

For Windows users, in the Plug-ins folder, create a folder yourname.vwr

 

It's not a zip file renamed or anything special. It's just a folder with an extension "vwr".

 

Put your png file/s into the folder.

 

This is the correct format CreateImageControl2 (GateADialog1, 4, 346, 476, 'Gates/GateA.png'); with the Gates.vwr folder in the Plug-ins folder and the GateA.png file inside the Gates.vwr folder.

 

If everything is correct in your code, naming the folder, and adding png file and you still get a red-"X", try restarting VW2020

 

Thanks to Julian for pushing me in the right direction 🙂

 

Regards

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...