Hi,

I'm a beginner in WinAsm and need some help, both in API and Asm.
First, how can I have dynamic strings array in asm, e.g. I need to read an unknown number of lines from text file into array for manipulation.
Second, how can I do a trick when the user can change window lenght but not height. I know it's WM_SIZING, but what to do next?
Thanks.

delphi boy
Posted on 2001-12-03 19:03:42 by delphi_boy
delphi_boy,

The dynamic string capacity is a BASIC technique and in 32 bit windows, OLE string is used to provide that capacity.


; include \MASM32\include\oleaut32.inc
; includelib \MASM32\LIB\oleaut32.lib
;
; --------------------------------------------------
stralloc MACRO ln
invoke SysAllocStringByteLen,0,ln
ENDM

strfree MACRO strhandle
invoke SysFreeString,strhandle
ENDM


This is a pair of macros that use OLE string. You will find more in the oleaut32 technical data where you can use either ANSI or unicode string allocation.

Somewhere you will need to find out how many lines are in the text file you wish to load into string arrays. What I would suggest is an array to hold the string handles that are returned from the OLE functions you use and thwen you can store them sequentially in the array.

Thomas Bleeker posted a procedure to use in the WM_SIZING message recently and I posted a pair of macros.



; -------------------------------------------------------------------
; The following 2 macros are for limiting the size of a window while
; it is being resized. They are to be used in the WM_SIZING message.
; -------------------------------------------------------------------
LimitWindowWidth MACRO wdth
LOCAL label
mov eax, lParam
mov ecx, (RECT PTR [eax]).right
sub ecx, (RECT PTR [eax]).left
cmp ecx, wdth
jg label
.if wParam == WMSZ_RIGHT || wParam == WMSZ_BOTTOMRIGHT || wParam == WMSZ_TOPRIGHT
mov ecx, (RECT PTR [eax]).left
add ecx, wdth
mov (RECT PTR [eax]).right, ecx
.elseif wParam == WMSZ_LEFT || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_TOPLEFT
mov ecx, (RECT PTR [eax]).right
sub ecx, wdth
mov (RECT PTR [eax]).left, ecx
.endif
label:
ENDM

LimitWindowHeight MACRO whgt
LOCAL label
mov eax, lParam
mov ecx, (RECT PTR [eax]).bottom
sub ecx, (RECT PTR [eax]).top
cmp ecx, whgt
jg label
.if wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT
mov ecx, (RECT PTR [eax]).bottom
sub ecx, whgt
mov (RECT PTR [eax]).top, ecx
.elseif wParam == WMSZ_BOTTOM || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT
mov ecx, (RECT PTR [eax]).top
add ecx, whgt
mov (RECT PTR [eax]).bottom, ecx
.endif
label:
ENDM


Either the proc posted by Thomas or the two macros above will do the job for you.

Regards,

hutch@movsd.com
Posted on 2001-12-03 22:18:56 by hutch--
Thanks hutch for help, it's working, I made it set a fixed height as I needed, now one more problem. My dialog window has just a combo box and nothing else, how to make the combo change it's width together with window's width? I found only CB_SETDROPPEDWIDTH, it sets the dropped list width, but I need also adjust the edit control width together. Thanks alot.

delphi boy

-//spoiled by delphi\\-
Posted on 2001-12-04 19:19:44 by delphi_boy
Use MoveWindow on the edit control hwnd in WM_SIZING, I guess.
Posted on 2001-12-04 20:04:34 by f0dder