|
Well if you don't need to send any data the just call CWnd::Invalidate() that will cause a Paint to occur.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Just for everyone's reference, I figured out a way to do this (granted, this way isn't all that clean and is probably more of a 16-bit windows style of doing things, but it works). Rather than using WaitForSingleObject to wait for the I/O to complete, I stuck in this:
while (MsgWaitForMultipleObjects(1,
&ol.hEvent,
FALSE,
10,
QS_ALLINPUT) !=
WAIT_OBJECT_0) {
while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE)) {
DispatchMessage ( &msg);
}
}
So... I just keep dispatching all the messages I received until the serial even becomes signalled. This seems to work well.
|
|
|
|
|
Ok, I have a CArray container like so:
<br />
CArray <myObject, myObject> objectList;<br />
and I declared a dynamic array in a separate class like so:
<br />
class SelectionBox<br />
{<br />
public:<br />
void AddContent(myObject *);
<br />
protected:<br />
myObject *content;
unsigned long numContents;
}<br />
So now I built my AddContent() function like this:
<br />
void SelectionBox::AddContent(myObject *c)<br />
{<br />
unsigned long counter;<br />
myObject *tempObject;<br />
tempObject = new myObject[numContents];<br />
<br />
tempObject = content;<br />
<br />
content = new myObject[numContents + 1];<br />
<br />
for(counter = 0; counter < numContents; counter++)<br />
{<br />
content[counter] = tempObject[counter];<br />
}<br />
<br />
content[numContents] = c;<br />
<br />
<br />
numContents++;<br />
delete [] tempObject;<br />
} <br />
Finally, in another part of the program, I shoot the address of one of the objects stored in the CArray to the AddContent function.
At first the function appeared to be working.. That is until I later tried to manipulate the original objects in the CArray by manipulating what I thought was the pointer to them in my SelectionBox class. Then I found out that I had copies of data stored and not a pointer to the CArray data. I can't for the life of me figure out how to declare the function and pass the data so that I can store an array of pointers/addresses to the data in the CArray container. Can someone show me an example, or maybe a link to a relevant tutorial?
|
|
|
|
|
|
That worked perfectly!!!! Thanks Pete.. I didn't even know that container existed, .. which will help a quite a few more problems I've been facing. Thanks Again
|
|
|
|
|
Hello,
I am writing a program that needs to do diffrent stuff depending on which OS it's running.
How can I do this?
Can I do it without GetVersionEx?
Can I do it with #if(WINVER >= #)? If so what values are for which OS?
Thanks.
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
KingKruncher wrote:
Can I do it without GetVersionEx?
Why would you want to?
KingKruncher wrote:
Can I do it with #if(WINVER >= #)? If so what values are for which OS?
See here for values.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
KingKruncher wrote:
Can I do it with #if(WINVER >= #)?
No, that is a compile time directive not a runtime evaluation.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
You'll eventually need to compile an exe for each version if you'll use #if(WINVER >= # method
It wont be the same exe
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
here you can use my code for this
//structure
struct NmpWindowVersion
{
public:
CString WindowName;//name of windows
int Plateform;//0 stand for single user and 1 stand for multi user
CString WindowsVersion;// contain the iformation abbt service pack etc
CString BuildNumber;
};
////function
int MeCheckVersionInfo(NmpWindowVersion &StructVar)
{
OSVERSIONINFO info;
info.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&info);
int nMajor,nMinor;
CString BuildStr;
//getting Verion nme
switch (info.dwMajorVersion)
{
case 3: StructVar.WindowName="Windows NT 3.51";
nMajor=3;
nMinor=51;
break;
case 4: switch(info.dwMinorVersion)
{
case 0:
if(info.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)
StructVar.WindowName="Windows 95";
else
StructVar.WindowName="Windows NT 4.0";
nMajor=4;
nMinor=0;
break;
case 10: StructVar.WindowName="Windows 98 ";
nMajor=4;
nMinor=10;
break;
case 90: StructVar.WindowName="Windows Me ";
nMajor=4;
nMinor=90;
break;
}
break;
case 5: switch(info.dwMinorVersion)
{
case 0: StructVar.WindowName="Windows 2000";
nMajor=5;
nMinor=0;
break;
case 1: StructVar.WindowName="Windows XP";
nMajor=5;
nMinor=1;
break;
case 2: StructVar.WindowName="Windows Server 2003 family 2";
nMajor=5;
nMinor=2;
break;
}
break;
}
////getting Plateform ID
switch(info.dwPlatformId)
{
case VER_PLATFORM_WIN32_WINDOWS:StructVar.Plateform=0; break;
case VER_PLATFORM_WIN32_NT :StructVar.Plateform=1; break;
}
///getting Platform version
StructVar.WindowsVersion=(CString)info.szCSDVersion;
////getting the build number
BuildStr.Format("%d.%d.%d",nMajor,nMinor,LOWORD(info.dwBuildNumber));
StructVar.BuildNumber=BuildStr;
return 0;
}
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I forgot (like I often do) to add help to my app's settings when creating my project. I'm pretty far along in the project now, so I don't want to start over, so what do I need to do to add help now since the project is already created?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Anytime you forget to do something with AppWizard, it's usually best to create a temp project using the desired settings, and then compare to see what items your project is missing.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
yeah, I thought about doing that, but I was hoping there was an easier way!! (just lazy ) thanks!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
what message handlers uses the min,max and close button
|
|
|
|
|
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
|
|
|
|