WhoCanDo Posted May 31, 2020 Share Posted May 31, 2020 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 ? Quote Link to comment
Julian Carr Posted May 31, 2020 Share Posted May 31, 2020 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. Quote Link to comment
WhoCanDo Posted June 1, 2020 Author Share Posted June 1, 2020 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: Result: Quote Link to comment
WhoCanDo Posted June 2, 2020 Author Share Posted June 2, 2020 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 Quote Link to comment
Recommended Posts
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.