Results 1 to 10 of 10

Thread: Textbox with calculator?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Textbox with calculator?

    Before I re-invent the wheel...

    I look for a textbox that provides a calculator.
    Not to calculate IN the textbox, just a calculator which pops out via context menu like a combobox.

    Perhaps someone has an idea?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Textbox with calculator?

    You can just show a form from the click on a context menu?
    Or do you mean something different?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: Textbox with calculator?

    That is right.
    And that's what I have up to now.

    I need a more sophisticated solution.
    In order to avoid that I have to care about the additional form.
    An additional form has to be on top always, I have to manage it to go away when I click outside the form, and many more thing to consider.
    In a usercontrol this all is easier to manage.

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Textbox with calculator?

    Power users love to have expression evaluation in *all* places where numeric values are entered. They just love the power of entering complex expression and forcing the computer to actually compute something useful for them.

    For the rest of your end-users even if you implement a super-duper calculator right there next to the textbox, they'll still use the Windows built-in one out of habit and inability to change habits at old age. C'est la vie. . .

    cheers,
    </wqw>

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Textbox with calculator?

    i like this idea, i have a commercial program that has this feature, though it is only a line calculator, no buttons just keyboard input, i use it all the time
    i have previously designed a calendar to show in a picturebox, positioned next to any textbox (before calendar controls were common) , i guess i would do the same for a calculator, if i was going to implement it
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: Textbox with calculator?

    I'm still not sure what exactly you're looking for here.

    Sounds like you just want to add a 'open calculator' entry to the context menu? You can add items to the default context menu with edit/paste/etc, it's a little complicated but do-able.

    For some of the behavior you're talking about, I've used a PictureBox that I make behave like a tool window, can drag it around:
    Code:
    Private Sub PictureBox1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
        Call ReleaseCapture
        Call SendMessage(PictureBox1.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
    End Sub
    You'll probably want to use SetParent when you show it too.

    and make it resizeable:
    Code:
    Dim dwFr As WindowStyles
    dwFr = GetWindowLong(PictureBox1.hWnd, GWL_STYLE)
    dwFr = dwFr Or WS_BORDER Or WS_THICKFRAME
    SetWindowLong PictureBox1.hWnd, GWL_STYLE, dwFr
    You could hide it just by checking if it's open when you click the parent form.

    If you do just want to have a TextBox that's a calculator, there are projects like that. I've got one that's pretty sophisticated; has all the scientific calculator functions like sin, sinh, sec, log, ln, ncr, etc. And some fun stuff, like converting to roman numerals, giving number names all the way up to 1000 Milliatillion-1 (1 milliatillion is 10^3003), and multiplying polynomials (e.g. if you enter (x^6+4)(x^2-x-5)(x^3+2) it gives you x^11-x^10-5x^9+2x^8-2x^7-10x^6+4x^5-4x^4-20x^3+8x^2-8x-40 ), solving linear and quadratic equations, doing summations, etc... let me know if you're interested in something like that, modified a basic calculator but never cleaned it up enough for a public release before.
    And if any of you have a calculator code more sophisticated than that, let me know because I'm interested.
    Last edited by fafalone; Oct 2nd, 2020 at 05:56 PM.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Textbox with calculator?

    I pictured something like this (non-working mockup):

    Name:  sshot.png
Views: 217
Size:  2.3 KB

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: Textbox with calculator?

    Quote Originally Posted by dilettante View Post
    I pictured something like this (non-working mockup):

    Name:  sshot.png
Views: 217
Size:  2.3 KB
    Exactly!
    My initial question was if something like this already exists.
    Apparently it doesn't.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: Textbox with calculator?

    Quote Originally Posted by wqweto View Post
    Power users love to have expression evaluation in *all* places where numeric values are entered.
    My user have power enough, but not on using software

    For the rest of your end-users even if you implement a super-duper calculator right there next to the textbox, they'll still use the Windows built-in one out of habit and inability to change habits at old age. C'est la vie. . .
    I suspect my users don't know the Windows calculator.
    Nor they know the clipboard.
    Therefore I want to give them something usable.

  10. #10
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Textbox with calculator?

    And now i'm going for the Overkill:
    Why not shell calc.exe, use the PID that shell returns to find/get the hWnd of calc.exe, and then SetParent to a Picture-Box?

    Right, just thinking out of my a** right now.
    No idea if it's even possible.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width