Ecere SDK/eC Forums http://ecere.com/forums/ Print view |
|
Printing integers and control array http://ecere.com/forums/viewtopic.php?f=5&t=88 |
Page 1 of 1 |
Author: | D.Bane [ Sat Aug 07, 2010 11:10 am ] |
Post subject: | Printing integers and control array |
I guess a lot of you may find this stupid to ask, but since I have a problem with it, I really need some help.. I want to type a number on the window, or MessageBox and it allways gives me an error.. This is how I did it.. Code: Select all
So my questions are, is there a way I can create Label lblName [15], and how can I make "i" (integer) write it self on surface, or function return code on MessageBox.. PS: If I pass someWindowClass.text, to pointer I got empty string..Is that normal, or do I have many errors in my codes for now? |
Author: | jerome [ Sat Aug 07, 2010 2:01 pm ] |
Post subject: | Re: Printing integers and control array |
There are no stupid questions, only stupid answers. Don't be shy to ask, that's how we fill up these forums with easy to find answers! Turning numbers into a string of digits characters is a process that is often greatly simplified by programming languages. C belongs to the category of those in which it is not. Because C supports direct memory access, and because character strings are typically stored into pointers used to reference an address, casting a number to a char * in fact makes up a pointer pointing at the memory location represented by that number. That will be an invalid address unless your number is indeed a valid address in memory your program allocated. So you don't want to be doing that. The typical way to turn a number into a string in C is using the standard C library sprintf function. There are a few additional ways to do it in eC. You can take a look at this post on the eC programming Google Groups. Here's the excerpt: It seems the Surface object is lacking a Print like function that can conveniently accept any type of parameters. (New Mantis ticket here) DialogBoxes and other Window objects also seem to be lacking this type of functionality. For now this code should do it: Code: Select all
|
Author: | jerome [ Sat Aug 07, 2010 2:28 pm ] |
Post subject: | Re: Printing integers and control array |
About using arrays of controls: it is possible in eC as well. You can use either a C array (Label labels[15]) or an eC dynamic array (Array<Label> labels { }) The former however does not allow for instantiation within the declaration, so you will need to instantiate all of them in your constructor: Code: Select all
Code: Select all
|
Author: | D.Bane [ Sat Aug 07, 2010 3:24 pm ] |
Post subject: | Re: Printing integers and control array |
Thanks, that helped. (I prefer here C version..for what I want now). Just to add if someone also want's the label to be different color change opacity from 0 to 1 (also background) Thanks again, for both answers |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |