|
Hi everyone!
Thanks for the reply about running an exe directly in memory!
Can anyone tell me how can I lock a process. I use CreateProcess function
Thanks!
|
|
|
|
|
Hi everybody. Does anybody know why a Visual Basic Application doesn't respond to the WM_PRINT messages that I send from Visual C++? I got a serious problem with this because I'm trying to get in a bitmap the contents of a Visual Basic window even if that window is not currently on screen.
I am thinking that maybe I can insert some Visual C++ hook or subclass in the VB window and somehow determine it to answer to the WM_PRINT message. But the problem is that VB windows don't have an OnPaint event........ so I'm kind of stuck.
Thanks for reading this : ).
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
I am using MDI Architecture for my application.
I have the MainFrame Window within which I can create mulitple child windows.
My issue is that I am selecting a color from a dialog box.
When I click the apply button I want to invalidate all the child windows behind the dialog box so that the selected color is applied to the child windows even when the dialog box is visible in the foreground.
I used the following code but it throws a memory exception.
void CMyPropertySheet::OnApply()
{
CDC *pDC;
try
{
GetActivePage()->UpdateData(TRUE);
pDC = this->GetDC();
((CMyApplnView*)AfxGetApp())->OnDraw(pDC);
// ((CMyApplnView*)AfxGetApp())->Invalidate(FALSE);
}
catch(...)
{
AfxMessageBox(" Exception during OnApply");
}
}
I tried calling the Invalidate function of the View class as in the code above but the memory exception is still comming.Can anyone let me know what is the problem here.
laiju
|
|
|
|
|
For updating all the child windows i used the foll. code But it updates only the topmost window.
pMainWnd = (CMDIFrameWnd *)AfxGetMainWnd();
CMDIChildWnd *pActiveWnd = (CMDIChildWnd *)pMainWnd->MDIGetActive();
CKolOSDBuilderDoc* pDoc = (CKolOSDBuilderDoc*)pActiveWnd->GetActiveDocument();
if(pDoc)
{
pDoc->UpdateAllViews(NULL);
}
laiju
|
|
|
|
|
Try that
AfxGetApp()->GetMainWnd()->RedrawWindow(NULL, NULL, RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW);
WBR
Henry
|
|
|
|
|
Is there a "serious" implementation of a MRSW-Lock available?
(I *think* a MRSW lock should do whatI need: I have a map with frequent concurrent reads and rare writes, contention during reads should be very low.)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
If you can write the data atomically, then you shouldn't need a lock for the readers. If you can't then this[^] might help.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I guess I can't update a std::map atomically
But the link looks good.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hi everybody,
I have a question .How can i print out the source code of my program, after i launch the program.
For example i run the program and it prints out on screen it's own source code ???
Thanks in advance
m0n0
|
|
|
|
|
Use OpenProcess, VirtualQueryEx, and ReadProcessMemory to access the memory. you are probably only interested int he parts of memory marked as MEM_IMAGE, as that contaisn the code. the other parts are other data.
Pass all this data to the disassembler, which will print out the assembly language
|
|
|
|
|
alternativly just have the source included in a text file with your program and just have it print it like any other text file.
|
|
|
|
|
One thing you have to realise is that the program has no idea what it's source code is, you will need to embed the source code as you would any other string, and then you can display it the same as you would any other string.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Not possible, unless you are storing the code as part of the string table resource. The compiler turns the source code into an object file. In turn, the linker turns the object file into an executable. See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I would like my program to run at set times (for example, every minute at the start of the minute, or every 30 seconds, at either the start of the minute or :30). What is the best way to do this. I dont want to use just "Sleep(6000)" or something like that, because after a few runs, it wont be starting at exactly minute:00. How can I solve this problem??
Thank you
Rihannsu
|
|
|
|
|
Sleep for 1 second then when it wakes up look at the system time and see if you want the program to run.
Look at CTime class members.
Elaine
The tigress is here
|
|
|
|
|
Create a waitable timer - CreateWaitableTimer
Calculate the difference between the time you want to run in the future and NOW and then set the waitable timer - SetWaitableTimer.
If you want to run every 'periodic' amount of time, then calcualte that period in milliseconds and set the period when you SetWaitableTimer.
This would be more eficient then sleeping and waking up constantly.
Read MSDN about the waitable timers for their proper usage.
|
|
|
|
|
Rihannsu wrote:
I would like my program to run at set times...
So how about creating a scheduled task to do just that?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Invalid handle issue for a Service application while using GenerateConsoleCtrlEvent
Description:
I have a non GUI application.
I have an issue with GenerateConsoleCtrlEvent while running the application in Service mode.
The following code raised an "invalid handle" error (GetLastError code 6) while running in Service mode:
BOOL res = GenerateConsoleCtrlEvent( CTRL_BREAK_EVENT, dwProcessId );
The same works without any problem when it is run as a console application.
My architecture is something as follows:
I have a partnet process, which creates multiple child processes for executing specific jobs.
In normal case, the child processes finish their jobs and exit gracefully. But some times (e.g. a shutdown), the parent process want to notify the child process to terminate immediately using CTRL_BREAK_EVENT (GenerateConsoleCtrlEvent).
Further, I give the creation flag CREATE_NEW_PROCESS_GROUP while creating the child process.
The child process is a simple console appliction and which has a console handler.
The annoying part is, the above mechanism works smoothly when i run the mother process as console appliction.
I am not sure if this is the case but, my hunch is that the problem occurs because the Service does not have a console (when running as a service). But how do I give console to the Service application and hide it?
Please help me find a way,
Thanks and regards,
|
|
|
|
|
What would be the Print preview methodology for a application like Windows Paint ?
|
|
|
|
|
Would anyone know the difference between
CPaintDc and CClientDc ?
In what scenario is one preferred over the other ?
|
|
|
|
|
The CPaintDC should only be used while handling the OnPaint member function. I am pretty sure the CPaintDc wraps with a BeginPaint and an EndPaint, whereas the CClientDc is prety much safe to create without those two side effects.
|
|
|
|
|
Really had a tough time finding some sample code to achieve the same . Was wondering if someone has a good article that will demonstate this concept !
|
|
|
|
|
I was reading up on Serialization in conjunction with CObject derived classes in the context of the Document View architecture .
The examples that I read were very basic where in serialize they read in or write the data using the >> or << operators .
Say I have a CDocument derived class that contains 10 link lists and i want this info to be persistant how would i write the Serialize routine .
How would my Doc class know where on link list ends and the other begins ?
Is there a mechanism .
The gurus out there can shower some wisdom !
|
|
|
|
|
*** WARNING ***
I whipped up an example in a few minutes so the code is far from tight. However, it should server as a guide to illustrate how to serialize a linked list of objects from an MFC application.
It would be the same as serializing any object in that the document would iterate the linked list and serialize each of the objects.
For example:
* Let's say you have a class called CTest that has a next pointer to support a linked list of CTest objects:
class CTest : public CObject
{
DECLARE_SERIAL(CTest)
public:
CTest(CString strValue);
CTest();
public:
CString m_strValue;
CTest* m_pNext;
public:
void Serialize(CArchive& ar);
};
* You'll note that it's responsible for serializing itself - just as any object. You could do this serialization from the documents Serialize or from any other function that makes sense for your app.
* The CTest class' implementation might look something like this where it is initialized via being serialized:
IMPLEMENT_SERIAL(CTest, CObject, 1)
CTest::CTest()
{
m_strValue = _T("-1");
m_pNext = NULL;
}
CTest::CTest(CString strValue)
{
m_strValue = strValue;
m_pNext = NULL;
}
void CTest::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_strValue;
ar << m_pNext;
}
else
{
ar >> m_strValue;
ar >> m_pNext;
}
}
* As an example of using the document's Serialize (since that's the specific question you had):
void CLinkedListDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ASSERT(m_pHead);
if (m_pHead)
{
for (CTest* pCurr = m_pHead; pCurr != NULL; pCurr = pCurr->m_pNext)
{
pCurr->Serialize(ar);
}
}
}
else
{
m_pHead = new CTest();
m_pHead->Serialize(ar);
CTest* pCurr = m_pHead;
while (pCurr->m_pNext)
{
CTest* pNext = new CTest();
pNext->Serialize(ar);
pCurr->m_pNext = pNext;
pCurr = pNext;
}
}
}
* Several things to note here
* When storing, note how I simply walk the linked list and call the object's Serialize function for each object
* When loading, note how I use the stored CTest::m_pNext member only to tell me that another CTest object is in the file. That way I know to instantiate a blank CTest and then call CTest::Serialize to read in its values until I reach a CTest object that has a m_pNext value of NULL.
Cheers,
Tom Archer - Archer Consulting Group
"So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe
|
|
|
|
|