Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about forms
#1
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?
Reply
#2
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
Reply
#3
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?
Reply
#4
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.
Reply
#5
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...
Reply
#6
1 control doesn't make any difference what so ever to anything. It's like having 1 more pixel in paint drawn out. Tongue
Reply
#7
We are talking about 1 control, and the size of the exe aint that important.
Reply
#8
So there is no way to do this without using a control?
Reply
#9
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.
Reply
#10
Anyone know where I could find this declare? Like a database or something full of functions?
Reply
#11
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.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#12
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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)