|
Handle WM_SYSCOMMAND
and these three values of wParam
SC_MINIMIZE
SC_MAXIMIZE
SC_CLOSE
and right before you "return 0;" you should do this:
SetWindowLong(hwnd,DWL_MSGRESULT,0); //For a dialog box
wWw.KruncherInc.com - My cool programs
|
|
|
|
|
Hi,
I am trying to iterate and delete the elements (assuming atleast 1 element) in a CptrList with this:
void *pPt = NULL;
POSITION pos = NULL;
for (pos = m_points.GetHeadPosition(); !m_points.IsEmpty(); m_points.GetNext(pos)) {
// TRACE("pos: %d, %d\n", pos, NULL);
pPt = m_points.GetAt(pos);
m_points.RemoveAt(pos);
delete pPt;
}
TRACE shows that pos is not equal to NULL as it should be after the last element has been seen.
So pos != NULL check does not work contrary to the MSDN Library documentation. THIS IS ONE PROBLEM.
The OTHER is even if there are more than 1 elements the second element returned by GetAt is not
"valid" (0xcdcdcdcd) and RemoveAt asserts.
Any clues?
Regards
Mahendra
|
|
|
|
|
As soon as you remove the element, you invalidate the position. Here's a better way of doing it:
{
void *pPt = NULL;
POSITION pos = NULL;
for (pos = m_points.GetHeadPosition(); pos != NULL; m_points.GetNext(pos))
{
pPt = m_points.GetAt(pos);
delete pPt;
}
m_points.RemoveAll();
}
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
But is this ok - (re)moving from the tail end if a sub-sequence has to be removed and RQUIRES using
RemoveAt. This seems to works:
for (pos = m_points.GetTailPosition(); !m_points.IsEmpty(); m_points.GetPrev(pos)) {
pPt = m_points.GetAt(pos);
delete pPt;
m_points.RemoveAt(pos);
}
pos is still not NULL in the end though!
Or like in the MSDNL RemoveAt help!:
POSITION pos1 = NULL;
POSITION pos2 = NULL;
for (pos1 = m_points.GetHeadPosition(); (pos2 = pos1) != NULL; ) {
m_points.GetNext(pos1);
pPt = m_points.GetAt(pos2);
delete pPt;
m_points.RemoveAt(pos2);
}
Due Regards
Mahendra
|
|
|
|
|
One problem I see in your example is the line delete pPt; . This line won't work correctly. Since pPt is a void pointer, the compiler won't know which delete operator and destructor to call. This will lead to memory leaks and possibly heap corruption. A better approach would be:
while (!m_points.IsEmpty()) {
MyType *pPt = (MyType *)m_points.RemoveHead();
delete pPt;
} In this case, MyType is the type of the value pointed to by members of the list.
If you use a CTypedPtrList<> , you can delete the contents of a list more simply as follows:
CTypedPtrList<MyType> m_points;
while (!m_points.IsEmpty()) {
delete m_points.RemoveHead();
} Using CTypedPtrList you don't need type casts.
Software Zen: delete this;
|
|
|
|
|
I'm writing an activex control and I have subclass the ListBox control.
I want to handle the messages WM_MEASUREITEM and WM_DRAWITEM, but I see that there are not virtual functions for the activex control class to override those message. So if I add the handles for thoses messages nothing happens.
How can I handle those messages, 'cause I want to provide the posibility of change the font, then the items measure change.
Thank you.
|
|
|
|
|
Hi Peter,
You might be able to catch it in PreTranslateMessage( ).
Jeff
|
|
|
|
|
Hi All
I have to develop a simulation application (MFC or OpenGL, yet to decide. )
I have to simulate explosive blasting and post blasting air wave movement.
There are some holes on the view (say screen). Each hole is having explosive filled.
Hole will blast one by one with delay in between. Say firts hole blast when it was initiated and then other holes one by one after some delay.
When one hole blasts then a air wave pulse will move out from teh hole location at the propogation speed of the sound. Similar will be for rest of holes.
SO i have to simulate following things:
>Explosive in hole blasts
>Air wave circle generates around the point of blast
>Air wave circle keep on moving/travelling away from the point of blast and its size keep on expanding based on time i.e. air wave circle size keep on increasing.
I have to show the above seq. in my simulation.
So this is the first part of my problem. How to do this? How to start with?
Next is i want to save complete simulation as movie file either avi,asf,mpeg (I do not have any idea regarding this)
How to proced?
Leave your mark wherever you go
|
|
|
|
|
Hi folks - trying to get the hang of Dialog boxes in an MFC application.. I can create the box okay and add member functions. I want to use a menu command to display the box. What do I need to do to actually make the box appear?
TIA
Keck
|
|
|
|
|
Keck wrote:
What do I need to do to actually make the box appear?
For a modal box, simply call DoModal() .
CMyDialog dlg;
dlg.DoModal(); For a modeless box, you'll need to call Create() and ShowWindow() .
CMyDialog *dlg = new CMyDialog;
dlg->Create();
dlg->ShowWindow();
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The Menu part ? or the DoModal part ? ( last one already answered by David )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
I have problem with ActiveX server included in MS Internet Explorer 5.5.
The aplication changes several pages in circle and all events are handling by Javascript.
After som time IExplorer shows message, like : "script on this page is causing internet explorer to run slowly".
I found this IExplorer bug in MSDN and I Set Timeout Period for Script by creating a new value in registry "MaxScriptStatements"=dword:ffffffff.
But after some time of running aplication, IExplorer shows this message again.
Have you any other idea how to fix this problem? (e.g. where IE saves total number of tracks of executed script statements ?)
Please help me.
Thanks.
|
|
|
|
|
How to can i create Setup of my Application
i have saw Visual Studio Installer.
But i not saw here the Changing of Dialogs Text as displayed on them ,, only can change there properties that is a Bmp banner ..
i want to create my own Dialog or want to change backgruods of dialog.
there is also a InnoSetup. but i not know abut its Script ,,
any other easy way or tools
some one said may there is a Installer for VC++ 6 in Visual Studio.
but there is a combine VS intaller is it that one ..
it makes only .msi file .. not a Setup File
thanx
|
|
|
|
|
You can create your own dialogs in a Windows Installer installation. I have never done it. See if Installsite helps you.
http://www.installsite.org/[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Check out InstallShield.
Kuphryn
|
|
|
|
|
hi,
i got an MDI app uses view/doc.
i have 3 views (and docs) that every one of them got a grid control and a button to Add new row.
i want to make a menu that will have the option to Add new row.
the problem is that in the AppWizard i can attach the menu item to only one function in the view.
but i want that no matter which wiew is opened, when i press the Add new row menu item it will work like the button on the view itself.
how can i do that?
|
|
|
|
|
each view should allow you to write a handler for the menu item. Or, you could add a function to your Document class called SetView(ViewType* pView), and depending on the view's type call the appropriate function. Or send a function pointer into the document so that when that menu item is called, it will call which ever function that pointer points to.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
HI,
On pressing Escape Key , my application dialog disappears .... Some one asked me to Override OnOk() and OnCancel() ...but there is no result ...
Plz tell me a good one .
thanx
|
|
|
|
|
Did you remove the call to the CDialog implementation in OnCancel ?
|
|
|
|
|
i got it,,
thanx ,, but wts a relation between Escape key and OnCancel() can u tell me littlte detail
thanx
|
|
|
|
|
Removing Oncancel .... escape key ok
But Clsoe Button in System menu near maximize not works to close application
another problm now
any help abut it
|
|
|
|
|
If you only want to filter the physical keyboard key, look at Anthonys answer below.
|
|
|
|
|
To catch enter key, override OnOK() and do not call CDialog::OnOK()
To catch esc key, override OnCancel() and do not call CDialog::OnCancel()
To have the close [x] button work when you override OnCancel() you have to override OnClose(). In the override call CDialog::OnCancel(). The default behaviour of OnClose() is to call your overridden OnCancel() which you have told to do nothing.
Do not override PreTranslateMessage(). That is just the lazyman's way of hacking things together.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Please check out the reply in your previous thread..
It has a sample implementation. It might help you...
if not, do not know where the prob is..
|
|
|
|
|
I normally use PreTranslateMessage to prevent unwanted key presses
BOOL CDialogClass::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_ESCAPE)
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|