Page 1 of 1

Posted: Thu Feb 28, 2002 12:48 am
by BackupUser
Restored from previous forum. Originally posted by PB.

I said:

I'm having trouble understanding the theory behind resizing a window and having
all the gadgets resize accordingly.


Never mind -- I found out how at Microsoft's Knowledge Base. I've posted a
PureBasic example in the Tricks 'N' Tips section for those interested.


Edited by - PB on 28 February 2002 01:33:28

Posted: Thu Feb 28, 2002 1:46 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

Hi PB
It isnt hard as it looks like... :wink: For example you set the windowsize when open your app to 200x200 (width/height) and want to resize to 400x200 for example...

Code: Select all

[u]Example Graphic for 200x200 Window:[/u]

    A                   B 
    +-------------------+
    |                   | 
    |  E   F     I   J  |
    |  +---+     +---+  |
    |  | 1 |  |  | 2 |  |
    |  +---+     +---+  |
    |  G   H     K   L  |
    |                   | 
    +-------------------+
    C                   D
I feel me like an azkie artist :wink: Ok, lets continue...

At programstart we must declare "winw = 200" and "winh = 200" this is where we will store the size for our window we want to open at programstart with this size... Now we have to check if the window was resized "#WM_SIZE" and if so, we must store the new width and height to our "winh" and "winw" variables... We can get the actual window height (distance between A and C) and window width (distance between A and B) everytime just using something like:

Code: Select all

    "winw = WindowWidth() : winh = WindowHeight()"
Window A Example:
We have to create our two gadgets on the window and have to set the coordinates for this. If you want everytime the same height for the gadgets, we must fix this value, else our gadgets will be resized in height too... If we want only a resizing in the width, we have to do follwing points, using "ButtonGadget(#Gadget, x, y, Width, Heigth, Text$)" for example...

Code: Select all

#gadget = Let us use 1 for Gadget1
x       = fixed position (E), for example 10 pixel from left
y       = fixed position (E), for example 10 pixel from top
Width   = not fixed! Only store our start val, 50 for example (F-E)
Height  = fixed height! (G-E) let us say 10 pixel height
Text    = Button1
When our window will now resized, we have the new windowsize and know the fixed and the new changed offsets for our gadgets and redraw it, using "ResizeGadget(#Gadget, x, y, Width, Height)"

Code: Select all

    ResizeGadget ( 1, 10, 10, winw-150, 10)       ; 200 org win width - org gad width = 150
So... this is only a really fast example turorial... Hope this explain you a little bit the technic behind resizing a complete app... Now its late and i will stop here... Maybe when having some time a will poste a working source example...!? Hope i have made no mistakes on this small reply... :wink: Good luck


PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten

Posted: Thu Feb 28, 2002 1:51 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> It isnt hard as it looks like... :wink:

Thanks for taking the time to write all that for me -- it's truly appreciated.
Unfortunately I just beat you to the answer before you posted yours, so I'm
sorry that you went to all that trouble.


PB - Registered PureBasic Coder

Posted: Thu Feb 28, 2002 1:52 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

Hi PB
hehe... i have read your post somewhere at 1am i think and tried to write some stuff, creating the small coloured box, formating text and so on... Needed about 30-45 minutes i think...!? Then i posted my stuff and saw that you changed your posting... :wink: Seems i am evertime to slow :wink: bye


PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten

Posted: Thu Feb 28, 2002 1:53 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

Wow... again a new posting from you PB :wink: You are really a very fast one... hehe


PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten