|
Look into the select() api call. You can detect a pending receive either blocking or unblocking in a loop based on the timeout value you specify.
|
|
|
|
|
Somebody can help me?
I need to declare a pointer to a class prior to defining the class.
I'm programming in Visual C++ 6, the code is something like this:
// header file A.h
class A : public CObject
{
....
}
// header file B.h
class __single_inheritance MyClass;
class B : public A
{
MyClass * m_pMyClass; // error C2027
.....
}
// header file C.h
class C : public Object
{
B * m_pBdata;
}
// header file MyClass.h
class MyClass : public C
{
.....
}
But, it doesn`t work, when I compile the code, Visual c++ give me the next error:
C2027: use of undefined type MyClass
Please, I need help,
Thanks a lot.
|
|
|
|
|
Just do a forward declaration:
class MyClass;
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
I didn't find anything necessarily wrong with your code except for the inclusion of a few missing .H files.
At the top of B.H, you need to include A.H, since class B is derived from class A.
At the top of MYCLASS.H, you need to include C.H, since class MyClass is derived from class C.
That's all I had to do to your code to clean up the compiler errors.
Make sense?
|
|
|
|
|
I have a Browser Helper dll that disables the context menu in IE and also several of the Accelerator and 'F' keys. I use a keyboard hook to trap for the keys and that includes F1 (Help).
The F1 trap doesn't work. The Windows Help comes up anyway. Is there a way to disable the help from coming up?
I guess I can look for the WM_HELP message, but have not done this type of thing in a dll before. Anyone have any suggestion please? Thank you very much.
AYousif
|
|
|
|
|
Try two things:
set the hook as a low level hook: WH_KEYBOARD_LL / LPKBDLLHOOKSTRUCT (find more in MSDN).
and if this don't work, then set it as a SYSTEMWIDE HOOK: hHookKeyboard = SetWindowsHookEx(WH_KEYBOARD_LL, HookKeyboardLL, hInst, NULL);
Hope this helps.
|
|
|
|
|
Hi Joan,
Well, I found the answer by chance and it was quite simple. I didn't realize a DISPID_... existed for this event. I updated my Invoke method to include:
<br />
case DISPID_HTMLELEMENTEVENTS_ONHELP:<br />
pvarResult->vt = VT_BOOL;<br />
pvarResult->boolVal = FALSE;<br />
break;<br />
This did the trick. BTW, I had tried the Low Level hook but it never got called. I'll keep the SYSTEMWIDE HOOK suggestion for future needs. Thanks.
AYousif
|
|
|
|
|
Is there any way to programmatically disable Visual Styles for an application so that it looks normal under XP like it would in previous versions of the OS?
|
|
|
|
|
What's the easiest way to read the width and height of a png file using C++ it’s the ONLY image type I'm going to read so massive image libraries are a waste of space in my program. Any ideas?
Cheers
RW
|
|
|
|
|
|
I'm having trouble getting understanding the header information. It doesnt seem very clear to me however regardless of that, how can i change my four bits stored in 4 indexes of an array into a recognisable number? I'm not much good with bit shifting
|
|
|
|
|
Do you have a code snippet of what you are trying to do?
|
|
|
|
|
Sure.
The basic idea here is that its going to create a button for a menu in directx. Its gotta find the size of the button image before it can create the panel to texture the png file onto [hence the panel and graphic are the same size] All I need for this is the width and height. DirectX can do the rest.
<br />
std::ifstream data_file;<br />
data_file.open("filename.png", std::ios::in | std::ios::binary);<br />
<br />
char signature[8];<br />
<br />
char width[4];<br />
char height[4];<br />
<br />
data_file.read(signature,8);
<br />
<br />
data_file.read(width,4);<br />
data_file.read(height,4);<br />
<br />
int texWidth = (int) ((width[0] << 32)+(width[1] << 16)+(width[2] << 8)+width[3]);<br />
data_file.close();
|
|
|
|
|
OK heres a better one since I just solved one problem and got another...
<br />
std::ifstream data_file;<br />
data_file.open("filename.png", std::ios::in | std::ios::binary);<br />
<br />
char signature[16];<br />
char width[4];<br />
char height[4];<br />
<br />
data_file.read(signature,16);<br />
<br />
data_file.read(width,4);<br />
data_file.read(height,4);<br />
<br />
int texWidth = 0;<br />
for(int i=0; i<4; ++i){<br />
texWidth <<= 8;<br />
texWidth += width[i];<br />
}<br />
<br />
<br />
data_file.close();<br />
Now it says the width of my image is -56!?
|
|
|
|
|
Real World wrote:
texWidth <<= 8;
texWidth += width[i];
Did you mean to use both of these or just one of them?
|
|
|
|
|
This should work:
// here's the bit-shifting stuff!
#define SH(p) ((unsigned short)(unsigned char)((p)[1]) | ((unsigned short)(unsigned char)((p)[0]) << 8))
#define LG(p) ((unsigned long)(SH((p)+2)) | ((unsigned long)(SH(p)) << 16))
void main( int argc, char *argv[] )
{
FILE *pFile;
unsigned char uBuffer[1024];
long lWidth,
lHeight,
lSize;
pFile = fopen(argv[1], "rb");
if (NULL != pFile)
{
fread(uBuffer, sizeof(unsigned char), 8, pFile);
fread(uBuffer, sizeof(unsigned char), 4, pFile);
// convert this to a long
lSize = (uBuffer[0] & 0xff);
lSize <<= 8;
lSize |= (uBuffer[1] & 0xff);
lSize <<= 8;
lSize |= (uBuffer[2] & 0xff);
lSize <<= 8;
lSize |= (uBuffer[3] & 0xff);
fread(uBuffer, sizeof(unsigned char), 4, pFile);
fread(uBuffer, sizeof(unsigned char), lSize, pFile);
lWidth = LG(uBuffer);
lHeight = LG(uBuffer + 4);
fclose(pFile);
}
}
|
|
|
|
|
Hi,
I'm having a frustrating little problem with 64-bit integer arithmetic. It goes something like this:
0xba5da800 * 0x38E
which should equal:
0x29678EB3000
Unfortunately, the code is a bit like this:
#define unsigned __int64 uint64_t<br />
<br />
unsigned long myval = 0xba5e3500;<br />
<br />
uint64_t myfunction(unsigned long val)<br />
{<br />
return val * 1000;<br />
}
This doesn't work, nor does:
return ((uint64_t)val * (uint64_t)1000);
or
return (uint64_t)((uint64_t)val * (uint64_t)1000);
The value I get returned looks like:
0xfffffeefffff0800 (or similar)
Now, I've run into problems before with not casting everything into __int64 twice (ok I exadurate slightly) for every calculation - but this is weird. It seems that casting val to uint64_t is turning it into:
0xffffffffba5e3500
Why is this happening?!
I truly do hate __int64, any help would be appreciated.
thanks,
Simon
--
Simon Steele
Programmers Notepad - http://www.pnotepad.org/
|
|
|
|
|
I get the desired results with:
typedef unsigned __int64 uint64_t;
unsigned long myval = 0xba5da800;
uint64_t myfunction(unsigned long val)
{
return (uint64_t) val * (uint64_t) 0x38e;
}
void myotherfunction()
{
TRACE("%I64u\n", myfunction(myval));
}
|
|
|
|
|
Check your tests?
The second two should work fine. The first one fails because the values are multiplied as longs and then returned as a uint64. The multiplication as a long wraps. Casting one value to a uint64 will make the multiplication occur on uint64's and should give correct results.
Your message mentions 0xba5da800 * 0x38E = 0x29678EB3000 at the top and your tests use 0xba5e3500 * 1000...
The code below seeems to give the results you expect.
typedef unsigned __int64 uint64_t;<br />
<br />
unsigned long myVal = 0xba5da800 ;<br />
<br />
uint64_t myfunction1(unsigned long val)<br />
{<br />
return val * 0x38E;<br />
}<br />
<br />
uint64_t myfunction2(unsigned long val)<br />
{<br />
return ((uint64_t)val * (uint64_t)0x38E);<br />
}<br />
<br />
uint64_t myfunction3(unsigned long val)<br />
{<br />
return (uint64_t)((uint64_t)val * (uint64_t)0x38E);<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
uint64_t result1 = myfunction1(myVal);<br />
uint64_t result2 = myfunction2(myVal);<br />
uint64_t result3 = myfunction3(myVal);<br />
<br />
printf("myfunction1 - 0x%I64x\n", result1);<br />
printf("myfunction2 - 0x%I64x\n", result2);<br />
printf("myfunction3 - 0x%I64x\n", result3);<br />
<br />
return 0;<br />
}
Len Holgate
www.jetbyte.com
The right code, right now.
|
|
|
|
|
Hi,
thanks for saying that it works for you, it led me to the problem. The value being passed in was actually a long not an unsigned long, I didn't notice because it's actually part of a structure the definition of which has changed.
"it does work, you fool!" posts are just as useful as solution advice so thanks to those who replied. I'll write a test harness next time before posting, my bad
thanks again,
simon.
--
Simon Steele
Programmers Notepad - http://www.pnotepad.org/
|
|
|
|
|
Hi everybody.I want programmaticly to change or set the 'Author' property for the newly created file.Any help will be appreciated.
|
|
|
|
|
Re: Changing file properties DavidCrow 15:30 7 May '03
Use the CFile::SetStatus() method, or use SetFileAttributes().
here you go, btw search forum before posting
Greetings
Jens
|
|
|
|
|
Unfortunately, those do not work with compound properties.
|
|
|
|
|
CFileStatus has not field Author.I think it is not suit for this case.But thank you anyway.
|
|
|
|
|
While it's not exactly what you are after, see if MSDN article Q186898 is of any help.
|
|
|
|