|
Ok, i have yet another refreshing problem. I have a lsitbox on a dialogpage (actually, its page1 of a propertysheet dialog, if it makes any difference) that has x number of strings. The user has the option to delete, add to, or edit a current string. If the user selects, say, to add a new string, a new window pops up asking for the name of the string.
WHen the user hits ok, the stringname is stored and added to the contents of the lisbox. However, when the user hits ok, the main page (with the listbox) is now in focus, and the contents of the listbox have not been updated. The only way to see the new string is to change focus to another page in the dialog box, or close the dialogbox and reopen it.
I've tried UpdateData() in OnSetActive, which i put in the page1 class of my propertysheet. It didint work. (i admit i dont fully understand it, but it was a shot in the dark).
Is there some way i can refresh the page (or the whole dialog for that matter) When focus is set to it? Or, is there a way to refresh only the listbox?
*.*
|
|
|
|
|
keegan wrote:
WHen the user hits ok, the stringname is stored and added to the contents of the lisbox. However, when the user hits ok, the main page (with the listbox) is now in focus, and the contents of the listbox have not been updated.
These two seem contradictory.
You have a property page (which is derived from a dialog) that has a listbox and an Add button on it. When the Add button is clicked, a (modal) dialog is displayed where text can be entered. When that dialog is dismissed, the text that was entered is added to the listbox. Yes? You should have code something like:
void CMyPropertyPage::OnClickAdd()
{
CMyDialog dlg;
if (dlg.DoModal() == IDOK)
m_listbox.AddString(dlg.m_strText);
}
Otherwise, I'm not understanding your question.
|
|
|
|
|
Heh, i was putting my AddString in my DoDataExchange. It's worked there on other pages, but i see why it should go where you suggested.
Once again, thanks
*.*
|
|
|
|
|
DoDataExchange() is only called during a call to UpdateData().
As a side note, you should rarely, if ever, have a need to explicitly call UpdateData().
|
|
|
|
|
I have a dialog app that I've written. I want to put our company logo on it but it's in jpg format. I could resave it to a bitmap but it takes away from it's colors. So how can I display this jpg on my dialog app?
I've looked at some of the examples in the bitmaps section of codeproject but these are way too much more than I need. Any suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You could transform it into a 24 bit bitmap but it will be a large file... I would use CxImage but I agree it is a lot of code for a simple thing like that. I think there are ways using ActiveX but I am not sure how to do this.
John
|
|
|
|
|
Try using GDI+. Displays JPEGs beautifully
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
I would like to read files greater than 32G. I think ReadFile can only handle 4 Gig files. Any suggestion? Would Mapped file work:?
Rdh
|
|
|
|
|
|
Assuming you are not wanting to read the entire file at once, there is still a maximum of 3GB of address space available. Just a guess, but I'd say that you'll need to read the file in chunks.
|
|
|
|
|
Let me see if I can explain this with shortness and clearity.
I am having to hard code the layout of a struct in memory.
Meaning that I have to hard code the actual memory location of each element in the struct.
Lets just say for simplicity that I have to start my first element at 0x0000.
The struct is layed out like this:
struct data<br />
{<br />
double min[4];<br />
double max[4];<br />
char name[4];<br />
int count;<br />
<br />
}
In order to create the struct in memory I think I need to create the layout of a byte(short word) like so:
typedef union u_do_word{<br />
unsigned short word;<br />
struct do_word_bits{<br />
unsigned pad : 8;<br />
unsigned bit7 :1;<br />
unsigned bit6 :1;<br />
unsigned bit5 :1;<br />
unsigned bit4 :1;<br />
unsigned bit3 :1;<br />
unsigned bit2 :1;<br />
unsigned bit1 :1;<br />
unsigned bit0 :1;<br />
}bits;<br />
} do_word_t;
And create the pointer and variables for the elements
I put the hex address in the name.
start of the min array
<br />
static do_word_t word_0x00;<br />
static unsigned short *vme_word_0x00;
static do_word_t word_0x20;<br />
static unsigned short *vme_word_0x20;
static do_word_t word_0x40;<br />
static unsigned short *vme_word_0x40;
static do_word_t word_0x80;<br />
static unsigned short *vme_word_0x80;
start of the max array
<br />
static do_word_t word_0xA0;<br />
static unsigned short *vme_word_0xA0;
static do_word_t word_0xC0;<br />
static unsigned short *vme_word_0xC0;
static do_word_t word_0xE0;<br />
static unsigned short *vme_word_0xE0;
static do_word_t word_0x100;<br />
static unsigned short *vme_word_100;
start of the char array
This is the part that I am not sure about.
I believe that an unsigned short will give me the correct size for a double, but how should I do the char array.
Is this correct???
static do_word_t word_0x120;<br />
static unsigned char *vme_word_0x120;
<br />
static do_word_t word_0x?????; (?? 0x124 ??)<br />
static unsigned char *vme_word_0x?????;
<br />
static do_word_t word_0x?????; (?? 0x128 ??)<br />
static unsigned char *vme_word_0x?????;
<br />
static do_word_t word_0x?????; (?? 0x12C ??)<br />
static unsigned char *vme_word_0x?????;
I am not sure how to step through the memory and create the correct size for the char array or the int at the end
Thanks for taking the time to read my winded message,
Steven
|
|
|
|
|
The size of a double is 8 bytes. Use the sizeof(double) to see that your self. I have no clue why you would want to do this. Also if you don't pack the data using #pragma pack(push,1) before your struct and #pragma pack(pop) after your struct you will get unexpected results.
John
|
|
|
|
|
I have used type "double" for the elements in my array. My numbers are 10 digits long, so I can't use the int type. My numbers don't have any decimals in them, but the output from my program is displaying decimals on the monitor. eg. number 2647584936 will display as 2647584936.000000
How do I get rid of the decimal and the six zeros?
Thanks
|
|
|
|
|
No idea,
But i'd use the Int64 type instead of int. The max size of Int64 is 2^64 --> Seems big enough.
|
|
|
|
|
I tried to enter the "int64" data type into my VC++ 6.0 compiler, but it doesn't turn blue as do other valid prototypes. How do I implement the int64 data type? It sounds very interesting.
Thanks
|
|
|
|
|
Use long integer (long int) instead! This should work: range is:
–2,147,483,648 to 2,147,483,647 . Or you can even use unsigned long int if you don't need negative numbers.
|
|
|
|
|
It's a Microsoft-specific type, so you must preface it with two underscores.
|
|
|
|
|
look for SetPrecision on the msdn library.
or look here.[^]
*.*
|
|
|
|
|
User the correct type specifier in your print, e.g.
<br />
str.Format("%5.0f", d)
where str is a CString and d is the double variable.
Elaine
The tigress is here
|
|
|
|
|
Thanks Elaine, I was hoping you might show me how to apply the code you mentioned into my program below?
<br />
#include "stdio.h"<br />
#include "math.h"<br />
#include "iostream.h"<br />
#include "stdlib.h"<br />
<br />
<br />
double values[] = {<br />
1115364759770,<br />
3748596078661, <br />
3849573800596,<br />
3849573846696,<br />
4615243374995,<br />
4745520008574,<br />
4748020008574,<br />
4847020005584,<br />
4847020007584, <br />
5758020005007,<br />
5758020005287,<br />
7557030006574, <br />
7937030006574,<br />
9500020004758, <br />
9585520004758, <br />
};<br />
<br />
<br />
int compare (const void * a, const void * b)<br />
{<br />
#define ABS(a) ((a) < 0 ? -(a) : (a) ) <br />
double _a = *(double*)a; <br />
double _b = *(double*)b; <br />
if( ABS(_a - _b) < 0.00000001 ) <br />
return 0; <br />
else if( _a < _b)<br />
return -1; <br />
else <br />
return 1;<br />
}<br />
int main ()<br />
{ <br />
double * pItem; <br />
cout<<"please enter a number"<<endl; <br />
double key;<br />
cin>>key; <br />
pItem = (double*) bsearch (&key, values, 15, sizeof (double), compare); <br />
if (pItem!=NULL) <br />
printf ("%lf is in the array\n",*pItem);<br />
else <br />
printf ("%lf is not in the array\n",key); <br />
return 0;<br />
}<br />
Dave
|
|
|
|
|
printf("%.0f is in the array\n", *pItem);<br />
printf("%.0f is not in the array\n", key);
|
|
|
|
|
Instead of printing them with '%f' , print them with '%10.f' . This will get rid of the decimal point and the digits following it.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks everybody, the %10.f and %.0f worked great.
|
|
|
|
|
Does anyone know of any Natural Language Processing open source for
C++?
at this point in my search, I will take any suggestions, even a link to a free VB source nah forget that. But maybe Java.
I have posted a question to Google answers, and they are trying to find me one too but no answer yet
Hopefully someone here knows of something I could use for the NLP part for Carl v2 I am working on, currently. Thanks.
sorry for the repost but I thought I might be able to reach some more people
Later, JoeSox www.humanaiproject.org
"Dream as if you'll live forever; live as if you'll die tomorrow."
- James Dean(ISTP)
|
|
|
|