News:

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

Help with controls

Started by Bieb, January 01, 2005, 01:13:57 AM

Previous topic - Next topic

Bieb

I'm starting to learn the basics of working with controls, so I decided to try and do something simple with slider and progress bars.  In the attached project, there's a form with a progress bar and three slider bars.  In theory, the slider bar's minvalue, maxvalue, and value properties should be set to the values of the slider bars, but it doesn't do anything.  Anyone know what I did wrong?

[attachment deleted by admin]

Ramon Sala

Hi Bieb,

First of all I have to say that a bug in Easy Code libraries made SetMaxValue, SetMinValue and SetValue methods not to work at all for ProgressBar and Slider objects. This has been fixed and the new libraries are included in the attached ECLibs.zip file. Once unzipped, please follow the Readme.txt file instructions.

On the other hand, I attached your SliderBar project too. It has been modified because you did not use the window procedure properly for ProgressBar and Slider objects. The window procedure for an object is called on every message it receives, so you should not write code without first checking the message. In the Window1Slider1 procedure you wrote the following code:

Window1Slider1  Proc
    Invoke GetValue, hWnd
    Mov MedValue, Eax
    Invoke SetMaxValue, pbHandle, MedValue
    Return FALSE
Window1Slider1  EndP


This code is being executed for each message that Slider1 object receives, which is not what you want to do and sometimes it may cause a crash. Instead, you have to write something like this (see the attached project SledrBar.zip):

Window1Slider1  Proc
   
    .If uMsg == WM_MOUSEMOVE ;Is mouse being moved?
        .If wParam == MK_LBUTTON ;Is mouse left button pressed?
            Invoke GetValue, hWnd
            Mov MedValue, Eax
            Invoke SetMaxValue, pbHandle, MedValue
        .EndIf
    .EndIf
    Return FALSE
Window1Slider1  EndP


so that the code will only be executed while mouse is being moved and the left button is pressed.

Replace the Easy Code libraries with the ones attached (ECLibs.zip) and have a look at the modified SliderBar project (SliderBar.zip). Thank you very much for your help.

Regards,

Ramon


[attachment deleted by admin]
Greetings from Catalonia


Vortex

Hi Bieb,

Did you check the example coming with Hutch's masm32 package? Have a look at C:\masm32\examples\bcraven\controls.