|
Donguy1976 wrote: Now under a certain condition, i want to make all open dialogs invisible and just show up a LogIn dialog. Or make the login dialog modal so that interfacing with the other dialogs would not be possible (until the login dialog was properly dismissed).
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Is it possible to get all dialog handles in a app? Or the number of dialogs that are open at a given time?
|
|
|
|
|
the function EnumWindows may help you.This function can enum all the window in the window manager .Or you can use the relationship between the dialog and the apps to meet your point.
|
|
|
|
|
Hello everyone,
Today when i was reviewing a part of C++ i noticed continue in some cycles (to be exact i managed to see atleast one example of each cycle with continue)
I remember beeing told that go to and continue shouldn't be used. You can easily do whatever you need with some other tool in c++ semantics.
What do you think? Is using continue a good practice?
|
|
|
|
|
yes
==============================
Nothing to say.
|
|
|
|
|
I think continue is quite okay while goto is evil.
|
|
|
|
|
goto is ok. You can write bad code without it and good code with it, just depends on the code.
==============================
Nothing to say.
|
|
|
|
|
In C there are a very few cases where using it is reasonable, in C++ I wouldn't hire someone who works with goto.
|
|
|
|
|
pasztorpisti wrote: In C there are a very few cases where using it is reasonable
Bollocks.
pasztorpisti wrote: , in C++ I wouldn't hire someone who works with goto.
Dogmatist.
==============================
Nothing to say.
|
|
|
|
|
I have no doubt a good programmer can write good programs with any syntax element of any language, but that doesn't mean that everyone should! Even the best program deterioates over time. Of all elements of the C/C++ language, goto is the one with the biggest potential for abuse, and the biggest potential for misinterpreting its intended use when maintaining the code. Therefore, even if you're the worlds best programmer, you should never deliberately use goto without a very good reason, and only if the existing alternatives would present a bigger potential for maintenance problems in the future.
You might argue that for throwaway code that you know is going to be ditched within a couple of months there is really no risk, but some of the most long-lived tools were originally designed as throwaway code. Even if the program as a whole gets thrown away, parts of it may be reused elsewhere. We are in an age of VCSs and code reuse; you can't take back code: once you've written it it can not be unwritten!
|
|
|
|
|
Is there, use it.
(I know the same argument might used for the goto statement).
Veni, vidi, vici.
|
|
|
|
|
Which I use, as well as the = ? : thingummyjob.
==============================
Nothing to say.
|
|
|
|
|
Me too.
Is there anybody against ternary operator usage, really?
Veni, vidi, vici.
|
|
|
|
|
I am against ternary operator because my ancient VC++ stopped cooperating when I want to watch the variable in debug mode. It just won't paste it correctly.
I know this is not a good reason and I need to upgrade to whatever MS is pushing today.(LOL)
But if you use continue or ternary operator it NEEDS to be commented so one can remain sane when in debug mode!
I sometime use goto and label to have a common point for generic error code, but I would be curious if optimizer would do the same in release code anyway.
|
|
|
|
|
I even use nested ternary operators, sometimes a few deep. That really messes with your head!
==============================
Nothing to say.
|
|
|
|
|
Erudite_Eric wrote: That really messes with your head! Or rather, the poor sod who has the job of maintaining/debugging your code.
Use the best guess
|
|
|
|
|
If you cant stand the heat.....
Actually a lot of programmers cant handle casting and pointrs. I wrote some C code that couldnt be maintained by another team, so they took my product, f***ed it up, made it slower and then released it to the customer.
Oh, they also couldmt understand why doing heavy work in the GUI thread was a bad idea. Dumbfucks. I had it in a seperate thread, but they didnt know why, and probably never did even after I pointed out to them that their app didnt paint or respond to button clicks.
==============================
Nothing to say.
|
|
|
|
|
I worked on a project like that. In the end I stopped tryint to tell people why I thought it important to do something in a particular way; not that it mattered when management canned it.
Use the best guess
|
|
|
|
|
Is it confusing? If it's not stop stressing.
Steve
|
|
|
|
|
Argonia wrote: Today when i was reviewing a part of C++ i noticed continue in some cycles...
Use of 'continue' within a loop to request branch back to the next loop iteration is the main reason for its existence and accepted practice.
Use of 'continue' with a label as a subject of a 'goto' is probably some code that was translated from FORTRAN where 'continue' also exists but means something quite different. This combination of 'goto' and 'continue' should not be used anywhere in C or C++ and should be exterminated wherever found.
In C/C++, use of 'goto' (without continue) is disparaged and at best, controversial. It can be justified in some languages but I never use it in C/C++ and would question such code and require justification for every instance, in every code review.
[I came from an age where 'goto' was prolific.]
--
Harvey
|
|
|
|
|
if you are writing C code for windows platform then you can user __try, __leave and __finally combination to avoid goto.
http://msdn.microsoft.com/en-us/library/9xtt5hxz(v=vs.80).aspx[^]
the main reason to avoid goto is the the instruction set directly jumps to given location and hence you do not get the call stack once you have jumped to new location. It would be really difficult if you have to debug some code like this.
using conitnue is always acceptable it is very useful in certain scneraois when you want to skip some of the values and continue with rest of them for certain operation which is running in a for or while loop and this does not have issue like goto where callstack will be lost.
|
|
|
|
|
continue isn't on quite the same level of abusive potential as goto : goto can jump backwards, out of multiple nested levels of scope, and into an entire different scope. If there are more than a couple of lines or scopes between the goto and the associated label, maintaining the code after several changes is painful at the very least, and hazardous at best.
continue on the other hand only jumps forward, to the end of the current scope. That's pretty much the same as break within a switch statement. it doesn't break the flow of control as indicated by existing control statements (if , for , do , etc.).
|
|
|
|
|
<pre lang="I am trying to gain “remote” access to DirectShow graph.
The graph is in Running Object Table under name.
I can retrieve / enumerate the ROT and get the named moniker.
However, my call to BindToObject fails.
Basically, I am not sure if I have the call to this method set properly.
My question is – since I am looking for a graph interface – do I need to pass graph interface or can I use Iunknown? It fails both ways.
I am nor really sure how to get the graph to the MFC document, but that is next step.
I am enclosing my code snippets , please note - it is under deconstruction and full of notes / comments.
I like it that way.
Any help will be as always appreciated.
Cheers
Vaclav
"></pre>
TRACE("\nHRESULT CDS::C_AddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister)");
IMoniker * pMoniker;
IRunningObjectTable *pROT;
IEnumMoniker *pMonikersTable;
IMoniker *pCurrentMoniker;
int iTestCount = 0;
WCHAR wsz[128] = L"Video" ; // MN used to retrive
HRESULT hr;
if (!pUnkGraph || !pdwRegister)
{
TRACE("\n!pUnkGraph || !pdwRegister");
return E_POINTER;
}
TRACE("\nGetRunningObjectTable ");
if (FAILED(GetRunningObjectTable(0, &pROT)))
{
TRACE("\nGetRunningObjectTable(0, &pROT)");
return E_FAIL;
}
// test enumerate before usage
pROT->EnumRunning(&pMonikersTable);
hr = pMonikersTable->Reset();
if(FAILED(hr))
{
TRACE("\nFailed pROT->Register(.. ");
}
while(pMonikersTable->Next(1, &pCurrentMoniker, NULL) == S_OK)
{
iTestCount++;
TRACE("\n");
}
/*
hr = StringCchPrintfW(wsz, NUMELMS(wsz), L"FilterGraph %08x pid %08x\0", (DWORD_PTR)pUnkGraph,
GetCurrentProcessId());
*/
TRACE("\nCreateItemMoniker using name ");
hr = CreateItemMoniker(L"!", wsz, &pMoniker);
if (SUCCEEDED(hr)) {
TRACE("\nRegister moniker ");
// Use the ROTFLAGS_REGISTRATIONKEEPSALIVE to ensure a strong reference
// to the object. Using this flag will cause the object to remain
// registered until it is explicitly revoked with the Revoke() method.
//
// Not using this flag means that if GraphEdit remotely connects
// to this graph and then GraphEdit exits, this object registration
// will be deleted, causing future attempts by GraphEdit to fail until
// this application is restarted or until the graph is registered again.
hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pUnkGraph,
pMoniker, pdwRegister);
if(FAILED(hr))
{
TRACE("\nFailed pROT->Register(.. ");
}
pMoniker->Release();
}
pROT->Release();
THIS IS A DIFFERENT "FUNCTION"
HRESULT hr;
TRACE("\nBind to control "); // Get a BindCtx.
IBindCtx *pbc;
hr = CreateBindCtx(0, &pbc);
if(FAILED(hr))
{
TRACE("\nCreateBindCtx()", hr);
return false;
}
TRACE("\nGet running-object table.");
IRunningObjectTable *prot;
hr = pbc->GetRunningObjectTable(&prot);
if(FAILED(hr))
{
TRACE("\nCreateBindCtx()", hr);
prot->Release();
return false;
}
TRACE("\nGet enumeration interface.");
IEnumMoniker *pem; // enumerated moniker
hr = prot->EnumRunning(&pem);
if(FAILED(hr))
{
TRACE("\nCreateBindCtx()", hr);
prot->Release();
pbc->Release();
return false;
}
// Start at the beginning.
pem->Reset();
// Churn through enumeration.
ULONG fetched; // actuall number of items retrived , could ve set to NULL
IMoniker *pmon;
int n = 0;
while(pem->Next(1, &pmon, &fetched) == S_OK)
{
TRACE("\nGet moniker for %s Graph name ", strName); // Get DisplayName.
LPOLESTR pName;
pmon->GetDisplayName(pbc, NULL, &pName);
// Convert it to ASCII.
char szName[512];
WideCharToMultiByte(CP_ACP, 0, pName, -1, szName, 512, NULL,
NULL);
TRACE("\nCompare with Moniker name %s",szName); // Compare it against the name we got in SetHostNames().
if(strName.CompareNoCase(szName) /* "!Video")*/ == 0 )
//if(!strcmp(szName, "!Video")) //MN for now
{
TRACE("\nBind to this ROT entry moniker named %s",strName);
/*
IDispatch *pDisp;
hr = pmon->BindToObject(pbc, NULL, IID_IDispatch, (void
**)&pDisp);
*/
IUnknown *pUnkGraph;
hr = pmon->BindToObject(pbc, NULL, IID_IUnknown, (void
**)&pUnkGraph);
if(!FAILED(hr))
{
TRACE("\nBound to object ");
// Remember IDispatch.
// m_pDocDisp = pDisp;
// Notice...
//sprintf(buf, "Document IDispatch = %08lx",
//m_pDocDisp);
//DoMsg(buf);
break;
}
else
{
AfxMessageBox("Failed IUnknown *pUnkGraph;");
TRACE("\nFailed BindToObject() %i ", hr);
}
}
// Release interfaces.
pmon->Release();
// Break out if we obtained the IDispatch successfully.
// if(m_pDocDisp != NULL) break;
}
// Release interfaces.
pem->Release();
prot->Release();
pbc->Release();
<pre lang="text">PS I cannot do "preview" getting "specified module cannot be found".
So if tthis post is too messy, sorry about that </pre>
|
|
|
|
|
Why are you trying to put <pre> tags around your question and comments instead of round your code?
Use the best guess
|
|
|
|
|
Because this site does not do spell check and I do my editing elsewhere and then paste it in.
And I do not pay attention that the entry is by default “code” and than it gets too messy to edit.
Besides I cannot do preview also.
I have no clue why the HTML tags gets posed in the text.
So, thanks for the comments.
I guess the answer is – I am too lazy.
But what is this "plain text" selection for anyway?
Just pasted the above without selecting anything - so is this post nov a code???
Still cannot do preview.
Vaclav
|
|
|
|
|