|
One solution is to add the messages to the message map.
afx_msg BtnHandler()
ON_BN_CLICKED(ID, Handler);
Kuphryn
|
|
|
|
|
Thanks for the information.
Appreciate your help,
ns
|
|
|
|
|
hey, i want to write an app that does low level screen capture based on a users selection of the screen, to capture video. i want it to capture an incoming stream until the user stops it (or their predefined harddrive limit is reached).
ive set up most of my app now, im just unsure how im going to grab and store the video from the selected area of the screen.
I figure i might have to take rapid screenshots and store that, maybe a little slower than the original video, i could live with a little bit of degredation , but i would like even more if their was better suggestions, thus, my plea to cp developers for help
any suggestions / ideas??
|
|
|
|
|
Hello,
I'm facing a tricky situation with my project using MSXML interfaces. Calling methods from my COM Object passing to it IXMLDOMDocument2 seems to leak after looping a while in a multi-thread environment. Here is an example code:
(...)
CComPtr<ixmldomdocument2> inDocXML;
CComPtr<ixmldomdocument2> outDocXML;
hr=myFunc(inDocXML,outDocXML);
(...)
HRESULT myFunc(IXMLDOMDocument2 *inDoc,IXMLDOMDocument2 **outDoc) {
(...) do some stuff
CComPtr<ixmldomdocument2> myTempDoc(inDoc);
(...) do some stuff
outDoc=myTempDoc.Detach();
return S_OK;
}
I'm using a ISAPI to call this COM Component (installed at COM+).
I tried almost everything and, when I used a [out] parameter for a Interface to DOM its seems to leak!!!
My components are Free Threaded.
Can anyone help me, or have faced with this problem already ?
Thanks,
Mário
|
|
|
|
|
1. Could you please give the complete code? The sudocode you provided is difficult to diagnose. The very places under suspicion would not probably compile in your example.
CComPtr inDocXML;
CComPtr outDocXML;
hr=myFunc(inDocXML,outDocXML); //I think it would not compile
(...)
HRESULT myFunc(IXMLDOMDocument2 *inDoc,IXMLDOMDocument2 **outDoc) {
(...) do some stuff
CComPtr myTempDoc(inDoc);
(...) do some stuff
outDoc=myTempDoc.Detach();//I doubt it would compile ether
return S_OK;
}
2. MSXML uses some funny memory management. How do you know there is actually memory leak? It could be that they just preallocate and hold memory.
|
|
|
|
|
1. the main code is:
STDMETHODIMP Cdemo::myDemo(BSTR docIn, BSTR *docOut)
{
HRESULT hr;
CComPtr<msxml2::ixmldomdocument> pDOMObject=NULL;
CComPtr<msxml2::ixmldomdocument> myDocTemp=NULL;
CComBSTR mOut=NULL;
hr= CoCreateInstance(CLSID_DOMDocument, NULL,CLSCTX_SERVER,
IID_IXMLDOMDocument2, (LPVOID*)(&pDOMObject));
hr=pDOMObject->loadXML(docIn);
try
{
hr=MyPrivateFunc(pDOMObject,&myDocTemp);
if FAILED(hr)
throw hr;
if (myDocTemp)
hr=myDocTemp->get_xml(&mOut);
else
mOut=L"Error";
*docOut=mOut.Detach();
}
catch (...) {
mOut=CComBSTR(L"Error").Detach();
}
return S_OK;
}
HRESULT Cdemo::MyPrivateFunc(MSXML2::IXMLDOMDocument *xmlin,MSXML2::IXMLDOMDocument **xmlout) {
IXMLDOMDocumentPtr myDoc;
CComPtr<msxml2::ixmldomdocument> myDocIn(xmlin);
CComBSTR mtemp;
if (myDocIn)
myDocIn->get_xml(&mtemp);
HRESULT hr=CoCreateInstance(CLSID_FreeThreadedDOMDocument30, NULL,
CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument2,
(void **)&myDoc);
if FAILED(hr)
return S_FALSE;
CComBSTR bstrDummy("<demo>");
bstrDummy.Append(mtemp);
bstrDummy.Append("");
myDoc->loadXML(bstrDummy);
*xmlout=myDoc.Detach();
return S_OK;
}
2.
I'm using Stress Tool to instance the object, using a ASP page. after running the stress with 40Threads and for 5/10 minutes the memory doesn´t stop growing...(very small chunks). Its there anything I should know about you said for "funny memory management"...
thanks again.
|
|
|
|
|
I assume that 'CComPtr' is really 'CComPtr<ixmldomdocument2>'. You are right there seems to be no leak point, except for 'BSTR *docOut', but it is used from script so we can assume it is released.
'mOut=CComBSTR(L"Error").Detach();' seems suspicious, but it would not leak mach anyway.
2. From our experience with MSXML we noticed that they preallocate memory with factor of 10 to size of actual document and it is not always released right the way, which in IIS environment could be frustrating. Plus if you use something like USES_CONVERSION it has the same simptoms because it uses stack memory allocation. Depends how big your leak is. I guess you can try your stress for couple of hours(days), see if you run out of memory. It could be normal IIS opertaion not to recicle until you reach phisical memory limit.
|
|
|
|
|
I already used the stress for some days, and the result was that I get 100/200 MB of RAM used for the component, and 100/200MB for the ISAPI/ASP page...
I don't know if this is normal, on that particular case the phisical memory has not been reached, so I will test again for more days, and see if the memory freezes or not.
thanks,
|
|
|
|
|
From listenning to others' experiences, it seems that the MSXML parser has all kinds of memory leaks.
Even a broken clock is right twice a day.
|
|
|
|
|
Hi i am working for a project where i need to provide an option of customization of the application to the user with only providing him the object file ( no source code will be given to user) all he need to do is start the customization utility and simply browse through some options and can get the executable as per his needs, i need to know any idea in order to achieve it.
urgent replies will be deeply appreciated.
thanks
gracias
gracias carol
|
|
|
|
|
gracias_carol wrote:
can get the executable as per his needs,
What does it mean?
|
|
|
|
|
IT simply means the cusomization of the features given to the customer , suppose that my executable provides a list of features and he is only interested in some of those features and he want to change the look and feel of the product , so all i need to give him a smart tool by which he can select the available options or add if he wants and can change the look and feel of it .
can it be achieved by using some sort of configuration file , or and XML file if yes then do let me know how do go ahead for it.
waiting for an urgent reply
thanks
gracias
gracias carol
|
|
|
|
|
When you use the >> operator when reading a file I noticed spipws is there by default. I open the file using File.open("file.txt"). How can I modify this so I can include the whitespace?
|
|
|
|
|
unsetf( ios::skipws )
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
hi i want to help me to release the graphical recources and the Device context in the code below
CFont cf;<br />
cf.CreateFont(16,0,0,0,FW_BOLD|FW_EXTRALIGHT,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial");<br />
<br />
CBitmap b;<br />
b.LoadBitmap(IDB_BITMAP1);<br />
<br />
BITMAP bm;<br />
b.GetObject(sizeof(BITMAP),&bm);<br />
<br />
CClientDC h(cw[n]);<br />
<br />
CDC *dc=new CDC;<br />
dc->CreateCompatibleDC(&h);<br />
dc->SelectObject(&b);<br />
<br />
h.SetTextColor(RGB(10,50,220));<br />
h.SelectObject(cf);<br />
<br />
<br />
h.BitBlt(0,0,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);<br />
dc->DrawText(Int2CString(cw_key[n]),CRect(2,5,25,25),DT_CENTER);<br />
h.BitBlt(0,0,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);<br />
<br />
i write this below code to release them but it seems that i forget something to release .because program will become very Slow after 1 or 2 mintue.
cf.DeleteObject();<br />
b.DeleteObject();<br />
dc->DeleteDC();
when i write : h.DeleteDC(); an error will Occure --> Unhandled exception at 0x77f767cd in MASTER.exe.
i dunno why.
thanks for your help
|
|
|
|
|
HellShrimp4free wrote:
when i write : h.DeleteDC(); an error will Occure
Don't do that. The destructor of CClientDC will take care of it.
What you however should do is either
delete dc;
or put that CDC on the stack, not on the heap.
|
|
|
|
|
I have written a program than spans six cpp file all of which share class information which is located in one header file. I am having a problem organizing my code concerning the global class objects. Each cpp file has it's own header file and depeding on the source code file some header files are nested etc...I would like to organize the program better and do not want to put extern class... at the beginning of each source file. How can I get around this problem? #ifndef-#endif seems could be the way to go but I can't quite get it without link errors. If someone could help out I would be greatful. Thanks.
|
|
|
|
|
Put all the extern statements into a .h file of their own and have all the .cpp file include this file. Only one place needs to be updated for all .cpp files to be updated.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
|
Hello,
yesterday I've found a nice manual on memory addresses. A part:
--------K-M00400017--------------------------
MEM 0040h:0017h - KEYBOARD - STATUS FLAGS 1
Size: BYTE
SeeAlso: MEM 0040h:0018h,INT 16/AH=02h,MEM 0040h:0096h
Bitfields for keyboard status flags 1:
Bit(s) Description (Table M0010)
7 INSert active
6 Caps Lock active
5 Num Lock active
4 Scroll Lock active
3 either Alt pressed
2 either Ctrl pressed
1 Left Shift pressed
0 Right Shift pressed
SeeAlso: #M0011,#00587
Now my question: How can I read this byte?
I tried this code:
unsigned char uTemp;
unsigned char *pNull = NULL;
uTemp = pNull[0x00400017];
char szTemp[32];
sprintf(szTemp, "%02X", uTemp);
MessageBox(GetDesktopWindow(), szTemp, "clock", NULL);
But it always prints "00", zero. But numlock is on! Therefor I think i misinterpret the address.
Whats the correct memory address for pNull[] to read from? How must I convert the "0040h:0017h"?
Thank you!
-Dominik
|
|
|
|
|
This seems 16-bit addresses. You cannot happily inspect those addresses in Win32 protected mode, so I guess what you're inspecting is just a random location into the virtual memory space of the program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
And how can I then read these 16-bit addresses?
It must be possible. Or how do other system information programs get advanced information about the BIOS (more than the 4 information strings in the registry)...?
|
|
|
|
|
Dominik Reichl wrote:
How can I read this byte?
From Win32? You can't. You needing ring0 privs (i.e. kernel-mode device driver).
But why would you want direct hardware access when GetKeyState, GetAsynchKeyState and GetKeyboardState can give you the same info?
|
|
|
|
|
I am currently developing a system information tool and there I need BIOS information (more than the 3 string values in the registry).
The keystate access was just thought as an example. There are many other, more interesting, values in this memory section.
Do you know how other system information programs get this information? For example, how do I detect, if the installed BIOS is flashable?
Thank you
-Dominik
|
|
|
|
|
I have some dialog controls inside an CFormView derived dialog and I need to clear them when the user selects New from file menu or when CDocument::OnNewDocument() is called.
How can I do this?
Thanks
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|