|
I think Menu is a part of your Frame window and you are calling the function in a class of View window. Is it?? if yes, try like this...
<br />
CMenu* pMenu;
CWnd* pParent = GetParent();<br />
pMenu= pParent->GetMenu();
pMenu->CheckMenuItem(ID_EDIT_CASESENSITIVE, MF_UNCHECKED);<br />
|
|
|
|
|
interface IDraw
{
virtual void Draw() = 0;
};
interface IShapeEdit
{
virtual void Fill (FILLTYPE fType) = 0;
virtual void Inverse() = 0;
virtual void Stretch(int factor) = 0;
};
//------------
// C3DRect supports IDraw and IShapeEdit.
class C3DRect : public IDraw, public IShapeEdit
{
public:
C3DRect();
virtual ~C3DRect();
// IDraw
virtual void Draw();
// IShapeEdit
virtual void Fill (FILLTYPE fType);
virtual void Inverse();
virtual void Stretch(int factor);
};
//-----------------------------------
// Here is the global 3D rect.
C3DRect* ptheRect;
// Functions to operate on the 3D rect.
void CreateThe3DRect();
void DestroyThe3DRect();
Implementing CreateThe3DRect() and DestroyThe3DRect() is trivial. Simply use the new and delete keywords to create and destroy the object:
// Creation function.
void CreateThe3DRect()
{
// Create a 3d-rect.
ptheRect = new C3DRect();
}
// Destroy the rectangle.
void DestroyThe3DRect()
{
// See ya!
delete ptheRect;
//--------------------
// This method returns interfaces to the client.
bool GetInterfaceFrom3DRect(INTERFACEID iid, void** iFacePtr)
{
if(ptheRect == NULL){
cout << "You forgot to create the 3DRect!" << endl;
return false;
}
if(iid == IDRAW){ // They want access to IDraw.
// Cast the client's pointer to the IDraw interface of ptheRect.
*iFacePtr = (IDraw*) ptheRect;
return true;
}
if(iid == ISHAPEEDIT) { // They want access to IShapeEdit.
// Cast the client's pointer to the IShapeEdit interface of ptheRect.
*iFacePtr = (IShapeEdit*) ptheRect;
return true;
}
// I have no clue what they want.
*iFacePtr = NULL; // Just to be safe.
cout << "C3DRect does not support interface ID: " << iid << endl<< endl;
return false;
}
//----------------------------------------------------
int main()
{
bool retVal = false;
IDraw* pDraw = NULL;
//IDraw3* pDraw3 = NULL;
IShapeEdit* pShapeEdit = NULL;
CreateThe3DRect();
// Can I get the IDraw interface from object?
retVal = GetInterfaceFrom3DRect(IDRAW, (void**)&pDraw);
if(retVal)
pDraw->Draw();
DestroyThe3DRect();
return 0;
}
//-----
are we simply casting pointers from one type to the next here?
when selecting the interface with GetInterfaceFrom3DRect ,i have iFacePtr which is a void pointer and ptheRect.
*iFacePtr = (IDraw*) ptheRect; <-- i dont get this part.
here iFacePtr is of IDraw type.. now we have ptheRect which is of C3DRect, taking that casting it to IDraw and assigning it to iFacePtr.
does this mean we are working with an instance of C3DRect but of type IDraw?
how did we managed that?
doesn't this mean we can make an instance of an abstract class by type casting it?
As you can see im confused any easy to digest explanation would be great.
thank you
|
|
|
|
|
Lamefif wrote: any easy to digest explanation would be great.
The design is lousy, period. I don't know if any explanation of why would be easy to digest since I don't have any idea what you know.
|
|
|
|
|
take a guess
|
|
|
|
|
in my program,the main exe runs with several dll modules,
and i want to implement the function of replacing one of the dll files when the main exe is running?
can anyone give me some advice?
thanks a lot
|
|
|
|
|
|
Do you want to load dll files on your program?
|
|
|
|
|
usually,when main exe is running,the dlls it loaded cannot be replaced.
i want to replace the loaded dll without kill the main exe.
the process of replace the dll module without stop the main exe is called "make hotfix"
|
|
|
|
|
I am trying to set the row color on certain rows of my clistctrl when certain conditions are met. I am using the following code:
<br />
void CApmDlg::OnCustomdrawMyList ( NMHDR* pNMHDR, LRESULT* pResult )<br />
{<br />
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );<br />
<br />
*pResult = CDRF_DODEFAULT;<br />
<br />
<br />
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage ) {<br />
*pResult = CDRF_NOTIFYITEMDRAW;<br />
}<br />
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage ) {<br />
<br />
MAnciProcedure* pData = (MAnciProcedure*)m_historyLC.GetItemData(pLVCD->nmcd.dwItemSpec);<br />
<br />
HTREEITEM hItem = m_pushTree.GetFirstVisibleItem();<br />
while ( hItem ) {<br />
if ( *pData == *(MAnciProcedure*)m_pushTree.GetItemData(hItem) ) {<br />
COLORREF crBkgnd;<br />
crBkgnd = RGB(192,192,192);<br />
pLVCD->clrTextBk = crBkgnd;<br />
}<br />
if ( m_pushTree.ItemHasChildren(hItem) ) {<br />
hItem = m_pushTree.GetChildItem(hItem);<br />
}<br />
else if ( m_pushTree.GetNextItem(hItem, TVGN_NEXT) ) {<br />
hItem = m_pushTree.GetNextItem(hItem, TVGN_NEXT);<br />
}<br />
else {<br />
hItem = m_pushTree.GetParentItem(hItem);<br />
if ( hItem ) {<br />
hItem = m_pushTree.GetNextItem(hItem, TVGN_NEXT);<br />
}<br />
}<br />
} <br />
<br />
*pResult = CDRF_DODEFAULT;<br />
}<br />
}<br />
I put a breakpoint inside the if statement and it makes it in there and sets the pLVCD->clrTextBk like it should but when I look at my list control the background color hasn't changed. Am I missing something?
Thanks
|
|
|
|
|
Given a handle to a process/main thread or even the ID's, how can I find a handle to the top level window of that process?
At this stage I do not know the window or class name's.
|
|
|
|
|
Iterate through each of the top-level windows with EnumWindows() . For each window encountered, call GetWindowThreadProcessId() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Is there an alternate/better solutions?
The problem here is I am launching a new process via CreateProcess(), since this api returns immedietlym when should it be called? Creating the new window could take much time, that's even if the new process doesn't fail before it's main window is created.
|
|
|
|
|
After calling CreateProcess() , you could call WaitForSingleObject() . Specify a non-infinite wait time that is long enough for the process to do what it needs to.
This might be easier by calling WaitForInputIdle() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well, if it's the only way...
Here's another question similar to the topic. If a create a new console process from a console process, the new process output's to the first window ( ie a second console is not created ). When the first process terminates, the origional owner, the window remains.
Is this normal behaviour?
|
|
|
|
|
Yes.
If you want true separation of console processes you need to specify CREATE_NEW_PROCESS_GROUP if you just want a new console window you need to specify CREATE_NEW_CONSOLE
|
|
|
|
|
Ahh, I see. Thanks for the help.
|
|
|
|
|
WalderMort wrote: Is this normal behaviour?
Wouldn't know, as I've never created one console process from within another. Have you tried the CREATE_NEW_CONSOLE flag?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
MFC OnInitDialog lengthy process halts screen painting
I have a problem, this is similar to another post, where a process in OnInitDialog takes too long and slows the screen from painting on dialog startup.
OnInitDialog<br />
{<br />
if()<br />
else<br />
DoSomethingVerryLengthy();<br />
}
The previously posted solution used a Create instead of a DoModal. This allows us to seperate the initialization of the dialog from the lengthy process. The posted solution looks like this:
pOtherDlg = new COtherDlg(...);<br />
pOtherDlg->Create(...);<br />
pOtherDlg->ShowWindow(SW_SHOW);<br />
pOtherDlg->UpdateWindow();<br />
pOtherDlg->DoSomethingVerryLengthy();
My question is, since this code replaces pOtherDlg->DoModal(), and DoModal waits for the dialog to close before continuing execution. How do I make this new chunk of code wait until the user closes pOtherDlg?
Thanks in advance for the help...
|
|
|
|
|
littleGreenDude wrote: How do I make this new chunk of code wait until the user closes pOtherDlg?
try calling pOtherDlg->RunModalLoop(); after pOtherDlg->DoSomethingVerryLengthy();
|
|
|
|
|
Have you considered using a modal dialog that spawns a secdonary thread to do the lengthy processing? This will result in the modal dialog's primary thread being able to respond to painting and user messages.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
For my WinSock how can i show green and red signal for connected/not connected respectively? Do we have any thing in Controls in Resource editor that could be used(eg: Picture control)?
|
|
|
|
|
A picture control is one way. You could use two icons - one red, one green -
and set the control's icon appropriately.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
could you please elaborate on it? i m not famaliar with using icons on front-end....
|
|
|
|
|
yashveer wrote: could you please elaborate on it?
Sure. Are you using MFC or straight Win32?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|