News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

UpDown Controls preset ranges

Started by zemtex, July 21, 2011, 08:02:34 PM

Previous topic - Next topic

zemtex

Is it possible to pre-set the ranges of updown controls in the resource editor or am I forced to do it during runtime?
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

dedndave

you can define the info structure as initialized data and fill in the values
        .DATA

vsi SCROLLINFO <sizeof SCROLLINFO,SIF_RANGE or SIF_PAGE or SIF_POS,0,32,0,0,0>

zemtex

Thanks. What system call should I use to apply this data to the UpDown control?

I normally use ACCEL's and SetRange

Never mind, you use SetScrollInfo function

EDIT: Btw are you sure you are talking about the same control as I am? You're not talking about a VSCROLL are you? I'm talking about an UpDown control, which you autobuddy to an edit control.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

dedndave

yes - i am talking about vertical scroll
doesn't an UpDown control use the same structure ?

Gunner

You can also use sendmessage with the message UDM_SETRANGE or UDM_SETRANGE32
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

zemtex

Quote from: Gunner on July 22, 2011, 12:52:17 AM
You can also use sendmessage with the message UDM_SETRANGE or UDM_SETRANGE32

I am currently using: Invoke SendDlgItemMessage, MainWinHandle, eax, UDM_SETRANGE32, UDN_LOWER_LIMIT, UDN_UPPER_LIMIT

The last two are signed constants. eax is currently in a loop, im looping through all updown controls instead of setting each individually.

My main question was if it is possible to hardtype the values in a resource file, Is it possible?  :bg
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

dedndave

Bill Craven gives an example in C:\masm32\examples\bcraven\controls
in the resource file....
    CONTROL         "Spin1",ID_SPIN1,"msctls_updown32",UDS_SETBUDDYINT |
                    UDS_AUTOBUDDY | UDS_ARROWKEYS,83,77,11,38

and....
    CONTROL         "Spin2",ID_SPIN2,"msctls_updown32",UDS_SETBUDDYINT |
                    UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HORZ,197,84,31,19,
                    WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE


there is a help file for resource files, and more info on MSDN, too
C:\masm32\bin\rc.hlp

http://msdn.microsoft.com/en-us/library/aa380599%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/aa380911%28v=VS.85%29.aspx

i think the numbers indicate position
with a quick browse, i don't see a way to preset the range in the resource file

zemtex

dedndave, I can't see that craven initializes the range anywhere, I only see positions. But thanks anyway.

I want to be able to pre-set the range of the UpDown control anywhere but in the code, in order to reduce the size of the program because I have quite a lot of UpDown controls, some of them need different numbers.
So far, I loop through most of them and then assign numbers to those who need exceptional numbers. It's not too bad, I can live with it so far. But if you know a different method, don't hesitate to tell  :8)
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

dedndave

i have found that everything in the resource file tends to make the EXE larger - lol
for example, i create my own menus in code and it is less than half the size
i create my own scroll bars, etc, in code also
there are some things that have to be in the resource file, like the manifest
and, it's probably best to put the icon in there so windows can find it

zemtex

We need a tool that can convert resource files into assembly data and instructions.  :U
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

mineiro

To Radasm 2.2.?.? have an addin called "dlgtowin", this one transform(export) the dialog into createwindow functions.
This addin add a menu in "tools", and it is enabled if you are looking to the dlgresource. You need do it some twice, because you need export ID equals, controls, names,.. .
You can get it in a page of Sr Bogdan Ontanu.
http://www.oby.ro/rad_asm/projects/projects.html

zemtex

Maybe the executable will be smaller, but will it be faster? I mean if you have 80 controls to create on startup, and you want to use CreateWindowEx to do all of them instead of a resource file, doesnt that give a noticeable delay? I've used resource files for the most part, you tell me.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

Gunner

AFAIK, windows still has to use CreateWindowEx to create all the controls you have in your resource section.  By doing it yourself, you remove that extra overhead.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave

that's right
the resource data is still converted into code, only the OS does it instead of you doing it
in one of my projects, i have the main window and 6 controls
i made a table of parameters and create them in a loop
probably faster and smaller that the OS would do it   :P

dedndave

        .DATA

        ALIGN   4

WinCreateTable  dd WS_CHILD or WS_VISIBLE or SBARS_SIZEGRIP,StatusClass
                dd WS_CHILD or SBS_HORZ,ScrollClass
                dd WS_CHILD or SBS_VERT,ScrollClass
                dd WS_CHILD or SBS_SIZEBOX,ScrollClass
                dd WS_CHILD or SBS_SIZEGRIP,ScrollClass
                dd WS_CHILD or WS_VISIBLE,TxtClass

ScrollClass     db 'ScrollBar',0
StatusClass     db 'msctls_statusbar32',0
TxtClass        db 'TextClass',0

        .DATA?

        ALIGN   4

ControlHandles  LABEL   DWORD
hStatus         dd ? ;ID = 1001h
hHScroll        dd ? ;ID = 1002h
hVScroll        dd ? ;ID = 1004h
hSizeBoxNG      dd ? ;ID = 1008h
hSizeBoxG       dd ? ;ID = 1010h
hTxt            dd ? ;ID = 1020h


then, in the WM_CREATE code for the main window...
        push    6
        mov     ebx,hWnd                                    ;EBX = hWnd
        xor     edi,edi                                     ;EDI = 0
        mov     eax,CID_STATUSBAR                           ;EAX = control ID
        pop     ecx                                         ;ECX = loop count
        mov     esi,offset WinCreateTable                   ;ESI = table pointer
        mov     hWin,ebx
        mov     edx,offset ControlHandles                   ;EDX = handle pointer

CrWin0: push    eax
        push    ecx
        push    edx
        push    edi                                         ;CreateWindowEx:lpParam
        push    hInstance                                   ;CreateWindowEx:hInstance
        push    eax                                         ;CreateWindowEx:hMenu (control ID)
        push    ebx                                         ;CreateWindowEx:hWndParent
        push    edi                                         ;CreateWindowEx:nHeight
        lodsd
        push    edi                                         ;CreateWindowEx:nWidth
        push    edi                                         ;CreateWindowEx:y
        push    edi                                         ;CreateWindowEx:x
        push    eax                                         ;CreateWindowEx:dwStyle
        lodsd
        push    edi                                         ;CreateWindowEx:lpWindowName
        push    eax                                         ;CreateWindowEx:lpClassName
        push    edi                                         ;CreateWindowEx:dwExStyle
        CALL    CreateWindowEx
        pop     edx
        pop     ecx
        mov     [edx],eax                                   ;store the handle
        pop     eax
        add     edx,4                                       ;point to next handle
        shl     al,1                                        ;next control ID
        loop    CrWin0