Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need program in C++ that will ignore the Alt+F4 function

Status
Not open for further replies.

C++

Junior Member level 3
Joined
Oct 12, 2004
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
243
Ignoring Alt+f4

I need to adjust my program so that it ONLY exits by pressing the exit button, can someone give me a code that'll capture Alt+F4 and other stuff like that so i can pop up a message box saying to exit using the exit option?

Language: C++
Platform: Windows (XP)
 

Re: Ignoring Alt+f4

You may not remove the Control-Box exit command to preserve windows interface.

If you are using MFC, override the OnClose function for the main window, the default implementation calls DestroyWindow ... you can make any closeout procedures before calling Destroy....

If you are not using MFC, keep track on the WM_CLOSE event ...
 

Re: Ignoring Alt+f4

I dont know the windows API, dont know MFC either. My program's in console mode....I remember there was a boolean function that captured Alt+F4, Ctrl+C and stuff like that, I just can't find it. . .and I really need that function cuz the program's got critical data that must be saved before closing
 

Re: Ignoring Alt+f4

.... within you WndProc function ... include a handler for WM_CLOSE message ...

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_CLOSE:
' DO SOMETHING HERE
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
 

    C++

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top