Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why wifstream can not read in numbers? Pin
transoft2-Nov-09 1:35
transoft2-Nov-09 1:35 
GeneralRe: Why wifstream can not read in numbers? Pin
«_Superman_»2-Nov-09 4:06
professional«_Superman_»2-Nov-09 4:06 
GeneralRe: Why wifstream can not read in numbers? [modified] Pin
transoft2-Nov-09 5:24
transoft2-Nov-09 5:24 
QuestionExit Message Box Pin
MrMcIntyre1-Nov-09 8:56
MrMcIntyre1-Nov-09 8:56 
AnswerRe: Exit Message Box Pin
«_Superman_»1-Nov-09 9:24
professional«_Superman_»1-Nov-09 9:24 
GeneralRe: Exit Message Box [modified] Pin
MrMcIntyre1-Nov-09 9:33
MrMcIntyre1-Nov-09 9:33 
GeneralRe: Exit Message Box Pin
«_Superman_»1-Nov-09 9:46
professional«_Superman_»1-Nov-09 9:46 
GeneralRe: Exit Message Box Pin
MrMcIntyre1-Nov-09 9:57
MrMcIntyre1-Nov-09 9:57 
Hi. I think I've done something wrong somewhere.

#include <windows.h><br />
<br />
//Global Definitions<br />
#define WINDOW_WIDTH 1040<br />
#define WINDOW_HEIGHT 750<br />
<br />
//Global Variables<br />
const char lpClassName[] = "My Project";<br />
HWND mainWindow;<br />
<br />
//Function Declarations<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)<br />
{<br />
	//Create The Window Class<br />
	WNDCLASSEX wc;<br />
	wc.style = CS_VREDRAW | CS_HREDRAW;<br />
	wc.lpszMenuName = NULL;<br />
	wc.lpszClassName = lpClassName;<br />
	wc.lpfnWndProc = WindowEvent;<br />
	wc.hInstance = hInstance;<br />
	wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
	wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);<br />
	wc.cbWndExtra = 0;<br />
	wc.cbSize = sizeof(wc);<br />
	wc.cbClsExtra = 0;<br />
<br />
	//Register The Windows Class<br />
	RegisterClassEx(&wc);<br />
<br />
	//Create the Window<br />
	mainWindow = CreateWindowEx(<br />
		NULL,<br />
		lpClassName,<br />
		"My Project",<br />
		WS_OVERLAPPEDWINDOW | WS_VISIBLE,<br />
		(GetSystemMetrics(SM_CXSCREEN) / 2) - (WINDOW_WIDTH / 2),<br />
		(GetSystemMetrics(SM_CYSCREEN) / 2) - (WINDOW_HEIGHT / 2),<br />
		WINDOW_WIDTH,<br />
		WINDOW_HEIGHT,<br />
		NULL,<br />
		NULL,<br />
		hInstance,<br />
		NULL<br />
		);<br />
<br />
	//Make Sure The Window Was A Success<br />
	if (!mainWindow)<br />
		return 0;<br />
<br />
	//Update the Window<br />
	UpdateWindow(mainWindow);<br />
<br />
	//The Main Loop<br />
	MSG msg;<br />
<br />
	while (1)<br />
    {<br />
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
        {<br />
            if (msg.message == WM_QUIT)<br />
                TranslateMessage(&msg);<br />
            DispatchMessage(&msg);<br />
        }<br />
    }<br />
    return (int) msg.wParam;<br />
}<br />
//Callback Function (WindowEvent)<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
    switch (message)<br />
    {<br />
        case WM_CLOSE:<br />
    if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))<br />
        DestroyWindow(hwnd);<br />
<br />
    return 0;<br />
        break;<br />
    }<br />
    return DefWindowProc(hWnd, message, wParam, lParam);<br />
}


Andrew McIntyre

GeneralRe: Exit Message Box Pin
«_Superman_»1-Nov-09 10:00
professional«_Superman_»1-Nov-09 10:00 
GeneralRe: Exit Message Box Pin
MrMcIntyre1-Nov-09 10:04
MrMcIntyre1-Nov-09 10:04 
GeneralRe: Exit Message Box Pin
MrMcIntyre1-Nov-09 10:48
MrMcIntyre1-Nov-09 10:48 
GeneralRe: Exit Message Box Pin
hxhl951-Nov-09 13:16
hxhl951-Nov-09 13:16 
GeneralRe: Exit Message Box Pin
David Crow2-Nov-09 2:58
David Crow2-Nov-09 2:58 
GeneralRe: Exit Message Box Pin
MrMcIntyre2-Nov-09 10:52
MrMcIntyre2-Nov-09 10:52 
AnswerRe: Exit Message Box Pin
David Crow2-Nov-09 10:54
David Crow2-Nov-09 10:54 
GeneralRe: Exit Message Box [modified] Pin
MrMcIntyre2-Nov-09 10:59
MrMcIntyre2-Nov-09 10:59 
QuestionRe: Exit Message Box Pin
David Crow2-Nov-09 11:04
David Crow2-Nov-09 11:04 
AnswerRe: Exit Message Box Pin
MrMcIntyre2-Nov-09 11:26
MrMcIntyre2-Nov-09 11:26 
GeneralRe: Exit Message Box Pin
MrMcIntyre2-Nov-09 11:28
MrMcIntyre2-Nov-09 11:28 
GeneralRe: Exit Message Box Pin
David Crow2-Nov-09 16:43
David Crow2-Nov-09 16:43 
Questionmaking calculator using MFC c++ Pin
goutom roy1-Nov-09 8:19
goutom roy1-Nov-09 8:19 
AnswerRe: making calculator using MFC c++ Pin
«_Superman_»1-Nov-09 8:47
professional«_Superman_»1-Nov-09 8:47 
AnswerRe: making calculator using MFC c++ Pin
CPallini1-Nov-09 9:59
mveCPallini1-Nov-09 9:59 
AnswerRe: making calculator using MFC c++ Pin
David Crow2-Nov-09 3:03
David Crow2-Nov-09 3:03 
Questionfilehandling Pin
khomeyni1-Nov-09 5:36
khomeyni1-Nov-09 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.