|
If you want to detect whether the session is ending due to a Log-off then you need to handle the WM_QUERYENDSESSION message. The lParam value of the message contains the info of the session end state.
Michael
CP Blog [^]
|
|
|
|
|
The problem here is that you can not use the functions OnEndSession and OnQueryEndSession as they do not get the lParam passed through from the MFC message handler.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
This is not that straight forward. The flags that are sent are in the LPARAM of the message but are not directly accessable from the OnEndSession virtual function.
If you override the MFC message handler you can check the LPARAM for ENDSESSION_LOGOFF.
LRESULT CALLBACK CMainFrame::NewMsgHandlerFn(HWND hWnd,UINT uMsg,WPARAM wParam, LPARAM lParam)
{
if( uMsg == WM_ENDSESSION )
{
if( lParam & ENDSESSION_LOGOFF )
{
return true;
}
}
return CallWindowProc(s_pOldMsgHandler,hWnd,uMsg,wParam,lParam);
}
I hope that helps.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Its been a while since I did any MFC but can't you just
ON_MESSAGE(WM_ENDSESSION, OnMyEndSession)
and
LRESULT OnMyEndSession(WPARAM wParam, LPARAM lParam)
{
return 1;
}
Michael
CP Blog [^]
|
|
|
|
|
That is a very good point. I seem to have over complicated the situation.
Aw, well at least it is an exercise in subclassing.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
That is a very good point. I seem to have over complicated the situation.
You know me, if there is an quick, easy way to do something I'll use it. Subclassing is just too much like hard-work. Thats why I use C# now, less work to do.
Michael
CP Blog [^]
|
|
|
|
|
WOW!
both the solution worked
but i decide to go with the easier solution...
i handle WM_ENDSESSION message on log-off and shut down seperately.
well, thnx all
|
|
|
|
|
Tried to incorporate the function suggested by u.
there is a compile error in
CallWindowProc(s_pOldMsgHandler,hWnd,uMsg,wParam,lParam);
Error:::'s_pOldMsgHandler':undeclared identifier
will u please elaborate the callback function and also the idenfifier 's_pOldMsgHandler'
|
|
|
|
|
Sorry,
s_pOldMsghandler is defined.
static PMSGHANDLERFN s_pOldMsgHandler;
then in the .cpp
PMSGHANDLERFN CMainFrame::s_pOldMsgHandler;
Subclass the message handler in a Subclass function
void CMainFrame::Subclass()
{
:
s_pOldMsgHandler = (PMSGHANDLERFN)SetWindowLong(m_hWnd,GWL_WNDPROC,(LONG)NewMsgHandlerFn);
:
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
HI~
Is there any function in eVC++ which can pass some parameters to a running C# program?
"CreateProcess" can pass some parameters as a argument when a process start. However, how about the process is running?
Thanks~
|
|
|
|
|
If you look for IPC and/or Interprocess Communication this should help you out.
Sorry forgot to say: If you look in the eVC++ help that is!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I don`t know if this is THE way to pass data, but in my case I`
use shared memory... And protect access by a global mutex
Check out the funcs
CreateFileMapping to create the shared mem portion and
MapViewOfFile to get access to the mem portion, and use a named
mutex to prevent read-write errors between apps.
`Hope this helps,
Davy
|
|
|
|
|
Hi. I try to connect to a Microsoft SQL database using Ole Db - IRowSet interface. This works, but I can't bind it to a grid control (I use Microsoft Datagrid control).
I have:
IRowset* pRowset;
DDX_Control(pDX, IDC_DATAGRID1, m_grid);
........................................
I try to bind by
m_grid.SetRefDataSource((LPUNKNOWN)pRowset);
but it raises an exception : Type mismatch.
Well, I tried - I suppose . Could someone help me?
Gabi
|
|
|
|
|
hi all,
i have converted a Form view based application to cview now im facing an error when i run the application the error is "failed to create empty document". please do reply . thanks in advance
Haseeb Ahmed
|
|
|
|
|
It could be one of many things. The only way to succesfully solve these problems is to put a breakpoint at the beginning on the InitInstance method and step through the code until the error is thrown.
Michael
CP Blog [^]
|
|
|
|
|
i have a log file which is a MS-access database. i have the following problem:-
1. wat is the name of the MS-access driver so that i can package it with my application and it can run on any machine irrespective of whether that machine has MS-access installed or not?
2. my log size increases very quickly. i want to rotate the log(i.e, something like syslog in Linux which rotates log weekely)
wat should i do?
|
|
|
|
|
Anonymous wrote:
wat is the name of the MS-access driver...
Look at the Drivers tab on the ODBC Data Source Administrator dialog. It shows:
Microsoft Access Driver (*.mdb)
Anonymous wrote:
2. my log size increases very quickly. i want to rotate the log...
Add a date/time field to the table, and index it. Periodically run through the rows, deleting those that have "expired."
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I dont know much but... "Ms Access uses JET DATABASE DRIVER". You use ODBC which acts as an interface between your application and JET
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
I have developed activex control in MFC. It is text control with additional features.
I am testing it in VB.
Design time properties are getting set.
When I try to set the properties at run time and execute the application I am getting the following error.
If I try to access text property
error is as follows
Method text of object '_DoleEdit' failed
|
|
|
|
|
i have a function IsAdministrator() which tells me whether i the administrator or not(i.e, i have administrative rights). Now i want to include this code in my dialog based application so that only the administrator can run the application. I tried to include it in the InitDialog() but it did not work. Should i put it in the constructor?
|
|
|
|
|
|
put it in InitInstance method of your CWinApp derived class
InitInstance()
{
...
if(IsAdministrator())
{
CMyDialog dlg;
dlg.DoModal();
}
else
{
AfxMessageBox("Your not an admin");
}
return FALSE;
}
|
|
|
|
|
Anonymous wrote:
...but it did not work.
Which tells us nothing. Do you get a compiler, linker, or run-time error? Does an assertion fire? Is an exception thrown? Does the function not produce the desired result? Have you single-stepped through the code to see what specific line fails? Be just a tad more specific.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am converting some of our projects from Visual Studio 6 to Visual Studio 2003
I have found that the following code gives different results from these compilers
In VS6 "Josh" is printed. in VS2003 nothing is printed.
If I trace into c_str() I can see that the correct pointer is returned to s. However between the call to TestFn() and printf the destructor of stl::string is called. This is for the temp object created when returning from TestFn(). In VS2003 a '\0' is inserted at the fist element in the buffer by this destructor. In VS6 this does not happen.
In VS2003 If I use the memory viewer I can see that s points to a \'0' followed by 'o' 's' 'h' '\0';
In VS6 the same things points to 'J' 'o' 's' 'h' '\0'
Can anyone explain why this is happening?
#include "stdafx.h"
#include <string>
using namespace std;
string globalString = "Josh";
string TestFn()
{
return globalString;
}
int main(int argc, char* argv[])
{
const char * s = TestFn().c_str();
printf(s);
return 0;
}
|
|
|
|
|
Your code is buggy.
TestFn is returning a string object. In your main routine you are getting the const char * of the returned string. Then the string is going out of scope and the memory is being deleted. Finally you do a printf on a pointer that now points to trash.
It worked on VC6 out of luck.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|