|
Hi Ganesh_T ,
Can you be more specific ( I press "Esc" all the coontrol opn child dialog also dissappears)
And first question (increase the size of coloumn i list control the borders dissappear)
(I think or I suggestion) that you can derived CListCtrl in your program)
|
|
|
|
|
Suppose we have the Dialog as parent and two dialog as child. On click of button which is placed on parent dialog I am displaying first child dialog.
Now when the focus is on the main Dialog means parent dialog I press "Escape" button the controls which are placed on the dialog box dissappears.
I am not able to find out the problem. Well itried doing different things and setting the properties then also it doesn/t worked.
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Hi Ganesh_T ,
Hope I understood your question
I had problem that I created child dialog in main program when I press "Esc" dialog closed
but my controls fix, but this problem that controls are dissappears, I think that usually focus is in window unless you use setfocus
why cthe controls are dissappears?
I use this way
I declare one CDialog and use a variable of cMyDialog in main program
and in child dialog I had controls(button,editbox,...) when I press Esc in child dialog
this disappear but controls not change (I suggestion you check OnCancel)
|
|
|
|
|
Dear Gurus,
I have a question concerning accessing bits from an array of unsigned char .
Considering a series of bytes read from an already coded file that I can't modify because it is coded "like that", I need to exctract the bits of the array in the following way:
consider the values in the file:
0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55
the vector (1D array) of unsigned char contents is the same of the file:
0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55
so, here we have 10 unigned char which is the way it is coded in the file.
Now, in the real visual world, it is in fact a 2D array. in our example, it should be an array of 2 lines and 20 columns! each unsinged char represent 4 cell of the real array these values are sets of 2 bits.
So, in our example, we should have the simple array after accessing the file:
L1: 11111111111111111111
L2: 11111111111111111111
if you take the file value as packet of bits you have:
L1: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
L2: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
Now, group these vallues by packets of nibbles:
L1: 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101
L2: 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101
if you convet these values in hexa by nibbles; you have:
L1: 5 5 5 5 5 5 5 5 5 5
L2: 5 5 5 5 5 5 5 5 5 5
And finally if you group these nibbles by bytes you have the array:
L1: 55 55 55 55 55
L2: 55 55 55 55 55
In the file it is coded the way I told just above:
55 55 55 55 55 55 55 55 55 55
So, if you followed, my question is the following:
given the array read from the file (values just above), how can I access to the set of 2 bits???
the function's header looks like this:
int GetAt(unsigned char* compressedArray, int i, int j);
and it should return the cell content.
How to do such a function that read the compressed values????
I hope you understood my problem.
If so, can someone give me a hand shot please?
Best regards.
Fred.
There is no spoon.
-- modified at 3:45 Saturday 25th March, 2006
|
|
|
|
|
I had to read what you had written several times. I gather that you have sets of data which is 2 bits in length (ie. of values 0 to 3)
The following code will get the value of the 2 bits at index i. I don't know what you mean by this being a 2D array. You would probably want to check that nArrayPos doesn't go over the bounds of the compressedArray.
<br />
unsigned char GetAt(unsigned char *compressedArray, int i)<br />
{<br />
int nArrayPos = i / 4;<br />
int nBytePos = (3 - (i % 4)) * 2;<br />
return (compressedArray[nArrayPos] >> nBytePos) & 0x03;<br />
}<br />
If you want to check which bit is set for the result you could always do something like
<br />
if((result & 0x02) == 0x02)
if((result & 0x01) == 0x01)
|
|
|
|
|
Actually, my problem is to decode a collision map wich is "compressed" for an old school 2D game.
It's like I had explained above (values are stored as set of 2 bits) and the values are stored as short in the file, so the values are inverted because of little endian.
For example:
the following line in the map would look like this (here, the width is 20 columns):
1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1
In the file, it is coded this way:
0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0
the "1" means there is a wall, "0" means no wall.
the values are inverted. so I need to reverse them to get the correct decoding.
It drives me crazy
How to do that?
Fred.
There is no spoon.
|
|
|
|
|
It looks like you may have either misrepresented your problem or I have misunderstood. You said that values are stored as a set of 2 bits (which can have 4 values from 0 to 3).. but it looks like it is just 1 bit (with a value of either 0 or 1)?
When doing bitwise operations though, always think of operating on the big-endian representation.
Since Windows is little endian... you can modify the function accordingly. While the values are held as little-endian, the bitwise operations are conceptually done in big-endian so you don't have to logically flip it yourself.
<br />
unsigned char GetAt(unsigned short *compressedArray, int i)<br />
{<br />
int nArrayPos = i / 16;<br />
int nBytePos = (15 - (i % 16));<br />
return (compressedArray[nArrayPos] >> nBytePos) & 0x01;<br />
}<br />
edit: 1 0 0 0 is a short? does that mean it is using 4 bits to represent 1 value of either 0 or 1? Actually that snippet seems to make no sense since ordering is per byte.. so I don't know how 1 0 0 0 gets represented into 0 0 0 1.
-- modified at 12:01 Saturday 25th March, 2006
|
|
|
|
|
Hi,
I was wrong by talking about short sorry.
by 1 0 0 0 I was meaning 01 00 00 00 = 8 bits = 1 byte.
The values are stored as set of 2 bits (values are between 0 - 3), but the sets are inverted in the file.
The values meaning are the following:
00 : nothing
01 : wall
10 : ladder
11 : tree
So, for example, when in the file there is the byte value:
0x68 : 01 10 10 00
the real values should be interpreted as:
0x29 : 00 10 10 01
1 byte means 4 cells of the array.
The series of 2 bits are inverted.
See what I mean?
So, the compressed array's size is (MapWidth/2)x(MapHeight/2).
for example if you have a tiny 4x8 map like this: (t1)
1 1 1 1 1 1 1 1
1 0 2 2 0 0 0 1
1 0 2 2 0 0 0 1
1 1 1 1 1 1 1 1
In the collision map coded like this in memory: (t2)
01 01 01 01 01 01 01 01
01 00 10 10 00 00 00 01
01 00 10 10 00 00 00 01
01 01 01 01 01 01 01 01
and in the file it is like this: (t3)
01 01 01 01 01 01 01 01
10 10 00 01 01 00 00 00
10 10 00 01 01 00 00 00
01 01 01 01 01 01 01 01
in hexa as bytes it looks like this:
0x55 0x55
0xa1 0x40
0xa1 0x40
0x55 0x55
the size of the compressed array is 2x4 like I wrote above (MapWidth/2)x(MapHeight/2)
In the unsigned char* it is coded like this (in the file)
0x55 0x55 0xa1 0x40 0xa1 0x40 0x55 0x55
so, in our example, GetAt(compressedArray, 3, 1) should returns 2 (0x10 - column 3, line 1 from t2)
while it is read from the compressedArray...
I hope it is clearer with a concrete example.
I'm sure there is a way to decode it on the fly without storing the decompressed array.
Thanks for the help
Best regards.
Fred.
There is no spoon.
-- modified at 12:20 Saturday 25th March, 2006
|
|
|
|
|
Just a tweak to the function should get it to work.
You can just do GetAt(compressedArray, x + y * MapWidth) to get the cell you are interested in.
<br />
unsigned char GetAt(unsigned char *compressedArray, int i)<br />
{<br />
int nArrayPos = i / 4;<br />
int nBytePos = (i % 4) * 2;<br />
return (compressedArray[nArrayPos] >> nBytePos) & 0x03;<br />
}<br />
Don't get what you mean by decode on the fly, isn't this decoding on the fly?
|
|
|
|
|
it always return 1
There is no spoon.
|
|
|
|
|
ok got it!!!
It works!!!
many thanks
Fred.
There is no spoon.
|
|
|
|
|
Hello hfry,
Do you remember me and my problem about bits?
You gave me the function that reads the values and it works perfectly. Now, I need the reciproque function: I need to write values...
I remind you the function for reading the data you kindly gave me:
int GetCollisionValue(unsigned char* collisionsMap, int x, int y, int nWidth)
{
int i=x+y*nWidth;
int nArrayPos = i / 4;
int nBytePos = (i % 4) * 2;
int value=(collisionsMap[nArrayPos] >> nBytePos) & 0x03;
return value;
}
Now, I need the "SetAt" function...
void SetAt(unsigned char* collisionsMap, int x, int y, int nWidth, int nValue);
Can you help me again please???
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
how to code for finding some related info based on keywords like "id", "name" etc
|
|
|
|
|
what's your question exactly ?
i doubt anybody can understand you.
please also indicate which data types you're handling...
sincerely,
|
|
|
|
|
lets say i have a program, its a reservation system. i have a db connected to it, and when click a button "Find", it will find related info based on keywords provided like "ReserveNo", "Name", etc.
im not very good at telling wat i want, cause im very new with this... sry
|
|
|
|
|
well, what you want seems to be some SQL queries...
|
|
|
|
|
I would like to distribute a font file with my app. The font I have is a little too large for my liking, 3.6mb. Using winrar I am able to compress it down to 1.2mb which is a little more realistic.
Obviously There is a chance that winrar will not be installed on the target machine so I need some sort of runtime decrompression algorithm. The idea is, I compress the file and add it to the resources/installer then simply deflate it onto the target machine.
I know of zlib, but I have never used it. Could anybody recomend a good algorithm, with not much overhead, will not increae the exe size too much, and fairly easy to implement? This is not an MFC project
|
|
|
|
|
|
This for the links, I will into them
|
|
|
|
|
|
I am using Visual c++ 6.0.
Where can I found a class that make DateTimePicker Flat like i found for ComboBox
Urgent
I learn my self
|
|
|
|
|
No Body can reply me at this forum !
|
|
|
|
|
Hi,
I've an application which creates HTML files. For that i'm using some database operations, which includes classes such as, CDatabase and CRecordSet etc.
I'm getting an exception as "invalid cursor" since m_strCursor is getting set to some file name e.g. "test.html", which the application is creating. I'm not able to trace out, how the variable is getting set. Similarly, m_strFilter, m_strSort, m_strUpdateSQL, m_strRequeryFilter, m_strRequerySort are getting set to the same file name.
Thanks,
Kranti
|
|
|
|
|
|