The MASM Forum

General => The Campus => Topic started by: demondoido on April 11, 2013, 11:15:38 AM

Title: Way to autoalign and autoresize (MASM32+Win32API)
Post by: demondoido on April 11, 2013, 11:15:38 AM
I'm working on a simple program to diet control... I'm searching for a way to autoalign and autoresize elements... A theoretical example:
-> The user opens the software
-> Two buttons side by side: |--B1--| |--B2--|
-> The user resizes the software
-> The buttons grow like this: |----B1----| |----B2----|

Other example:

-> The user opens the software
-> A button: (WindowLeftEdge) [space] Button [space] (WindowRightEdge)
-> The user resizes the software
-> The button keeps the center position: (WindowLeftEdge) [space] [space] Button [space] [space] (WindowRightEdge)

My question is: is there anyway to do this using the Windows API (something using constants of style...) or I would have to do this by hand (writing codes to autoalign and autoresize)?

Sorry for my poor english :s (I'm Brazilian)
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: qWord on April 11, 2013, 11:38:29 AM
There are no container controls in the WinAPI, thus you need to do it by hand.
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: dedndave on April 11, 2013, 12:20:02 PM
as qWord said - by hand

a while back, Edgar (Donkey) showed me how to use BeginDeferWindowPos, DeferWindowPos, EndDeferWindowPos
it makes for smoother resizing of multiple child windows
it's a little more advanced, but worth the extra effort
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: dedndave on April 11, 2013, 12:23:44 PM
here is a small example....

http://masm32.com/board/index.php?topic=1026.msg10028#msg10028 (http://masm32.com/board/index.php?topic=1026.msg10028#msg10028)

notice the wmSize and SetWndPos routines
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: demondoido on April 11, 2013, 10:00:12 PM
Well, I'm loving Assembly, in this level of software development there aren't frills, but it's a great way to work, you have absolute control...

I need a hint... I know that the main function of DLLs is to facilitate the reuse of codes... But, is it a good idea to create DLLs to implement functions such as autoresize and autoalign, to insert elements (buttons, textboxes...), tables and other operations?
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: dedndave on April 12, 2013, 01:57:20 AM
a static library is probably better for what you are talking about
an example of one is the masm32 library (\masm32\lib\masm32.lib)
the source files for the functions that are inside that library are in the \masm32\m32lib folder
and, it has an include file that accompanies it, \masm32\include\masm32.inc

DLL's can be used that way, but are typically used a little differently
for example, i might have a set of DLL's for a program
i might load and unload DLL's for different operations in order to reduce memory usage
or, i might use different DLL's, depending on the CPU and/or OS

i don't manage a large collection of functions or large programs, so i do things a little simpler
i just have the source for functions in several files, and grab them as required   :P
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: demondoido on April 12, 2013, 02:15:34 AM
I understood, and moreover, I read about DLLs and static libs, thanks for the hints Dave!  ;)
Title: Re: Way to autoalign and autoresize (MASM32+Win32API)
Post by: MichaelW on April 12, 2013, 06:52:29 AM
Auto-align and auto-resize code would be much easier to implement in a high-level language.