Hello people this is me again,
I'm making a chat application program, that people can communicate over a computer network or V.P.N. (virtual private network) and when a user clicks the red close button a message box is suppose to show, but does not, here's the code:
#include <windows.h>
#include "stdafx.h"
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "netchat_ad";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME));
wincl.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_NETTYPE), IMAGE_ICON, 16, 16, 0);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName,
"netCommunication - [NET: <none>]",
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
500,
400,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
if (!hwnd) {
MessageBox(0, "Failed to create the window, ending program.", "Handle Error", MB_OK | MB_ICONERROR);
return 2;
}
ShowWindow (hwnd, nCmdShow);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
HFONT font1 = CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Microsoft Sans Serif"));
HFONT font2 = CreateFont(14,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Microsoft Sans Serif"));
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
HWND messagebox, sendmesbutton;
messagebox = CreateWindow(TEXT("edit"), TEXT(""),
WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOVSCROLL | ES_MULTILINE | WS_VSCROLL,
71, 317, 320, 32,
hwnd, (HMENU) 1, NULL, NULL
);
sendmesbutton = CreateWindow(TEXT("button"), TEXT("Send\n(Message)"),
WS_VISIBLE | WS_CHILD | WS_BORDER | BS_MULTILINE,
397, 317, 75, 33,
hwnd, (HMENU) 2, NULL, NULL
);
SendMessage(messagebox,WM_SETFONT,(WPARAM)font2,MAKELPARAM(true,0));
SendMessage(sendmesbutton,WM_SETFONT,(WPARAM)font1,MAKELPARAM(true,0));
break;
case WM_PAINT:
break;
case WM_SETFONT:
break;
case WM_CLOSE:
int mbcce;
mbcce = MessageBox(hwnd, "Are you sure you want to exit the chat and close the session?", "Close Connection", MB_YESNO | MB_ICONINFORMATION);
if (mbcce == IDYES) {
DestroyWindow(hwnd);
} else if (mbcce == IDNO) {
}
break;
case WM_COMMAND:
if (LOWORD(wParam) == 2) {
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
Technically the message box appears because I can hear the dialog pop up and can use the enter or arrow keys to select a command, but the problem I am having is that I cannot see it. I was wondering if you'll can spot my error.
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|