|
You need a handle to the process, which you can get as a return value from CreateProcess() or ShellExecuteEx(). Call WaitForSingleObject() and pass it the handle, and a timeout of 0. It will return WAIT_TIMEOUT while the process is running, and WAIT_OBJECT_0 when it closes.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
in a reminder app i'm playin with i can't delete from the database and i don't understand. if i un comment the lines (test to read)
I get the required info, which means to me i'm on a recordset, but when i call delete it errors with no current recordset, what am i doing wrong?
BOOL CPageThree::DeleteRemind(CString sec, CString name)
{
CDaoDatabase datab;
CString SqlString;
int iRec = 0;
TRY
{
// Open the database
datab.Open("remind.mdb");
// Allocate the recordset
CDaoRecordset recset( &datab );
// Build the SQL statement
SqlString = "SELECT * "
"FROM Remind WHERE Catagory='";
SqlString += sec;
SqlString += "' AND Extra1='";
SqlString += name;
SqlString += "'";
// Execute it
recset.Open(dbOpenDynaset, SqlString, dbAppendOnly);
// make sure we can make changes and update
if (!recset.CanAppend() || !recset.CanUpdate( ))
AfxMessageBox("can't append from recordset");
// test to read from current recordset
// CString sWarnDate;
// recset.GetFieldValue("WarnDate",sWarnDate);
// delete the current record
recset.Delete();
// Close the database
datab.Close();
}
CATCH(CDBException, e)
{
// If a database exception occured, show error msg
AfxMessageBox("Database error: "+e->m_strError);
return FALSE;
}
END_CATCH;
GetDlgItem(IDC_BUT_DEL)->EnableWindow(FALSE);
InitTree();
return TRUE;
}
p.s am a beginner so be kind
shotgun
|
|
|
|
|
okay i got it, it was my dbAppendOnly, should be dbSeeChanges, of course
shotgun
|
|
|
|
|
How do I find the height in pixels of what a combo box control *should* be? I am creating my own custom control, which includes combo list and list box sub-controls, and I want the user to be able to draw my control onto the dialog and have both sub-controls be the full width, and the list control be as tall as my custom control - the height of the combo box - a small gap between.
So I need to be able to calculate the size that the combo box should be in order to find the position and height of the list box below it....
Thanks!
- Kati
|
|
|
|
|
1. A dialog box derived from CFontDialog doesn't call PreTranslateMessage!?
(Dialogs derived from CDialog or the common control dialogs always do).
This makes it difficult to provide Tooltip support in a CFontDialog derivation.
Does anyone know why - or how to add Tooltips?
2. Changing the Sample Text (Control ID stc5) only works initially. As soon as the font selection
is changed the Sample reverts to "AaBbYy" etc. How/can you subclass this control and "user"
set this text.
3. Ditto the position of this text on the CFontDialog seems to be "hardcoded" independently of Control ID stc5.
Moving the stc5 window in a resizable dialog doesn't move the Sample Text. Why??
gjr
|
|
|
|
|
Hi,
I'm wondering if anyone can solve the closest pair problem in C/C++. "Closest Pair" problem is to find two points that are closest in a set of points. Of course we can use "brute search" by comparing each and every point but I need a faster algorithm than that (just like quicksort is faster than bubblesort).
Thank you
Chris U.
|
|
|
|
|
|
Subject: COM BSTR SysAllocString SysFreeString
simple question on memory allocation and deallocation...
Following is a simple function exposed by an interface:
STDMETHODIMP CQueryGenerator::GenQuery(BSTR bstrParam, BSTR *bstrSQL)
{
// TODO: Add your implementation code here
* bstrSQL = SysAllocString(L"Testing");
return S_OK;
}
Its corresponding IDL definition:
[id(1), helpstring("method GenQuery")] HRESULT GenQuery([in] BSTR bstrParam, [out, retval] BSTR * bstrSQL);
Is it the responsibility of the client to call SysFreeString for the returned string?
Thanks!
norm
|
|
|
|
|
Yes, otherwise you would be stuck with the problem of making two round trips in order for the caller to determine how many characters need to be allocated for the string, like in the Win32 API.
And two round trips is bad in COM, because remember the objects might not be in the same process, or even the same machine.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
norm wrote:
round trip?
A round trip is basically a function call. The caller or client calls into the COM object send in data. This would be travelling to the COM object. Then the result is returned back to the caller. This would be returning from the trip.
The reason why it is good to think about function calls, as trips when you are dealing with COM, is that it may just be that, a trip that takes quite a while to process because of latency delays.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Actually, you should call SysFreeString(*bstrSQL) first, to free any memory that the string was using prior to the function call. Once you call SysAllocString() , that memory belongs to the caller, so it's not your responsibility any longer.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
please bear with me:
"you should call SysFreeString(*bstrSQL) first"
what do u mean deallocating the memory PRIOR to the function call? but how can u do this since u're basically passing the address of the string back to client. If you free the memory before passing it to client, isnt that equivalent to passing a NULL pointer to client?
One more question: How can u SysFreeAlloc in an ASP application?
Thanks!
norm
|
|
|
|
|
I mean call SysFreeString() before storing a new value into the BSTR.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi !
I have a base class that have the Serialize function as a virtual one.
I defined the Serialize function in the class the inherit from the base and used it to WRITE data to the disk like this:
ar<<base_class <-----="" (base_class="" is="" a="" pointer)
but="" when="" i="" wtire="" this="" code="" in="" order="" to="" read
ar="">>base_class the compiler don't want to do it
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class CDriveCage *' (or there is no acceptable conversion))
How come ?
By the way base_class is defind like this
CBASE_CLASS *base_class=new Child_CLass
|
|
|
|
|
When you write it is going to write a number, being the address of the item. When you try to read, the operator does not exist for the pointer, and it does not downcast. That's how it looks to me, anyhow.
Why would you store the address of an item when you serialise ? Or does the shift operator work with pointers for serialisation ? I don't know serialisation, I'm assuming it works the same as iostreams.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
When you Serialize you can give the archive object a pointer to an object and as long as this object have the Serialize function is works, you can see the the << operation worked and it is also going through the same serialize function.
by the way, If I do this:base_class->Serialize(ar) ,it works , but then it will not read the object Schema which I can't afford....
Thanks
Shay
|
|
|
|
|
OK, in that case I suppose I could complain about Microsoft using the iostream notation and changing the rules, but the bottom line appears to be that I have no idea what I am talking about....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Shay, see this[^] article for an explanation.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I will appretiate it if you can be more specific and explain why the wtire operation is OK with the compiler and the read is not.
the write goes well and smooth, I was able to read the file in HEX mode and I see the object's data structure written nicely so I know it works.
Once, again, why the compiler complains it can't use this operator when the other operator worked...
Thanks
Shay
|
|
|
|
|
|
If a certain condition is fulfilled in a subdialog, i close the subdialog and return to the original parent dialog.
What i want to do is when i return to the main dialog, i want to make visible a DlgItem, which is not visible by default. If i was in the main dialog, i would have used ShowWindow(TRUE) . But how do i trigger this on the closing of the subdialog?
Cheers,
Ayush
|
|
|
|
|
Use GetParent and cast it to the right type of dialog, so it can see the item. Or just do it in the main dialog by checking the state of varables in the sub dialog after it closes.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
If i do it in the main dialog by checking variables, where would i declare it? i.e. where does the program return to once the subdialog closes?
|
|
|
|
|
Declare a method in your dialog, such as GetShouldIDoIt, and have it return the state. If you do this:
CMyDialog dlg;
if (dlg.DoModal() == IDOK)
{
// at this point your CMyDialog instance exists, although none of it's windows do, so you can call it's non Window methods.
// and check any public variables if you defied OO and created some.
if (dlg.GetShouldIDoIt())
myControl.ShowWindow(SW_HIDE);
}
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|