|
I want to convert int, long values to byte arrays, and from byte arrays back to int, long. I can do it with In .NET BitConverter class, but I want to do it in C++. any help greatly appreciated..
happy coding
|
|
|
|
|
Not sure if this is what you want:
char b[sizeof(int)];
int i=*reinterpret_cast<int *>(&b);
...
int i=...;
char b[4];
mempcy(b,&i,sizeof(int));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi
I have a dialog which fits perfectly in a regular 17inch screen.
But with my friend, who has a 15inch screen, the dialog is too large to display.
How can i make sure the dialog got scrollbars on the 15inch screen, and not when the program is run with the 17inch screen?
Greetings
Bart
|
|
|
|
|
don't
Change your layout to fit the smaller screen size, using Tabs, and/or secondary dialogs.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Oh, i've thought about that too
but that isn't possible.
|
|
|
|
|
Friends,
Please tell me that how can i change the background color of my dialog box at runtime.
Thanks.
|
|
|
|
|
Thanks for reply..one more question
How can i force repaint after applying your solution. For example on pressing the OK button of dialog box i call the following code:
AgxGetApp()->SetDialogBkColor( COLORREF clrCtlBk = RGB(192, 192, 192), COLORREF clrCtlText = RGB(0, 0, 0) );
But the problem is that the dialog is not repainted at that moment. Its only when i bring some other window on top of dialog, the dialog gets repainted with new background color. I also tried PostMessage(WM_PAINT) after the above line of code, but it is also not applying color ?
|
|
|
|
|
I want to list all sub-keys under a key. In my test I have two sub-keys. I open my key with ::RegOpenKeyEx() and then I put zero into first call for ::RegEnumKeyEx() . I call it again until it does not return ERROR_SUCCESS . This is my code:
HKEY hKey;
CHAR achKey[MAX_KEY_LENGTH];
DWORD i = 0;
if (::RegOpenKeyEx(HKEY_CURRENT_USER, REG_MAJOR_KEY, 0,
KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
{
while (::RegEnumKeyEx(hKey, i++, achKey, &cbName, NULL, NULL, NULL,
&ftLastWriteTime)) == ERROR_SUCCESS)
print("Found %s", achKey);
RegCloseKey(hKey);
}
The problem is it finds one key but not the other. Can anyone tell me where I am wrong please? Thank you.
|
|
|
|
|
Shouldn't you be checking against ERROR_NO_MORE_ITEMS instead?
while (::RegEnumKeyEx(hKey, i++, achKey, &cbName, NULL, NULL, NULL, &ftLastWriteTime) == ERROR_NO_MORE_ITEMS)
...
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
Hello,
MFC CString has the += operator.. When dealing with char's how can one achieve the same thing?
I need to keep adding the contents of one char to the other while in a loop.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Use strcat() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks David!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
One more question.. You answered my question correctly but I just realized that I was asking the wrong question.. Given the following code, can you give me any hints on how I can accomplish what I'm trying to do?
s_recv sRecv;
int nRecvSize = 0;
char outBuff[sizeof(s_recv)];
while(nRecvSize < sizeof(s_recv))
{
char inBuff[sizeof(s_recv)];
int nRecv = recv((SOCKET)wParam, inBuff, sizeof(inBuff), 0);
TRACE("Received %d of %d\n", nRecv, sizeof(s_recv));
if(nRecv == SOCKET_ERROR)
{
TRACE("MainFrm Recv Error %d\n", WSAGetLastError());
break;
}
else
{
if(nRecv == 0)
break;
strcat(outBuff, inBuff);
nRecvSize = nRecvSize + nRecv;
}
}
memcpy(&sRecv, outBuff, sizeof(outBuff));
Thanks for all the help...
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote:
...can you give me any hints on how I can accomplish what I'm trying to do?
Assuming I knew what it is that you wanted to accomplish.
RobJones wrote:
strcat(outBuff, inBuff); // This doesn't work how I want it to..
So what is it doing instead?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The structure is like this...
struct s_recv {
int nTag;
char sTagMsg[256];
char sMsg[3072];
};
When I do the receive sometimes I dont receive the whole structure just a peice of it.. So I'm trying to store what I have received in a char and then keep appending the data until all the data is received..
Here is a output of the strcpy...
The inBuff contains..
[0] -75 'µ'
[1] 6 ''
[2] 0 ''
[3] 0 ''
[4] 110 'n'
[5] 111 'o'
[6] 110 'n'
[7] 101 'e'
[8] 0 ''
[9] -51 'Í'
etc.......
This is fine.. But when I do the cat..
the outBuff looks like this...
[0] -75 'µ'
[1] 6 ''
[2] 0 ''
[3] 0 ''
[4] 0 ''
[5] 0 ''
[6] 0 ''
[7] 0 ''
[8] 0 ''
[9] 0 ''
etc......
I think I need some way of doing a memcpy that appends instead of strcat...
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote:
I think I need some way of doing a memcpy that appends instead of strcat...
You are correct. This is because the data you are receiving may have embedded '\0' characters, of which strcat() uses and memcpy() does not.
Try something like:
int nOffset = 0;
...
memcpy(outBuff + nOffset, inBuff, nRecv);
nOffset += nRecv;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
YOUR THE MAN!
Thanks for all your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I was passing through revolving door the other day, and i stopped half the way and hold the door real tight so it stopped revolving. the door slammed onto the face of guy behind me who was passing through the door too.
nothing is impossible..
|
|
|
|
|
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Have you ever looked at the PCL output from Word? You don't see complete words all the time. You see the PCL doing adjustments in the Horz direction with certain characters. Why is it doing that? Could it be that it is adjusting the Horz position due to the printer? Could it be that it is doing it because of the font? How is it deciding when to do the adjustment?
Fonts are driving me nuts! When I use the CRichEditCtrl’s FormatRange, it puts out a single string. I create a text box in Word, put the same text in and I notice that it breaks it up. Now I’m wondering why?
[EDIT]
AND, it doesn't look the same! The printed lenght (in inches) are not the same but have the same characters exactly! WHY? <- Pulling hair out!
[END EDIT]
I really do need some insight in outputting fonts to the printer. Something is going on that I’m in the dark about and I need some help big time!
Thanks to any who respond.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
It might well be that the PCL spit out by Word reflects the way that they are adjusting intercharacter spacing to improve kerning in a word, and in some cases for things like text justification, this is practically mandatory. If you want to know much much more about fonts, printing, and the rest of the GDI stuff, get yourself a copy of the Feng Yuan GDI book. It's worth every penny(or other currency of your choice).
I contracted at Serif once upon a while, and we used info like the ABC tables from fonts to alter output, and it really does make a difference.
Steve S
|
|
|
|
|
Thanks Steve,
(Quick response too! ) I currently have Fengs book and have tried some of examples in the code that I'm doing. I adjusts it too much the other way! Trying to make a WYSIWYG application is not the easiest thing at all.
You by chance don't have any examples that I can sneak a peak at do you?
Larry
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Not without enraging at least half a dozen lawyers!
You need to check his web site for errata (I think there's one in there from me!), and be aware of using reference (or em square?) fonts to derive size information. Generally, his stuff is fine for all but the pickiest of users, although I have had to do some work on things like breaking strings into paragraphs, lines, and words for formatting purposes.
More recently I've worked with FormatRange, having needed RTF editing capabilities for WP like behaviour, and that was an education in itself!
Steve S
|
|
|
|
|
Quote
Not without enraging at least half a dozen lawyers!
Well, we wouldn't want that now would we? I will have to see if I have the URL to his web site. Also, you don't have any test programs when you were learning hanging around do you? Those would do.
Also, I'm using his "Text.exe" example where you can insert the font and point size to get information about that font. I used the equaion to convert the point size into the logical:
Logical = ( point * LOGPIXELSY ) / 72
and found out about the size to enter. Using this information, I'm seeing what happens. The first section adds up correctly. The next character is on smaller, have not done the rest yet...
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|