Alright, I was reading Iczelion's asm tutorials, and I decided to go off on my own and play around with the controls, which led me to this question:
Is there an easy way to make a control the size of the window's space, and then when it is resized, make the control stretch to the border so it is always the size of the window.

Thanks in advance.
Posted on 2008-01-08 19:55:52 by HKothari
Well I assume by the "size of the window" you mean the size of the client area of the window. If so, then just put the X and the Y property of the window to both (0, 0). Then intercept the WM_SIZE and the WM_SIZING window messages that are sent to your window. Upon receiving them, resize your child window perhaps with SetWindowPos().
Posted on 2008-01-09 00:54:31 by XCHG
Thanks :D

Umm... How would I get the length and width of the client area?  :|
Posted on 2008-01-09 04:31:59 by HKothari

How would I get the length and width of the client area?  :|


GetClientRect
Posted on 2008-01-09 06:08:13 by JimmyClif
As XCHG said, intercepting WM_SIZE gives you the size of the window's client area.

quote from msdn:
lParam
The low-order word of lParam specifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
Posted on 2008-01-09 09:38:30 by ti_mo_n
Oh I misread.. a great way to do that is as follows:


wParamL             equ <WORD PTR >
wParamH             equ <WORD PTR >
lParamL             equ <WORD PTR >
lParamH             equ <WORD PTR >

.IF uMsg==WM_SIZE
    movzx eax, lParamH ; width
    movzx edx, lParamL ; height


Think I grabbed those from Ernie :thumbsup:
Posted on 2008-01-09 13:26:30 by JimmyClif
If you also process WM_SIZING, the lParam parameter will point to a RECT structure that contains the rectangular borders of the parent window. This might also be useful  :roll: With this message you can also prevent the window from being changed by changing the values of the RECT structure to which you are given a pointer to, through the lParam parameter. Just change the left, right, top and/or bottom values and you will prevent the user from changing the size of your window.
Posted on 2008-01-09 13:35:24 by XCHG
Thanks all, I took a look at JimmyClif's code and I found it rather useful for when the window is sizing, but when the window is created, I tried using it with one of my controls and it just disappeared. I'm not sure what happened, or what I'm doing wrong, but I appreciate your help :D
Here's the code that is important to this by the way:
.ELSEIF uMsg==WM_CREATE
movzx eax, lParamH ; width
movzx edx, lParamL ; height
invoke CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditClassName,NULL,\
                        WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or\
                        ES_AUTOHSCROLL or ES_MULTILINE or ES_WANTRETURN,\
                        0,0,lParamH,lParamL,hWnd,EditID,hInstance,NULL
mov  hwndEdit,eax
invoke SetFocus, hwndEdit
.ELSEIF uMsg==WM_SIZE
movzx eax, lParamH ; width
movzx edx, lParamL ; height
invoke SetWindowPos, hwndEdit, HWND_TOPMOST, 0, 0, lParamH, lParamL, NULL

By the way, I am just trying to make a simple notepad program if your wondering.
Posted on 2008-01-09 15:29:49 by HKothari
Well, during the WM_CREATE Message the lParam contains most probably 0 as it's the value passed as lParam during the CreateWindowEx call.

Basically you are creating a 0,0 window.

Only inside WM_SIZING and WM_SIZE the lParam contains the size of the window.
Posted on 2008-01-09 15:43:55 by JimmyClif
Oh, got it, then, is there a way on WM_CREATE that I can create the control at the size of the window?
Posted on 2008-01-09 16:13:09 by HKothari
Intercept the WM_PARENTNOTIFY message. That message is sent to your parent window whenever a child window is created. Then do whatever you want to do with the child window there.
Posted on 2008-01-09 16:26:23 by XCHG