|
Thanks - looks really nice indeed.
Anyway, I don't need any serious thread managment at this time, and I don't store the thread handle at all. I just have to run it and wait till it finishes the job, but I don't have to wait till process it really quits. All I care is when the data will be ready.
[ CoY0te ]
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
Okay, if your stuff works right now you have no reason to change it
However, please note that the described technique has nothing to do with "serious thread management". It just shows how to use member functions where C-style callbacks are expected. This is exactly what you asked in your original post: How to do the conversion from a pointer to a member function to THREAD_START_ROUTINE
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Can we create a bitmap of a hidden window??????
|
|
|
|
|
You may try to send WM_PRINT. Just remember that window is free to ignore this message.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
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!
|
|
|
|