The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: chipbug on June 17, 2010, 02:14:36 PM

Title: editbox won't update
Post by: chipbug on June 17, 2010, 02:14:36 PM
Hello,

I am new to ASM and have been working on the attached code for days. It works but HumaCarbDose editbox and BGcarb editbox update from the calculation the first time the button is pushed. Then they won't update anymore after that unless I manually edit the text in one of those 2 boxes and press the button, then they will update. Am I missing something?

David
Title: Re: editbox won't update
Post by: Tedd on June 17, 2010, 09:55:55 PM
Something's not right there :dazzled:

I would guess at some kind of value dependency type thing (a value getting set after the first time, screwing up any following calculations), but I don't see it.

It probably doesn't help that you're not actually checking whether the text boxes contain anything before you use their values. So you're retrieving an empty string and trying to convert that to a floating-point value. And it seems the only way to get it to update is to clear the 'BGcarbMsg' box. Which is a little strange when you're not using that in the calculation.
Title: Re: editbox won't update
Post by: Gunner on June 17, 2010, 10:17:17 PM
If you are going to use SetDlgItemText with the control ID, why are you getting the handles to the controls on init?  Since you have the handle to the control just use sendmessage... Sometimes SetDlgItemText doesn't work for me so I just use SendMessage...
Title: Re: editbox won't update
Post by: chipbug on June 17, 2010, 11:07:23 PM
OK, I figured out my problem.

I put all these variables in this section and they had no values in them so they were getting assigned small areas in memory and all my variables were overwriting each other:

    .data?
        BGdropMsg   dd ?
        BGupCarbMsg dd ?
        LantusDoseMsg dd ?
        BGMsg       dd ?
        BGcarbMsg   dd ?
        CarbMsg     dd ?
        HumaCarbDoseMsg dd ?
        HumaDoseMsg dd ?
        HumaMealDoseMsg dd ?


Soon as I took them out of that section and put them in this section and gave them values it all ran smoothly:

    .data
        BGdropMsg   dd "46.5",0
        BGupCarbMsg   dd "5.2",0
        LantusDoseMsg   dd "08",0
        BGMsg       dd "08",0
        BGcarbMsg   dd "08",0
        CarbMsg     dd "08",0
        HumaCarbDoseMsg dd "08",0
        HumaDoseMsg dd "08",0
        HumaMealDoseMsg dd "08",0

I'm not exactly certain why but it works.

David
Title: Re: editbox won't update
Post by: Farabi on June 18, 2010, 12:43:57 AM
.data? is only for uninitialized data, I guess it was generated on the runtime.
.data is for initialized data, I guess it was writted on your application somewhere.
Title: Re: editbox won't update
Post by: jj2007 on June 18, 2010, 06:53:26 AM
Quote from: chipbug on June 17, 2010, 11:07:23 PM
    .data?
        BGdropMsg   dd ?

This is one dword, that you could use to store a pointer to your string

Quote
    .data
        BGdropMsg   dd "46.5",0

This is the string itself, to be used as offset BGdropMsg