|
hi !!!
can u plz tell me how to calculate the total duration of an audio file using VC++ (or SDK).....
u can also contact me at jayostu@yahoo.com
bye
jayostu
|
|
|
|
|
The code below is a simple pool manager i written for pooling the VBScript
engines. I also created a CShirleyScriptSite COM:
<br />
class ATL_NO_VTABLE CShirleyScriptSite :<br />
public CComObjectRootEx<CComMultiThreadModel>,<br />
public CComCoClass<CShirleyScriptSite, &CLSID_ShirleyScriptSite>,<br />
public IDispatchImpl<IShirleyScriptSite, &IID_IShirleyScriptSite,<br />
&LIBID_ShirleyLib, 1, 0>,<br />
public IActiveScriptSiteImpl,<br />
public IActiveScriptSiteWindowImpl<br />
{<br />
... ...<br />
}<br />
I put into a MFC application 's MainFrame,
CComPoolManager<CComObject<cshirleyscriptsite> >="" m_scriptegr_pool;
in="" init="" instance,="" i="" called="" m_scriptegr_pool.createpoolobjects().="" when="" the
mainframe="" is
displayed,="" click="" the="" "x"="" button,="" then="" application="" should="" exits.
however,="" it="" is
still="" "run"="" in="" debugger,="" and="" ccompoolmanager's="" destructor="" seemed="" not
to="" be="" called.
anything="" wrong="" ?
if="" don't="" add="" line="" m_scriptegr_pool.createpoolobjects(),="" exits="" to
[design]="" mode
normally.="" can="" anyone="" show="" me="" night="" ?
<code="">
////////////////////////////////////////////////////////////////////////////
///////////////
//Function: CComPoolManager
//
//Description: A pool manager that does pooling of COM Objects. The
controlled objects (T)
// must be derived from CComObject<TypeName>.
//
//Usage: CComPoolManager<CComObject<CYourComClass> > m_my_pool;
////////////////////////////////////////////////////////////////////////////
///////////////
template <class T, int PZ = 10>
class CComPoolManager
{
public:
typedef std::deque<T*>::iterator iterator;
CComPoolManager() : m_pool_threshold(PZ)
{
TRACE("CComPoolManager constructor called\n");
InitializeCriticalSection(&m_cs);
}
~CComPoolManager()
{
TRACE("CComPoolManager destructor called\n");
iterator itr;
for(itr=m_free_list.begin();itr!=m_free_list.end();itr++)
{
(*itr)->Release();
}
m_free_list.clear();
DeleteCriticalSection(&m_cs);
}
//create default no. of objects
void CreatePoolObjects(int sz = PZ)
{
if (sz > PZ)
sz = PZ;
while(m_free_list.size() < sz)
{
T* pobj = NULL;
HRESULT hRes = T::CreateInstance(&pobj);
_ASSERTE(SUCCEEDED(hRes));
m_free_list.push_back(pobj);
}
}
void SetPoolThreshold(long thr)
{
m_pool_threshold = thr;
}
T* AllocateFromPool()
{
T* pobj = NULL;
EnterCriticalSection(&m_cs);
//allocate from the beginning of the list
iterator itr = m_free_list.begin();
if (itr != m_free_list.end())
{
pobj = *itr;
m_free_list.pop_front();
}
else
{
HRESULT hRes = T::CreateInstance(&pobj);
_ASSERTE(SUCCEEDED(hRes));
}
LeaveCriticalSection(&m_cs);
return pobj;
}
void ReturnToPool(T* pobj)
{
EnterCriticalSection(&m_cs);
if (m_free_list.size() > m_pool_threshold)
{
pobj->Release();
}
else
{
m_free_list.push_back(pobj);
}
LeaveCriticalSection(&m_cs);
}
private:
CRITICAL_SECTION m_cs;
std::deque<T*> m_free_list;
long m_pool_threshold;
};
|
|
|
|
|
Hi there,
I need to send a message to a UDP or TCP client.
The function needs to be synchronic.
I the following code 'good practice' ?
When does Send() or SendTo() return WSAEWOULDBLOCK ?
Greetings,
Niko
bool CSomeClass::SendMessage(BYTE *lpBuf, int iBufLen)
{
if (GetConnectionType() == eTCP)
{
if(!m_pSocket)
return false;
int iBytesSend = 0;
while (iBytesSend < iBufLen)
{
iBytesSend += m_pSocket->Send(lpBuf+iBytesSend, iBufLen-iBytesSend);
if (iBytesSend == SOCKET_ERROR)
return false;
}
return true;
}
else if (GetConnectionType() == eUDP)
{
//Use Server socket to send UDP Message
int iBytesSend = 0;
while (iBytesSend < iBufLen)
{
iBytesSend += m_pServerSocketUDP->SendTo(lpBuf+iBytesSend, iBufLen-iBytesSend,
m_uiPeerPortConnection, m_csPeerNameConnection);
if (iBytesSend == SOCKET_ERROR)
return false;
}
return true;
}
return false;
}
|
|
|
|
|
Is the socket actually connected when you send this call?
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
Jon Hulatt wrote:
Is the socket actually connected when you send this call?
Yes,
TCP socket is accepted.
UDP socket is ready to send/receive
|
|
|
|
|
Hello, the codegurus around the world.;)
Actually, does your code work for both UDP and TCP client?
Did you change the port number for UDP or TCP client?
I believe that one server can create the socket with both UDP and TCP,
but the server have to change the port number.
WSAEWOULDBLOCK message is called on non-blocking and asyncrious socket.
So, if you use blocking or syncrious socket, WSAEWOULDBLOCK is never called.
As long as you use Asyncsocket class, WSAEWOULDBLOCK might be called at any time.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Hi,
How can I find out the value of CLOCKS_PER_SEC?
Best regards/ Janette
|
|
|
|
|
It's defined in Time.h and it's value is 1000.
By the way - using windows timer is sometimes not enough.
Although CLOCKS_PER_SEC is 1000, the timer is updated approximately every 55ms, that is less than 20 times per second.
As for me i prefer to use QueryPerformanceCounter and QueryPerformanceFrequency functions - these use a timer that is updated very often (depends on hardware). I should be "smoother" than 1us (over 1MHz frequency).
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
Enable browse info and press F12
"Search in files" for it.
Print it out.
Get Visual Assist and hover to mouse over it.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
Anywhere in your code (e.g. in your CMainFrame constructor)put in
UINT test=CLOCKS_PER_SEC;
Set a breakpoint and run it in debug mode.
Regards, Hakon.
|
|
|
|
|
HI ALL,
I have an application which requires loading a selected bitmap in a bitmap control. The bitmap is selected using the common dialog control during run time. What i require is on selecting the new bit map using the common dialog control when my program is running, it should be displayed on the bitmap control placed in my dialog and should adjust its size automatically to the size of bitmap control.Also when i select a new bit map it should be displayed in the position of the previous bitmap. How can i achieve this?
Hope that anyone will help me.
With regards
|
|
|
|
|
1) Load the image from disk with LoadImage
2) send STM_SETIMAGE to bitmap control
3) to resize the control, get the image height and with with GetObject and use MoveWindow.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
How can i provide the handle?
Can you send me a sample code?
With regards
Shibu
shibukv@yahoo.com
|
|
|
|
|
i have displayed a dialogbox using DialogBox() API, i want to remove system menu but i need a close button how can i get rid of this system menu.
|
|
|
|
|
Billa wrote:
how can i get rid of this system menu.
By unchecking 'System Menu' in dialog editor.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hi All,
Does anyone know how to get the original data that view source shows programatically in IE? I would like to access the data in the exact format that it is received from the server.
Currently I am accessing the HTML source through the DocumentElement->OuterHTML call that is available from the IHTMLDocument3 interface. However, because the HTML has passed through the HTML DOM, it has parsed it and reformatted the data.
If anyone can point me in the right direction I would greatly appreciate it.
Thank you,
Paul
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!
|
|
|
|
|
Hi all,
I just wanted to let you know that you can query the IHTMLDocument for the IPersistStreamInit interface and call the Save method to save the raw data to an IStream object. Then it can easily be read into a BSTR or a CString.
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!
|
|
|
|
|
Hello, the codegurus around the world.;)
We can use Socket program to post HTTP GET command to HTTP server.
And we get the html source code by receive function of Socket.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
THanks for the suggestion, but I was looking for a solution that I could tell what the user was currently looking at in their browser.
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!
|
|
|
|
|
|
Thanks, that looks like a very good example. However he is not doing what I needed:
[quoted from the explanation of that example]
The information presented is gathered after the Internet Explorer has parsed it. This is quite different from e.g. the information you get from the standard "View Source" popup menu.
BTW, I did find the correct solution. It involves qquerying the browser for its IPersistStreamInit interface, and calling the save method. The raw HTML data is found there.
Thanks again.
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!
|
|
|
|
|
How do I make List Control get its contents from a text file?
"Behind every longing of man is a longing for God."
|
|
|
|
|
I'm afraid you'll have to do most of the work yourself. Read the text file (probably using CStdioFile, if using MFC), then display in your list control in the format that you require.
If this control is used very regularly in your project, you might consider creating a derived custom list control that does this automatically. But you still have to code the hard bits yourself.
A simple case would be like: (NB: This is UNTESTED and probably will not compile, but it
demonstrates my line of thinking .
<br />
CStdioFile myFile; <br />
CString strLine;
<br />
int nIndex=0;<br />
if( myFile.Open( "C:\Text.txt", CFile::DenyNone | CFile::modeRead ) )<br />
{<br />
while( myFile.ReadString(strLine) )<br />
{<br />
m_ListCtrl.InsertItem(nIndex++, strLine);<br />
}<br />
myFile.Close;<br />
}<br />
chin
|
|
|
|
|
Yes, my current project heavily uses the List Control. I am not allowed to use any database program so what I would do is use a text file as my data storage and display its contents in the list box.
Thank you, Chin. I'll try your code.
"Behind every longing of man is a longing for God."
|
|
|
|
|
arg.. i have been using .net since it shipped and now i have added a new dialog.. i right click on the dialog and say 'Add Class'.. specify the class name and set it to be derived from CDialog (instead of CHtmlDialog).. and click ok..
and it doesn't make the .h or .cpp or add the class to my project!!!
i have tried deleting the source safe files and setting all of the files to not be read only.. i have tried adding a dummy dialog and adding a class for it, and it will NOT make a frickin' class for any dialog at all now..
if i try to add a message handler for a button i have tried to make a class for it gives me a frickin' debug error in the 'script' since all of there dialogs are apparently html driven now..
arg.. i cant deal with making every dialog manually instead of having .net make the classes for me, its just too much of a pain in the arse..
is anyone familiar with this error, or can anyone give me an expectation of what to expect if i try to get technical support from microsoft?! i have spent the last 6 months developing this frickin' software and now i cant add any classes to any dialogs?! i thought this was perhaps a screwup in the .rc or the recourse.h, but i am not familiar with these files, and they seem to look the same for the new dialogs as they have for every other dialog ive ever made in .net
arg..
i cant make any classes from any dialogs.. plz give me advice as to what my next plan of action should be (besides manually adding these classes..).. arg..
-dz
|
|
|
|