|
|
csc wrote:
I think there are a lot of complete classes here at codeguru.
Codeguru? Don't you mean CodeProject?
|
|
|
|
|
Hi
Anyone can tell me how to lock CD-rom drive
Give some code as eg.
GO ON KIDDING
|
|
|
|
|
In MSDN,KB138434,there's some code to demo this.
|
|
|
|
|
Who can tell me how to change the height of CComBox.
the function CComboBox::Create(..rect.) only modify the size when the
control is dropped down.
gucy
|
|
|
|
|
|
Dave:
First thands a lot,SetItemHeight works very well.
But another question is that how can i change the font size of the ccombobox,i created the control in source file instead of in source view control.i put the control on the toolbar instead of on dialog box.
Can you help me further?
gucy
|
|
|
|
|
Something like:
CFont* pOldFont = m_combo.GetFont();
LOGFONT lf;
memset( &lf, 0, sizeof(LOGFONT) );
pOldFont->GetLogFont( &lf );
CClientDC dc( m_combo );
lf.lfHeight = -MulDiv( PointSize, dc.GetDeviceCaps( LOGPIXELSY ), 72 );
CFont* pNewFont = new CFont();
pNewFont->CreateFontIndirect( &lf );
m_combo->SetFont( pNewFont );
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Is it Ok (good practice) to include headers within other header files ?
I have a CTimer Class declared in TimerClass.h and implemented within TimerClass.cpp.
I have a CAnimatedSprite class declared in AnimatedSprite.h and implemented within AnimatedSprite.cpp.
Is it alright for the AnimatedSprite.h to #include "TimerClass.h" and for the AnimatedSprite.h to have as a class member CTimer AnimationTimer; ?
Is there a requirement for the CTimer to be a friend of CAnimatedSprite ?
Responses much appreciated,
Wodger
|
|
|
|
|
There is no problem having includes within includes, and they really should be there if the file won't compile without them.
You do not need to make CTimer a friend of CAnimatedSprite just to make it a member variable. You only need a friend class when it needs to access protected/private members of another class.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
You should always minimize inclusion of headers in other headers, especially on larger projects as you get unnecessary compiles on the slightest change. Read "Large Scale C++ Design" (I think that is the title) for a very informative and in depth discussion of the many problems here.
Try not to make CTimer a member, but instead use CTimer* then you can forward declare CTimer (eg. class CTimer;) and hide its implimentation from the AnimatedSprite.h file. ie. It only needs to be visible in AnimatedSprite.cpp Read about PIMPL and look at Boost Smart Pointers www.boost.org[^]
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Cheers, Thanks and Superb to both of you.
I'm not quite sure what you mean wrt CTimer* (Newbie Alert)
// AnimatedSpriteClass.h
// Doesn't the statement
CTimer* pSpriteTimer;
// require the TimerClass header to create a pointer to one ?
// No: because it is not initialised ?
// AnimatedSpriteClass.cpp
// Then when I define the InitSprite(int x, int y, int CurrentAnimSequence);
// do I initialize the Ctimer pointer to an instance of the CTimer ?
pSpriteTimer = new CTimer;
// will that do the trick ?
// Cheers,
// Wodger
|
|
|
|
|
Anonymous wrote:
Cheers, Thanks and Superb to both of you.
It is a pleasant change to get a thankyou - thanks for that.
Anonymous wrote:
CTimer* pSpriteTimer;
No is correct. You would include:
class CTimer;
in the .h before the class definition. You need to ensure that you don't define any functions in this .h that call CTimer functions, otherwise you are back to needing CTimer.h In other words write this functions in the .cpp. If you need inline functions for speed then put them in a .inl.
Anonymous wrote:
pSpriteTimer = new CTimer;
Yes. But I'd suggest doing this in the AnimatedSpriteClass constructor and the delete pSpriteTimer; in the destructor. Better still using either an STL auto_ptr or Boost scoped_ptr. eg. In the .h
boost::scoped_ptr<CTimer> pSpriteTimer;
and in the constructor:
pSpriteTimer.reset( new CTimer );
Then you don't need to delete pSpriteTimer and can rest assured that it will be cleaned up if an exception occures etc.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi,
I'm learning C++ and have the MS Developer Studio C++ V4.2 installed.
Can anybody tell me how to define a project with the demo files I downloaded from this site to produce an executable program? What are the settings/options when I create a project workspace? How to incorporate the downloaded files?
Thanks in advance,
Ulrich
|
|
|
|
|
Have you tried double-clicking on the .dsp file (the project file), which should open devstudio.
It should also ask you if you want to create a workspace for the project.
|
|
|
|
|
double-clicking on the .dsp file opens devstudio and opens the .dsp file in the editor, that's all
|
|
|
|
|
Vc++ is being used for automating winword report generation using ole automation. The reports are based on predefined templates. How can we convert the same report to other languages using ole automation in vc++. Ex: English reports to French.
Thanks in advance.
|
|
|
|
|
Hi, is there anyway to prevent the ALT F4? so my window can't be shutdown like that?
If not, is there anyway to "hide" my window from the list of windows which pops op when won presses ALT-TAB.
Thanks for any help.
|
|
|
|
|
Intercept the WM_CLOSE message and return false. If you are using MFC, goto classwizard and add WM_CLOSE message handler to that particular window and remove the CDialog::OnClose() statement.
Harsha
----------------------------------
http://www.ece.arizona.edu/~hpg
----------------------------------
|
|
|
|
|
That's right, Make more programs that require a hard reset to get out of.
MS finally makes a reasonably stable OS (XP) and then you go and disable essential escape funtionality. Try disabling Alt-Tab and Ctrl-Alt-Del as well (I don't think you will, but would be a good challenge)
Alt F4 is there for a reason!
Head retracted now (I'm sure you have a legit reason for doing this)!
|
|
|
|
|
Anonymous wrote:
I'm sure you have a legit reason for doing this
There are plenty of reasons. I wrote a little app a while ago for a church for controlling a LCD projector (turning it on/off etc.). It was an appbar that ran at startup and was permanently set at the top of the screen, and they didn't want people to be able to close it, because then they couldn't control the projector. So I had to do this. I did it in a slightly different way, though.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
If you must let people interact with your app, then you should think about setting a system wide keyboard hook in order to avoid all the "strange" keypresses (Ctrl + shift + esc...) and also to implement a gina dll in order to avoid Ctrl+alt+del... you can say then that you control the PC and that you can be sure that people won't touch things that shouldn't...
hope this helps.
|
|
|
|
|
Joan Murt wrote:
hope this helps.
I never asked a question!
All I had to do was prevent one app from being closed. Task Manager was disabled by system policies, so all I had to do was prevent Alt+F4 and Escape (it was a dialog app). Setting a system-wide keyboard hook would have been massive overkill.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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 was under the impression (according to my programming book) that a left shift on a byte caused the bits on the left to "fall off" and zeros inserted to the right:
eg. 0x1F << 2 = 0xC0
but it equals 0x7C0
Why is this?
My reason for asking this question is that I am trying to find a four byte sequence within a file (MPEG-1) that doesn't seem to byte aligned. I wrote a little function to do a "bit by bit" search but since the above statement is not true it fails, here is my code (I feed it 64 bits at a time):
int FindSequenceHeader(unsigned char *str)
{
char ch[4];
DWORD dwValue;
for (int x = 0; x < 4; x++)
{
for (int i = 0; i < 8; i++)
{
ch[0] = ( (str[x + 0] << (0 + i)) | (str[x + 1] >> (8 - i)) );
ch[1] = ( (str[x + 1] << (0 + i)) | (str[x + 2] >> (8 - i)) );
ch[2] = ( (str[x + 2] << (0 + i)) | (str[x + 3] >> (8 - i)) );
ch[3] = ( (str[x + 3] << (0 + i)) | (str[x + 4] >> (8 - i)) );
dwValue = ( ch[0] | (ch[1] << 8) | (ch[2] << 16) | (ch[3] << 24) );
switch (dwValue)
{
case 0x000001b3:
cout << "Video Sequence Header Found" << endl;
return 0;
break;
default:
break;
}
}
}
return 1;
}
which then leads me to ask why this standard routine i've seen in many sample codes works:
DWORD MakeDword(unsigned char *str)
{
return ( str[0] | (str[1] << 8) | (str[2] << 16) | (str[3] << 24) );
}
any thoughts?
|
|
|
|
|
georgiek50 wrote:
eg. 0x1F << 2 = 0xC0
but it equals 0x7C0
georgiek50 wrote:
Why is this?
Because it is the right answer.
0x1F = 0001 1111
shift it left a coupla times and put zeros in on the right
0111 1100 = 0x7C
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = A
1011 = B
1100 = C
1101 = D
1110 = E
1111 = F
cheers!!
Adam.
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|