The MASM Forum

Members Gallery => Showcase => Topic started by: NoCforMe on August 27, 2023, 08:00:39 AM

Title: A little calculator
Post by: NoCforMe on August 27, 2023, 08:00:39 AM
The latest "product" from NoCforMe Laboratories, GmbH: a small calculator for your evaluation.

Fixed-point only, no floating point. Does basic arithmetic ops, plus shift left/right (by 1 bit). Displays in decimal or hex. Can copy result (or whatever happens to be in the calculator edit field) to the clipboard. Pretty basic. Works, so far as our limited testing here can tell.

The most complex part of coding this? Nothing having to do with the calculator code; it was the code that handles updating the edit field from the calculator buttons. I've started a new topic on this in the Workshop.

There is one problem I haven't been able to solve, would appreciate any help. It's totally cosmetic; I'm drawing a nice border around the edit control (the one that receives user input and shows the result), but that border doesn't show when the program starts. It only shows either when one of the number buttons is clicked, or if you mouse over the edit control.

I'm pretty sure I've found the cause of this, but not the reason: the edit control sits on top of a static control which I use as a "container" field; it gets filled with a bitmap that shows the rounded border on top. If I take this control out the edit control works as expected, so something about having this static underneath it is causing trouble. I don't really understand why, since the only thing I'm doing with that static is filling it with a bitmap, using STM_SETIMAGE. There's no interaction with it other than that. Not a huge problem, but annoying.

Have fun playing with this, and of course please let me know if you find any problems, other than the one described above. (I'm sure there are no bugs in here.  :biggrin: )
Title: Re: A little calculator
Post by: jj2007 on August 27, 2023, 09:09:18 AM
Great job, and no problem with borders :thumbsup:

One minor suggestion: I am used to the Windows calc.exe, so I hit Escape to clear the field... which didn't work as expected :wink2:
Title: Re: A little calculator
Post by: NoCforMe on August 27, 2023, 11:43:56 AM
OK, noted. In fact, everyone please give me your suggestions. This is only version 1. I'll start on the next version when I have enough material.
Title: Re: A little calculator
Post by: Biterider on August 27, 2023, 04:36:10 PM
Hi NoCforMe

Quote from: NoCforMe on August 27, 2023, 08:00:39 AMNoCforMe Laboratories, GmbH
:cool:

Cool program!  :thumbsup:

I am using Win10 Home 22H2 and have noticed a glitch when starting calc.exe. When the app first pops up, the border of the input control does not appear. When I move the mouse over it, it appears and remains visible from then on.

Biterider
Title: Re: A little calculator
Post by: NoCforMe on August 27, 2023, 05:59:58 PM
Yes, that's the cosmetic problem I pointed out. Happens to me w/Windows 7-64 as well. As I said, I know what's causing the problem but I don't know why it's causing it. Annoying.
Title: Re: A little calculator
Post by: Vortex on August 27, 2023, 06:54:23 PM
Hi NoCforMe,

Nice work :thumbsup:
Title: Re: A little calculator
Post by: stoo23 on September 09, 2023, 07:07:23 PM
Cool, it has a kinda nice Old 'retro' look about it, you almost Expect it to make the Sounds those old large Accounting department calculators with the big crank handles on the side used to make  :wink2:  :thumbsup:

Maye Retro' Audio in version 2 ??,..  :bgrin:
Title: Re: A little calculator
Post by: NoCforMe on September 09, 2023, 07:59:39 PM
Quote from: stoo23 on September 09, 2023, 07:07:23 PMMaye Retro' Audio in version 2 ??,..  :bgrin:

Hey, I never thought of that. Not a bad idea. "Ka-chunk!" when you click one of them buttons ...
Title: Re: A little calculator
Post by: stoo23 on September 09, 2023, 09:03:14 PM
 :smiley:

https://youtu.be/aDN4s8ElxqE

 :cool:  :thumbsup:
Title: Re: A little calculator
Post by: NoCforMe on September 10, 2023, 05:44:10 PM
OK, you asked for it. Try this baby out. (Yeah, it might get annoying after a while. Need to put a sound on/off control in it somewhere ...)
Title: Re: A little calculator
Post by: stoo23 on September 10, 2023, 06:10:34 PM
 :smiley:

Maybe each Button could just have a single 'click' (much like a typewriter), with the 'Kachunk' saved purely for the Major functions like creating an addition or Total etc  :smiley:
Title: Re: A little calculator
Post by: jj2007 on September 10, 2023, 07:05:48 PM
Quote from: NoCforMe on September 10, 2023, 05:44:10 PMOK, you asked for it. Try this baby out. (Yeah, it might get annoying after a while. Need to put a sound on/off control in it somewhere ...)

Nice :thumbsup:

Have you considered using Gdi+ for the controls, to round the edges a bit?
Title: Re: A little calculator
Post by: NoCforMe on September 10, 2023, 08:08:23 PM
Actually no. I like your rounded "window" on top better than mine (which is a bitmap that's a little jaggy). I like my "steampunk" buttons better, though.

Did you use a rounded rectangle function for that (like GDI's RoundRect() but the GDI+ version)?
Title: Re: A little calculator
Post by: jj2007 on September 10, 2023, 10:54:00 PM
Quote from: NoCforMe on September 10, 2023, 08:08:23 PMDid you use a rounded rectangle function for that (like GDI's RoundRect() but the GDI+ version)?
It's a series of GdipAddPathArcI invokes.