|
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
|
|
|
|
|
|
Anonymous wrote:
Say I have a CDocument derived class that contains 10 link lists...
Are those CList objects?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I'm updating a MFC app by, among other things, adding a second dockable toolbar to it. Its original toolbar has been there a long time and it works fine: in particular, if you move it around in the frame and close the application, it turns up in the same location you left it the next time the application is opened again. (Its information is preserved and retrieved with a single pair of SaveBarState and LoadBarState calls.)
Not wanting to meddle with what works, I created the second toolbar by basically copying the code which implemented the first. It gets created at the same point in code, with the same properties, in the same way. By and large it works well, but it falls down in one important respect; the new toolbar always appears docked in the upper left corner position whenever the application starts up, even if you moved it somewhere else.
Has anyone else experienced this? Do SaveBarState and LoadBarState have some limitation with multiple toolbars I don't know about? Or is there some better mechanism for managing these which I don't know about?
Ron Ritchie
|
|
|
|
|
It may be a problem with your toolbar IDs. MFC uses the constant AFX_IDW_TOOLBAR for the main toolbar ID. It also uses a couple of successive IDs for things like the status bar, dialog bar, etc.
I would try setting the ID of the 2nd toolbar to AFX_IDW_TOOLBAR + 20 or something similar. (pass the ID via the CToolBar::Create call)
If you search the vc++ folder for AFX_IDW_TOOLBAR, you should see all the defines/constants I'm referring to.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
That was very helpful. It didn't solve the whole problem, but knowing to search for that toolbar ID proved the key to solving the rest. Thanks!
Ron Ritchie
|
|
|
|
|
Hi Everyone!
I have a problem! How can I run an EXE directly from memory?
Thanks for any reply!
|
|
|
|
|
Yeah you can... but you have to implement your own PE loader.
That's quite difficult so I propose that you dump the exe file to the disk and execute it the normal way.
Don't try it, just do it!
|
|
|
|
|
Why did you want to run your application in memory?
It's not a normal operation. Don't do this..
---------------------------
Auto Debug for Windows
http://www.autodebug.com/
|
|
|
|
|
Does anyone know a discussion of the actual overhead imposed by using a SetWindowsHookEx(WH_CALLWNDPROC / WH_CALLWNDPROCRET) for a single thread?
I'm currently writing a test app for my specific case, but I'd be interested in what others have to say.
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
|
|
|
|
|
Hello,
Just a short question really. Could anyone either tell me how or give me a link to a webpage that explains how you turn an image using DirectDraw.
Thanks
|
|
|
|
|
Hi,
How to get the name of the treeview node.
on clicktree event. if anybody knows pls let me know .
Regards
Chezhian
|
|
|
|
|
How do you name the node ?
If you have the handle you can issue no of treeview events to get the inforormation.
-prakash
|
|
|
|
|
hi,
i got it by
the following code
HTREEITEM hSelectItem=GetTreeCtrl().GetSelectedItem();
CString itemname=GetTreeCtrl().GetItemText(hSelectItem);
Thanks for ur reply.
|
|
|
|
|
I have created a C++ application WinMain( non-MFC). I included the following code to gather some information.
#########
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "\"C:\\Program Files\\MyProgram\\info.exe \"";
ShExecInfo.lpParameters = "/nfo c:\\temp\\info.txt";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
################
because it takes a while (4-5 mins), the user does not know if the application is running or doing anything at all.
How to display a message "Please wait...etc" while the process is running?
I tried messagebox bot the user must click OK and still has no idea if the app still running?
thanx for any adviced.
|
|
|
|
|
Perhaps you can create a modeless dialog box instead?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Hi all,
This is roland working for s/w comp in pune as trainee programmer in SDK (win 32)as i don't have preiveious experience in sdk i am getting some problem.....so can anybody help me....my project is related to desktop & printing ...when user selects a perticular area on desktop or on screen he should get only that area after printing ..
i am getting the selected image on screen but after taking print for it the colors of that image are not appear as they are on screen i am getting very light colors image....i tried lots for this but i didn't get it...i got one API ColorMatchToTarget But where should it place or is it really work for this ???so can anybody help me & guiide me plz???
thks waiting for reply.......
roland
|
|
|
|