| Mirage Source http://web.miragesource.net/forums/ |
|
| Question about forms http://web.miragesource.net/forums/viewtopic.php?f=201&t=3177 |
Page 1 of 2 |
| Author: | Stomach Pulser [ Mon Dec 17, 2007 7:36 pm ] |
| Post subject: | Question about forms |
Hello, I am trying to load a GUI into a form's background image and then set the form's width and height to that of the picture. I have the actually loading the GUI done, but when I try to load the width and height, it sets it incorrectly. Meaning, it makes both to big. Here is my code Code: Sub LoadGui(ByVal curForm As Form, ByVal locGUI As String) curForm.Picture = LoadPicture(App.Path & GFX_GUI & locGUI) curForm.Width = curForm.Picture.Width curForm.Height = curForm.Picture.Height End Sub In frmMainMenu I use this call: Code: Private Sub Form_Load() Call LoadGui(Me, "menu.bmp") End Sub Any tips on loading the correct width and height? |
|
| Author: | William [ Mon Dec 17, 2007 8:22 pm ] |
| Post subject: | Re: Question about forms |
You load it into the form picture here: Code: curForm.Picture = LoadPicture(App.Path & GFX_GUI & locGUI) And here you try to get the width from something that doesn't exist: Code: curForm.Width = curForm.Picture.Width curForm.Height = curForm.Picture.Height This part doesn't exist. you cant have picture.width. It should be curForm.Width, in that case. But that wont work for you either. Code: curForm.Picture.Width
|
|
| Author: | Stomach Pulser [ Mon Dec 17, 2007 8:59 pm ] |
| Post subject: | Re: Question about forms |
I tried Code: curForm.Width = LoadPicture(App.Path & GFX_GUI & locGUI).Width before I I tried my new code. But they both do the same thing. Shouldn't this have worked since I load the picture's width? |
|
| Author: | William [ Mon Dec 17, 2007 9:03 pm ] |
| Post subject: | Re: Question about forms |
You can't do that either. I don't know in my head how to do it with a form. It's much easier if you use a picture box though. |
|
| Author: | Stomach Pulser [ Mon Dec 17, 2007 9:39 pm ] |
| Post subject: | Re: Question about forms |
I know that If I load it into a picture box it will work, but I want to learn the other way, it causes for less controls... |
|
| Author: | William [ Tue Dec 18, 2007 5:03 pm ] |
| Post subject: | Re: Question about forms |
1 control doesn't make any difference what so ever to anything. It's like having 1 more pixel in paint drawn out. |
|
| Author: | Lea [ Tue Dec 18, 2007 6:59 pm ] |
| Post subject: | Re: Question about forms |
Actually, controls are what makes VB exe files huge. Delete all the controls, but have the same functionality written in code, and it will be much much smaller. |
|
| Author: | William [ Tue Dec 18, 2007 7:23 pm ] |
| Post subject: | Re: Question about forms |
We are talking about 1 control, and the size of the exe aint that important. |
|
| Author: | Stomach Pulser [ Tue Dec 18, 2007 7:32 pm ] |
| Post subject: | Re: Question about forms |
So there is no way to do this without using a control? |
|
| Author: | William [ Tue Dec 18, 2007 8:02 pm ] |
| Post subject: | Re: Question about forms |
Dave just said it is possible. There isn't a default option for it on the form, I'd say there is a declare for it. |
|
| Author: | Stomach Pulser [ Tue Dec 18, 2007 8:05 pm ] |
| Post subject: | Re: Question about forms |
Anyone know where I could find this declare? Like a database or something full of functions? |
|
| Author: | Robin [ Tue Dec 18, 2007 8:08 pm ] |
| Post subject: | Re: Question about forms |
There is probably a function which will allow you to get the width and heigh of the image file. It's stored in the files properties after all. |
|
| Author: | Lea [ Tue Dec 18, 2007 8:59 pm ] |
| Post subject: | Re: Question about forms |
You could extract the size straight from the bitmap file, look for the bitmap fileformat spec. Just open a file just like any binary file, and extract the correct datatype from the correct place. |
|
| Author: | Stomach Pulser [ Tue Dec 18, 2007 9:44 pm ] |
| Post subject: | Re: Question about forms |
Dave wrote: You could extract the size straight from the bitmap file, look for the bitmap fileformat spec. Just open a file just like any binary file, and extract the correct datatype from the correct place. I'm sorry to ask, but how would I go about doing that? Would I need to make a program that reads binary files? (already searched through forums) |
|
| Author: | Lea [ Wed Dec 19, 2007 4:43 am ] |
| Post subject: | Re: Question about forms |
The beginning of every windows bitmap file starts with this: http://www.fastgraph.com/help/bmp_header_format.html Load it using the standard binary file I/O routines provided in VB. I'm sure you can find a pre-created structure that loads the header automatically, then just call x = bitmap.width |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|