|
ppatel567 wrote: I sometimes noticed that in the header file its only written asanyheader.h=======class CMyApp;class CMySpec;
thats we call forward decalaration of class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
This kind of declaration is used to help the compiler to understand what string used into the code are sintax errors or objects that are somewhere defined.
I'll try to find a way to explain this to you with two examples,... and remember that the compiler will read the code in the same way of you, i.e. from top to bottom:
First case: the error!
class classA{<br />
classB b;
}<br />
class classB{
...<br />
}
Second case: OK
class classB;
class classA{<br />
classB b;
}<br />
<br />
class classB{<br />
...<br />
}
Hope be clear
|
|
|
|
|
Sir,
I want to display ikon in only 2 columns in a grid control. can u help me in this issue.
Regards JOhn
-- modified at 0:50 Wednesday 17th May, 2006
|
|
|
|
|
are u askin this question in reference to the programmin or windows appearance.
|
|
|
|
|
In my application, I dynamically set the parent of my custom child control to Desktop Window. Now I don't get the keyboard messages in PreTranslateMessage of my control, because the keyboard focus is still in the main application...
BOOL CMyCtrl::PreTranslateMessage( MSG* pMsg_i )
{
if(( pMsg_i->message >= WM_KEYFIRST ) && ( pMsg_i->message <= WM_KEYLAST ))
{
ProcessKeyStroke();
}
return CWnd::PreTranslateMessage( pMsg_i );
}
I cannot change the focus from application to the control because it's a must. Is there anyway to watch the key strokes in this condition?
( Please don't tell me about hook )
Thank you.
- NS -
|
|
|
|
|
Did you try sending a copy of the message to the control from your dialog or frame which houses the control (SendMessage , PostMessage ).
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
I think that is a last resort... !
As this control is supposed to be a common, I need to avoid such dependencies.
- NS -
|
|
|
|
|
NS17 wrote: I think that is a last resort... !
As this control is supposed to be a common, I need to avoid such dependencies.
Well that is how keyboard messages are set to function. If a control is to receive input from keyboard it should have the Input Focus. This the rule. You cannot break that.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
mmm....
So now I am planning to expose a function to allow the app to call in its PreTranslateMessage, like the RelayEvent() of ToolTip Ctrl. What's your opinion?
- NS -
|
|
|
|
|
NS17 wrote: So now I am planning to expose a function to allow the app to call in its PreTranslateMessage, like the RelayEvent() of ToolTip Ctrl. What's your opinion?
Well if you want such functionality that's an option. You can also take look at the FORWARD_WM_********* group of macros which could also help you.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Ok, thank you... Let me try
- NS -
|
|
|
|
|
Hey guys,
I would like to know what happends with memory in this code,
CArray<int,int> myArray;
//my array could be 0 or can grow upto 1000
myArray.SetSize(0,1000);
for (int j = 0; j < 900; j++)
{
myArray.Add(j);
}
//what is below line going to do?
myArray.FreeExtra();
Is SetSize & FreeExtra functions anyway improves anything here or it would be better of without these lines.
Thanks
Mohan
|
|
|
|
|
|
CArray<CPoint,CPoint> myArray;<br />
int i;<br />
<br />
myArray.SetSize(32, 128);<br />
<br />
CPoint* pPt = (CPoint*) myArray.GetData();<br />
for (i=0;i < 32;i++,pPt++)<br />
*pPt = CPoint(i, 2*i);<br />
<br />
<br />
myArray.SetSize(5, 128);<br />
myArray.FreeExtra();
Look at the above code .
Hope now u can understand the use of FreeExtra.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
HI Mohan,
function FreeExtra():
Frees any extra memory that was allocated while the array was grown. This function has no effect on the size or upper bound of the array
function SetSize():
Use this function to set the size of your array before you begin using the array. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory
...referenced from MSDN oct 2001
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
With SetSize your code runs faster - memory for 1000 items is allocated and not copied\extended during adding new items. Without it array will allocate new memory several times, copying all items to new location.
FreeExtra just free unused memory - but it have to copy whole array to new location, which cost time. So I almost never use it - if you will want to add new item afterwards, you will cause array to copy items again.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Igor,
I kinda got a clue, thanks. But i got a question...
I load the array only once when my application loads & then i just use it for reference purpose only, in this case if i include SetSize(0,1000) & the array loads only 500 items, will that mean the memory for other 500 still exists & not released?
Thanks.
Mohan
|
|
|
|
|
|
can anyone teach me how to get string input and display it in the blackbox?
fe8her
|
|
|
|
|
Prinz Ryoiji wrote: it in the blackbox?
Is this a Console Application?
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
yupe..
win32 console application..
|
|
|
|
|
That blackbox is called console.
Well I wrote an example for you and then I lost the whole thing (Page cannot be displayed).
Well CG has done that for you...
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
owh..ok..
thanks...
|
|
|
|
|
Nibu thomas wrote: That blackbox is called console.
Also called "DOS-Box" in some books ...
Maxwell Chen
|
|
|
|
|
owh..ok..
thanks a lot!
|
|
|
|