|
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++
|
|
|
|
|
|
Here's some of the operations involved:
Add 2 icons to your app's resources - here I'll assume they are custom size
10x10 icons, with IDs IDI_INDICATORRED and IDI_INDICATORGREEN.
Draw the icons the way you want them to look.
Then...
CStatic m_IndicatorStatic;
...
if (m_IndicatorStatic.Create(NULL, WS_CHILD | SS_ICON, CRect(0,0,10,10), this, ID_INDICATORSTATIC))
{
m_IndicatorStatic.SetIcon((HICON)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_INDICATORRED), IMAGE_ICON, 10, 10, LR_SHARED));
}
...
m_IndicatorStatic.SetIcon((HICON)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_INDICATORGREEN), IMAGE_ICON, 10, 10, LR_SHARED));
Hope that helps a bit!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
// Add as member of window or dialog class
CStatic m_IndicatorStatic;
where do i add this IDI_ICON1 as CStatic m_IndicatorStatic?
I tried in class wizard but didnt find this ID....
|
|
|
|
|
In the properties for resources, you should be able to change the ID to whatever you want.
IDI_ICON1 sounds like the default ID - you can use that as well. It's just not as meaningful in the
code as an ID that's more descriptive.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|