Jump to content

Gord P

Members
  • Content Count

    65
  • Joined

  • Last visited

Everything posted by Gord P

  1. I have this same problem with C++ Builder
  2. Maybe this is obvious to most or summarized better somewhere else (that I couldn't find) but here is what I have sorted out and hopefully it is a bit helpful to someone. You need to be careful when allowing users to copy and paste numeric data from Excel to a StringGrid or any control that uses text as easily lose some significant digits. It is more of an issue of how Excel pastes to the clipboard than it is a Rad Studio issue. Excel pastes the text of what you see in a cell, not the text of the number itself. For example, If you type in the number 123456789012 (twelve digits) into a cell, it will show up as 1.23457E+11 if your cell is wide enough - as follows. If it isn't wide enough, Excel will drop even more digits and it may show up as 1.23E+11. In the Formula Bar, the number still shows up as 123456789012. Now if you copy this cell, and paste it into Notepad, you will see 1.23457E+11 (or less digits as the case may be) and NOT the original number (123456798012). You have lost several digits of precision. We'll get to how to avoid that, but first I want to mention that I chose a 12 digit number as my example because for some reason if it is less than that, Excel will show the full number in the cell if your cell is wide enough (it often autosizes it to make it wide enough). Actually, if you include a decimal somewhere in there, it will only show 10 digits. Excel only wants to show 11 characters in a cell: a decimal counts as a character; and "E+00" counts as 4 characters. Interesting enough the minus sign doesn't count as a character, i.e. if you enter 112233.445566 you will see 112233.4456 in the cell. However, if you enter -112233.445566, you will see -112233.4456 in the cell. Don't ask me (I'm sure there are some here who understand the IEEE methods of storing numbers that can answer that). Don't worry if you didn't catch much of this paragraph, the bottom line is that if you enter a number into a cell with too many digits you will lose some of them. To make sure that your number pastes correctly, right click on the range of cells that you want to copy and select "Format Cells...". In the Category list, choose "Scientific". Then increase the number of decimal places to 14. [Why 14? Because Excel only has 15 digits of precision (typical Double precision). You can see this if you put in 12345678901234567980 into a cell. In the Formula bar you will see 12345679801234500000] Now when you paste the number into Notepad, or your stringgrid or wherever, you will see the full precision of the number (up to 15 digits as discussed). One minor drawback is that by choosing 14 digits behind the decimal in the scientific format, you will likely end up with a lot of 0's in your cell. For example, your number may have been 1234567 but now shows up as 1.23465700000000E+06. Those extra 0's are a waste of space in your cell. One workaround is to use ToDouble on the string that you pasted your number into as you put it into a grid cell. For example (c++ code sorry): String YourNumberAsText; YourNumberAsText = Clipboard()->AsText; YourNumberAsText.Delete(YourNumberAsText.Length()-1,2); // need to get rid of the line feed characters that Excel appends (or tab if multiple columns) StringGrid1->Cells[0][0] = YourNumberAsText.ToDouble(); I recognize that this last statement is converting a string to a double and then back to a string again but it does the trick. I was going to use FormatFloat with #.############E00 but I don't need to using ToDouble this way (i'm pretty sure anyways). Let me know if this has helped you or if you think it is completely (or partially) bogus for some reason.
  3. AFAICS there is no Copy "Special" analog to Paste Special. Paste Special in Excel is of no use in this situation because it is only applicable to copying and pasting within an Excel document. If you actually know of a better way to do what I have described, please post it. I am not saying I have posted the best solution, I have posted a solution. I am open to a better one.
  4. I assume you are saying my post is not that relevant to many people. Maybe. I am sure that there are some that copy and paste floating point numbers from Excel.
  5. Very simple to reproduce. 1. Add a TTitleBarPanel to the form. 2. In the Form's CustomTitleBar property, set Enable to True and set Control to TitleBarPanel1 as you are supposed to. 3. Drag the corner handle for the Form to resize and voila - instead of the form getting bigger, it stays the same size and white space shows up (see image below). The same happens if you increase the width or height properties of the form in the object inspector. When you run the program the form shows up as the increased size. If you add a button to the white area it doesn't show up at design time but does show up at run time. I don't see this issue online or in QP. Any idea what is happening? Am I supposed to change a setting somewhere when using TTitleBarPanel or is this a bug? I am using C++Builder (11.3) but I am sure this is not language specific (if someone can confirm this with a Delphi installation that would great - thanks)
  6. There is a work around here - at least for my case. Still had to fiddle with it. It needs to be fixed for real though. https://quality.embarcadero.com/browse/RSP-41798 HTH
  7. I can change the color of most things (so far) but the default background color for a node item in a treeview is light blue and I can't figure out where to change it. It must be possible because some of the styles, mostly the dark ones, have a color other than light blue.
  8. Has anyone been able to change the appearance of a Treeview via styles in any way (the Bitmap Style Designer or something else)? I found out how you can adjust some things if you turn off styles, but that is not what I am looking for. I am just wondering about making a change as simple as this to this for example. I'm using VCL by the way, and 11.3. Thanks
  9. I was unable to use styles to change the background color of a TreeView node, so I am trying an alternate route but once again have hit a road block. I found some code in Delphi and converted it (I think) to C++. void __fastcall TForm1::TreeView1CustomDrawItem(TCustomTreeView *Sender, TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw) { if(State.Contains(cdsSelected)) { Sender->Canvas->Brush->Color = clBlack; Sender->Canvas->Font->Color = clWhite; } } The problem is that it never fires true. When I set breakpoint at the "if" line, State shows up as "{ }" What am I doing wrong here? BTW, if I get rid of the "if" statement" so that it fires all the time, all the items show up as expected (white font on black background) except the selected node (which I don't know why).
  10. Gord P

    Why is the TCustomDrawState set empty?

    Turns out you need to turn off theming for the treeview control. void __fastcall TForm1::FormCreate(TObject *Sender) { SetWindowTheme(TreeView1->Handle, L"", L""); } It allows you to control the color but unfortunately when you do so, you get old school buttons on the treeview. It is kind of ridiculous why you have to go through so many hoops and hurdles just to adjust a color to match a specific theme. It should be easily done through the Bitmap Style Designer so the developer can focus on other things.
  11. I posted this in the Delphi IDE group thinking the problem was an IDE thing and not related to C++ but the Delphi users don't seem to be having this issue. When you add a TTitleBarPanel to use the Custom Title Bar the form designer no longer behaves properly. Increasing the form size leaves a white space (see image below) It does it constently for me on two different installations. To reproduce: 1. Add a TTitleBarPanel to the form. 2. In the Form's CustomTitleBar property, set Enable to True and set Control to TitleBarPanel1 as you are supposed to. 3. Drag the corner handle for the Form to resize and voila - instead of the form getting bigger, it stays the same size and white space shows up (see image below). The same happens if you increase the width or height properties of the form in the object inspector. If you run the program the form shows up as the increased size. If you add a button to the white area it doesn't show up at design time but does show up at run time. I don't see this issue online or in QP. Any idea what is happening? Am I supposed to change a setting somewhere when using TTitleBarPanel or is this a bug?
  12. Thanks for checking. I realized that I forgot to post that I am using 11.3. One installation without the patch and one with the patch. It does it for me every single time. Classic or Clang.
  13. Well as the subject lines states, most (95%) of the time I see a list that looks like the first image below. It is not entirely repeatable. Occasionally I get the bottom one (which is the expected response). It seems to happen more when the Classic Compiler is false. Sometimes nothing shows up, not even the list of templates. I can't imagine it is a common thing as I would have seen something online about it I am sure (because it is really irritating). Anyone have any ideas if I screwed up a setting or something and if so, which one? I am using 11.3 (no Patch 1). Never had this issue with 10.3.3.
  14. I am definitely having less occurrence of this if I remember to change the "Use 'classic' Borland compiler" setting to 'true' before I do anything. The docWiki says the default is 'true' but that is not the case.
  15. Hmm. Okay. Thanks to you both. Well it does it for me every time on two different installations (one VM and one not). Maybe I was mistaken that it had nothing to do with the C++ personality.
  16. I typically use TEdits or StringGrids to let the user input numbers. Sometimes for a given input, the number can either a regular float (123.456) or required to be entered with scientific notation (1.23456e11). I thought maybe TNumberBox might be helpful with number input (i.e. automatically handle only entering valid numerics) so I checked it out but I am unable to get it to allow the user to enter an exponent. Based on something online I think the the Microsoft's NumberBox control, which I assume TNumberBox is emulating or wrapping, has the ability do this. Could be wrong here too though. Is it not able to do this or is it just me? I have fooled around with the DisplayFormat property but no joy.
  17. Thanks for that. In the end though if I have to add code, it's not much better than the Edit control for now. It's not a big deal, I was just wondering if I was missing something on this control, but I guess not.
  18. Not too much really and that is what I have been using - along with some code to check or prevent incorrect input. I was just checking to see if the TNumberBox control would have that built in and maybe some additional features since the word "Number" is in the name of the control.
  19. Thanks for the suggestion. Unfortunately it doesn't give me the desired behavior. I would like the user to be able to enter a number such as 1.234E9. The NumberBox will not allow typing in an 'E'.
  20. Gord P

    11.2 Patch 1 is out

    Why is it that if I didn't come to the Praxis site, I wouldn't know there was a patch? Which brings me to a point I have wanted to bring up for a while: Is https://blogs.embarcadero.com/ still the site where everyone is supposed to go to see what is going on in the Rad Studio world? There is nothing happening there for months. Nothing on 11.2 let alone a patch. Or is there some other Embarcadero site to keep on top of things?
  21. Gord P

    Missing The Old Forums

    I think the OP was referring to having C++ Builder discussions not the forum in general. And I agree with him and for the reason he cited as well. That is, there has just been a major release for C++Builder and there is absolutely zero discussion on it. Very sad. I have not installed it, so I can't comment on it.
  22. Gord P

    Problem with Logging on to my.embarcadero.com

    Working for me here in Canada.
  23. Gord P

    C++Builder Journal website is down

    Okay, it's not just me then. I have been wondering about that. Hopefully just a technical glitch.
  24. I stumbled on the fact that you can have two instances (or more) of the IDE running and open up different projects. Is there any reason that this would be a bad idea? Not sure if there would be some conflict if the IDE wants access to some file or something.
  25. Gord P

    Multiple instances of C++Builder IDE

    Thanks to both.
×