|
sorry, typo error. My meaning is the program don't execute when i click on the execute icon. No dialog was generated although no compilation error. Did i miss in writing any function or messages?
|
|
|
|
|
You need to debug the program. Put a breakpoint at the beginning of the InitInstance. There is probably a problem with the dialog.
Or before using the breakpoint, just execute the program using the debugger and then look at the debug messages after the program finishes. There probably is a message indicating a problem.
|
|
|
|
|
|
Nope, no error in compilation. Only problem is the dialog can't even be generated when i click on execute icon("!").
|
|
|
|
|
Can you show your code that has this problem
|
|
|
|
|
Can you show code ?
By any chance you are using rich edit control, on your dialog ?
|
|
|
|
|
Ok what is the most efficient way in c++ to set the bit of data A to the bit of data B. Ex:
a.7 = b.6;
right away i realized i have to check up to four conditions, and this is what i got:
if( b & ( 1 << 6 ) > 0 && a & ( 1 << 7 ) == 0 ) a |= ( 1 << 7 );
if( b & ( 1 << 6 ) == 0 && a & ( 1 << 7 ) > 0 ) a -= 128; // i.e. a = 1xxxxxxx - 10000000
any1 knows a better way?
|
|
|
|
|
bool bBitSet = (B & 64) != 0;
A &= ~128;
A |= bBitSet ? 128 : 0;
|
|
|
|
|
nice. I also came up another with way:
if( b > 63 ) a |= 128 else a &= ~128;
|
|
|
|
|
|
dammit, your right. I guess with my code i could do it this way:
if( b & ( 1 << 6 ) > 0 ) a |= 128 else a &= ~128;
Also, is the > 0 part necessary, or does extracting the bit result to 1 or zero?
I am at work right now, thatz why i asking.
|
|
|
|
|
Just test (b & 64) to tell if that bit is 1
|
|
|
|
|
I'm trying to write a fuction which will accept a reference to a structure. I figured I'd start by just passing a structure to a function, then move on to the refrence. However, I can't figure the syntax.
In Ladder.h- I declare a function and set up a structure
void WalkLadderUpDown(struct PriceLadder TransPL);<br />
<br />
typedef struct <br />
{<br />
double one;<br />
double two;<br />
double three; <br />
} PriceLadder;<br />
<br />
PriceLadder TransPL;
In Ladder.cpp- I define the function to receive an instance of PriceLadder
void Ladder::WalkLadderUpDown(struct PriceLadder TransPL)<br />
{<br />
TransPL.one = 1;<br />
TransPL.two = 2;<br />
TransPL.three = 3;<br />
}
The compiller sys the function is overloaded. Any ideas on how to code this?
|
|
|
|
|
You don't need "struct" in the type -
typedef struct
{
double one;
double two;
double three;
} PriceLadder;
void WalkLadderUpDown(PriceLadder TransPL);
PriceLadder TransPL;
void Ladder::WalkLadderUpDown(PriceLadder TransPL)
{
TransPL.one = 1;
TransPL.two = 2;
TransPL.three = 3;
}
|
|
|
|
|
Oliver123 wrote: In Ladder.h- I declare a function and set up a structure
void WalkLadderUpDown(struct PriceLadder TransPL);
Are you sure that is in your definition of the Ladder class?
Are you getting other errors? I suspect that if you have other errors and fix them, then this one that you are asking about will go away.
|
|
|
|
|
Everything works Ok if all structures and functions are confined to one class.
The problem arises when I put the function into class-B and call it from class-A. I can call any other class-B function from class-A. And I can use references to int and doubles in passing params to a class-B function from class-A. But when I try to pass a structure as either a stand alone or a reference the compiler says it can't convert the class-A structure to a class-B structure.
The same structure is defined in both class-A and class-B. ???
|
|
|
|
|
Hi,
I think my subject says most of it. I am a little stuck with this problem. What must I do if I want e.g. send a few normal chars and then an Integer ? I think I must somehow pack it all into a byte array. But how ? Hope someone can help me. Thanks
|
|
|
|
|
something like this?
BYTE bytes[100];
int anInt = 10, anotherInt = 50;
char *str = "Hi there";
BYTE *pPos = bytes;
memcpy(pPos, anInt, sizeof(int));
pPos += sizeof(int);
strcpy(pPos, str, strlen(str));
pPos += strlen(str);
memcpy(pPos, anotherInt, sizeof(int));
pPos += sizeof(int);
|
|
|
|
|
copying an integer value inside a byte array (an array of unsigned char, I suppose) is simple, for instance:
int i=5;
unsigned char buff[0x100];
memcpy((void*)buff, (void *)&i, sizeof(i));
but you must be aware that INTEL processors have little-endian byte order, while TCP/IP network has big-endian one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
thanks that helped me. I already thought that it's something like memcpy. But there's my next question. How can I get then from this byte array the original values back ?
Btw when I send data with TCP/IP, do I have to send it was unicode (TCHAR) or normal (unsigned char) ?
|
|
|
|
|
FreeCastle wrote: I get then from this byte array the original values back
if you, at the opposite side of the TCP line, don't know what is the nature of the data contained inside the byte array then you are lost. So maybe you have to preceede each chunk of data with, say, a marker section (maybe few bytes) that state:
(1) the type of the following items
(2) the lenght of the following items
Hey, you're establishing a protocol!
FreeCastle wrote: Btw when I send data with TCP/IP, do I have to send it was unicode (TCHAR) or normal (unsigned char) ?
When you are sending bulk data maybe BYTES (hence unsigned char) are more appropriate.
hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hey thanks a lot again. And you're right, I am writing in fact a little protocol
|
|
|
|
|
Hello,
I am working with an on-screen keyboard that was designed from scratch using the Win32 API, and it designed to be used with 4 or 5 languages. The keyboard works absolutely perfectly except when attempting to display some of the special characters for the other forgein languages(characters above 0x7F on the ASCII table). When I attempt to print these characters using the WM_CHAR message, the following character ÿ always appears before it.
For example:
If I were to press the "A" key, the edit box above the keyboard display "A". However, if I press the "Ö" button on the onscreen keyboard, the edit box about the keyboard displays "ÿÖ". I am totally stumped and was hoping anyone could provide any insight into why this is happening.
Thanks in advance,
Joe
|
|
|
|
|
Post some relevant code, both where you send the WM_CHAR message and where you are recieving it. Are you doing UNICODE builds?
ÿ is ascii 0xff, that should tell you something, but without seeing the code I can not tell you what.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I will try to post some code tomorrow, however, the keyboard procedure is pretty large, so I will try to post some relevent pieces.
|
|
|
|