|
The OnOK(), OnCancel() and OnClose() functions are merly handlers for messages that gets sent when your button (I am assuming these are linked to a button) gets pressed. The previous poster mentioned creating a handler function for the WM_ENDSESSION message. This could be one possible solution to your problem.
My solution uses the fact that the WinApp::ExitInstance() function gets called whenever the user choses to exit their windows session.
Every MFC application should have a WinApp derived class, called something like MyProgApp, or something similar with the App appended to your class name.
Now this function isn't visible by default, so you need to override this function using the Classwizard (if using VS6), or the properties window (if using VS7.1).
You can then write your logging code within the function, but remember to call the base class at the end (or your app won't exit).
int CMyApp::ExitInstance()
{
delete m_pVarA;
delete m_pVarB;
::CoUninitialize();
return CWinApp::ExitInstance();
}
I Dream of Absolute Zero
|
|
|
|
|
The system sends the message, so all you have to do is capture that message and then do your stuff.
( return FALSE after a WM_QUERYENDSESSION is received and then capture the WM_ENDSESSION and check if system is really shutting down and do your stuff before returning from this message...
Greetings,
Davy
|
|
|
|
|
Ok,
And where do I make that check?
|
|
|
|
|
Something like this will help
Mainfrm header file
protected:
afx_msg LRESULT OnMyEndSession(WPARAM wParam, LPARAM lParam);
Mainfrm cpp file
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
:
ON_MESSAGE(WM_ENDSESSION, OnMyEndSession)
:
END_MESSAGE_MAP()
LRESULT CMainFrame::OnMyEndSession(WPARAM wParam, LPARAM lParam)
{
if (lParam & ENDSESSION_LOGOFF)
{
:
:
}
else
{
}
return 0;
}
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 Walliams (Little Britain)
|
|
|
|
|
Thanks it works greate.
|
|
|
|
|
Can I wait for Data to be available on a pipe? Peek & Poll works, but I'd rather have a true wait (since I'm waiting for "either data on pipe, or kill event")
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Yes, I found this in MSDN under "Synchronization Objects":
In some circumstances, you can also use a file, named pipe, or communications device as a synchronization object; however, their use for this purpose is discouraged. Instead, use asynchronous I/O and wait on the event object set in the OVERLAPPED structure. It is safer to use the event object because of the confusion that can occur when multiple simultaneous overlapped operations are performed on the same file, named pipe, or communications device. In this situation, there is no way to know which operation caused the object's state to be signaled.
|
|
|
|
|
Hello All,
Can some one tell me the Win32 API fn() or fn()'s used to calculate the bandwidth consumption of our computer. I am on NT platform and using VC++6.0 compiler.
Thnx in Advance
Comboy2080
|
|
|
|
|
Do you mean Network Percentage Utilisation?
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 Walliams (Little Britain)
|
|
|
|
|
Can u plz tell me fn() which retrives packets sent and received information which is displayed in the Local Area Connection Setup (which is in the task bar in the right hand side corner).
Thnx in Advance
Comboy2080
|
|
|
|
|
If you want to analyse packets to and from your PC take a look at WinPCap[^]
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 Walliams (Little Britain)
|
|
|
|
|
Hi,
the Win32 API fn() ??? No function avilable..
|
|
|
|
|
comboy2080 wrote:
Can some one tell me the Win32 API fn() or fn()'s used to calculate the bandwidth consumption of our computer. I am on NT platform and using VC++6.0 compiler.
yeah there are some Good IPhelper Api's presents in the VC++ enviornment
Look in Index of MSDN for iphlpapi Module
or Here is the required Function that will help you
-->GetIfTable
or you can look for firewall Implementation by SUdhir MAngla at Cp.search for article by author for Sudhir Mangla
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello everyone
What is the defference about _T("abc") and "abc"? Thank you.
-Freehawk
|
|
|
|
|
_T("abc") translate "abc" to unicode on unicode builds and remain "abc" on non unicode builds, see tchar.h
hope that helps, regards
|
|
|
|
|
As well as the above reply, you can also read this[^] article for a more detailed explanation (and other vital info on strings).
I Dream of Absolute Zero
|
|
|
|
|
Hi,
I need to modify a 16 color bmp and then save it as a seperate file. I loaded a 16 color 48x48 bmp file on DC using the LoadImage() and BitBlt() API. Using GDI functions, I change the display on the DC, say draw a line on the DC, on top of the image displayed. Now I need to capture the current DC ( bmp image + the changes,i.e., the line) and create a new BMP file.
For 256 color and 16 color BMP file, the new BMP created is a plain white imgage, if I load the image with 'LR_CREATEDIBSECTION' flag in LoadImage API. else I get am able to create the file, but the image size is different. For the 24 bpp the application is working fine. Where am i doing wrong. I am using the 'CreateCompatibleBitmap()' to create the bitmap from DC. Is there any other way?.
<br />
HBITMAP hBMP;<br />
RECT r;<br />
GetClientRect(GetDlgItem(hWnd,IDC_STATIC_1),&r);<br />
HDC memDC = CreateCompatibleDC ( pDC );<br />
hBMP = (HBITMAP)LoadImage(hResDll ,filename,IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);<br />
SelectObject ( memDC, hBMP );<br />
BitBlt(pDC,r.left ,r.top ,imgWidth,imgHeight ,memDC,0,0,SRCCOPY);<br />
DeleteObject(hBMP);
..............................
To capture the modified BMP from DC
.............................
<br />
RECT rc;<br />
GetClientRect(GetDlgItem(hWndDlg,IDC_STATIC_1),&rc);<br />
HDC hScreenDC = GetWindowDC(GetDlgItem(hWndDlg,IDC_STATIC_1)); <br />
HDC hmemDC = CreateCompatibleDC(hScreenDC); <br />
int ScreenWidth = rc.right;<br />
int ScreenHeight = rc.bottom;<br />
HBITMAP hmemBM = CreateCompatibleBitmap(hScreenDC, ScreenWidth ,ScreenHeight );<br />
SelectObject(hmemDC, hmemBM);<br />
bufLen= filesize;<br />
HGLOBAL hpxldata = GlobalAlloc(GMEM_FIXED ,imgWidth * imgHeight * 3 ); <br />
void * lpvpxldata = GlobalLock(hpxldata);<br />
<br />
BITMAPINFO bmInfo;<br />
bmInfo.bmiHeader.biSize = 40;<br />
bmInfo.bmiHeader.biWidth = imgWidth;<br />
bmInfo.bmiHeader.biHeight = imgHeight;<br />
bmInfo.bmiHeader.biPlanes = 1;<br />
bmInfo.bmiHeader.biBitCount = 24;<br />
bmInfo.bmiHeader.biCompression = 0;<br />
bmInfo.bmiHeader.biSizeImage = 0;<br />
bmInfo.bmiHeader.biXPelsPerMeter = 0;<br />
bmInfo.bmiHeader.biYPelsPerMeter = 0;<br />
bmInfo.bmiHeader.biClrUsed = 0;<br />
bmInfo.bmiHeader.biClrImportant = 0;<br />
BITMAPFILEHEADER bmFileHeader;<br />
bmFileHeader.bfType = 19778;<br />
bmFileHeader.bfSize = filesize; <br />
bmFileHeader.bfReserved1 = 0;<br />
bmFileHeader.bfReserved2 = 0;<br />
bmFileHeader.bfOffBits = 54;<br />
StretchBlt(hmemDC,0 ,0 ,imgWidth ,imgHeight,hScreenDC,0,0,ScreenWidth,ScreenHeight ,SRCCOPY);<br />
int nret = GetDIBits(hmemDC, hmemBM, 0, imgHeight, lpvpxldata, &bmInfo, DIB_RGB_COLORS);<br />
<br />
<br />
ImgBuffer = (void*)malloc(bufLen); <br />
memset(ImgBuffer, 0, bufLen); <br />
memcpy((char*)ImgBuffer, (char*)&bmFileHeader,14);<br />
memcpy((char*)ImgBuffer + 14, (char*)&bmInfo, 40);<br />
memcpy((char*)ImgBuffer+54, (char*)lpvpxldata,bufLen - 54); <br />
FILE *fn = fopen("e:\\vinaya\\testimg.bmp","w"); <br />
fn = fopen("e:\\NewImg.bmp","w");<br />
fwrite((char*) ImgBuffer ,sizeof(char), filesize, fn);<br />
fclose(fn);<br />
fn = NULL;<br />
<br />
int i = GlobalUnlock(hpxldata);<br />
DWORD size = GlobalSize(hpxldata);<br />
HGLOBAL h = GlobalFree(hpxldata);<br />
DeleteObject(hmemBM);<br />
DeleteDC(hmemDC);<br />
ReleaseDC(0,hScreenDC);<br />
return ;
The new image need to be same in file size, resolution, bpp except the modification in image data. Kindly help.
Thanks
~Vini
|
|
|
|
|
I want to change a menu item, if i click over "Pause" it must appear "Run", for example.
But how can i do this?
Thanks.
|
|
|
|
|
Assuming you are using MFC. Add a handler for the OnUpdate of the menu item. You will also need a state flag of some kind (say a bool m_bIsRunning)
So you will have something like
void CMyDoc::OnUpdateMenuItem(CCmdUI* pCmdUI)
{
:
if (m_bIsRunning)
pCmdUI->SetText(_T("Pause"));
else
pCmdUI->SetText(_T("Run"));
:
}
NOTE: You need to toggle m_bRunning when you select the menu item.
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 Walliams (Little Britain)
|
|
|
|
|
an activeX control acess the oracle by ODBC interface,such as a windows application.coun't it realize? if can ,tell me how to do,Thanks a lot !!
|
|
|
|
|
|
How can, to you too.
I Dream of Absolute Zero
|
|
|
|
|
Hi,,,

|
|
|
|
|
what do u want buddy
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
First. I appreciate that you spend your time to read my question.
I have question about how to define an object array at private area.
For example: I have a class which is call base_class; I want to create a new class which is called
new_class; But I want to define base_class[50] in my new class. Could someone help me?
The following code is what I define in my new class;
class new_class
{
public:
// define some public function here.
private:
base_class datause[50];
};
I got wrong message when I create new_class object in my main program.
|
|
|
|
|