|
ARGH - this is killing me. All I am trying to do is take a dialog, bring it to the front, centered, and activated. And I CAN'T for the life of me figure out how to do all three! Here is some code I have tried, in the dialogs, OnInitDialog handler:
BOOL CongratsDlg::OnInitDialog()
{
...
CenterWindow();
ShowWindow(SW_RESTORE);
}
I have tried various parameters in ShowWindow , and I have tried it with the SetWindowPos stuff, and without it... and with it but not ShowWindow... etc.
So what is the magic combination to show and activate a window?
Some background: this is an MFC app. It has no main window - it launches some other app, waits for it to finish, and then pops up this dialog.
Muchas gracias.
Even a broken clock is right twice a day.
|
|
|
|
|
Hmm - I may have answered my own question. It seems like if I have the Start menu active at all - even if I activate it long before this dialog comes up, the window won't activate. It seems that in any other situation, the code I have above works.
Ah well.
Even a broken clock is right twice a day.
|
|
|
|
|
|
Hey guys
I just told someone on a forum that CString has an implicit const char* operator. Now I suddenly realized that this is actually wrong grammar or usage or whatever. I mean implicit operators are the ones the compile does for us huh? Like conversion of int to char etc... So I should not have used the word implicit there, right? But then it's not an explicit operator either cause the user need not actually put a cast there. So can someone gimme some info on best usage practices for such stuff, so that I wont confuse other people in future
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
It is more question of English language, than programming. Stroustrup writes something like "operator const char*() ... provided convenience of an implicit conversion..."(#20.3.7). I understand that as an operator provides some implicit action, but itself cannot be implicit. But again, I am not a native English speaker.
|
|
|
|
|
|
You should have said "an LPCTSTR operator" But seriously, since all operator TYPE() functions can be invoked implicitly, you weren't completely wrong.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
Hi.
Anyone know of a portable way
of doing program icons
(the kind you see when looking in a folder)?
Got an example?
How do I go about making
the program icon a separate file
(so if i edit it, i don't have to recompile)?
Any reading you can point me to, i'd really appreciate it.
|
|
|
|
|
So far I'd been making projects with CFormView, so when I wanted to adda handler for the bn_clicked I would just dbl click on the control, say a button, and the ONButtonA type function would be created and automatic messagemap entries made.
Now I have a CView project and am having to add the controls using .Create() so I cant very well dbl click to add the handler automatically. In this case am I responsible for making messagemap entries? Is there no automatic mechanism for this?
Thanks
Appreciate your help,
ns
|
|
|
|
|
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
|
|
|
|
|