Click here to Skip to main content
12,403,811 members (71,392 online)

C / C++ / MFC

 
AnswerRe: Sql server Database BackUp Pin
André Kraak16-Nov-12 0:48
memberAndré Kraak16-Nov-12 0:48 
QuestionNeed help compiling Pin
xLeonx15-Nov-12 8:51
memberxLeonx15-Nov-12 8:51 
AnswerRe: Need help compiling Pin
jeron115-Nov-12 9:51
memberjeron115-Nov-12 9:51 
QuestionRe: Need help compiling Pin
DavidCrow15-Nov-12 10:34
memberDavidCrow15-Nov-12 10:34 
QuestionRe: Need help compiling Pin
CPallini15-Nov-12 23:09
mvpCPallini15-Nov-12 23:09 
AnswerRe: Need help compiling Pin
xLeonx18-Nov-12 9:35
memberxLeonx18-Nov-12 9:35 
AnswerRe: Need help compiling Pin
Stephen Hewitt16-Nov-12 22:36
memberStephen Hewitt16-Nov-12 22:36 
GeneralRe: Need help compiling Pin
xLeonx18-Nov-12 9:31
memberxLeonx18-Nov-12 9:31 
GeneralRe: Need help compiling Pin
xLeonx18-Nov-12 9:33
memberxLeonx18-Nov-12 9:33 
AnswerRe: Need help compiling Pin
Arun S J18-Nov-12 18:15
memberArun S J18-Nov-12 18:15 
GeneralRe: Need help compiling Pin
xLeonx23-Nov-12 8:20
memberxLeonx23-Nov-12 8:20 
GeneralRe: Need help compiling Pin
Arun S J25-Nov-12 17:37
memberArun S J25-Nov-12 17:37 
QuestionVisual Studio 2003 on Windows 8! Pin
Hadi Dayvary15-Nov-12 4:23
memberHadi Dayvary15-Nov-12 4:23 
Question[RESOLVED] Message Box will not show on top of window Pin
Brandon T. H.15-Nov-12 1:14
memberBrandon T. H.15-Nov-12 1:14 
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"

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
 
/*  Make the class name into a global variable  */
char szClassName[ ] = "netchat_ad";
 
int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
 
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);
 
    /* Use default icon and mouse-pointer */
    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;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
 
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;
 
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "netCommunication - [NET: <none>]",       /* Title Text */
           WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           500,                 /* The programs width */
           400,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
 
           if (!hwnd) {
           MessageBox(0, "Failed to create the window, ending program.", "Handle Error", MB_OK | MB_ICONERROR);
           return 2;
           }
 
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);
 
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }
 
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}
 

/*  This function is called by the Windows function DispatchMessage()  */
 
    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)                  /* handle the messages */
    {
        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) { /* When the message box button is clicked, try to send the message. */
 
            }
 
            break;
 
        case WM_DESTROY:
			PostQuitMessage(0);
			break;
        default:                      /* for messages that we don't deal with */
            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

AnswerRe: Message Box will not show on top of window Pin
Richard MacCutchan15-Nov-12 3:16
mvpRichard MacCutchan15-Nov-12 3:16 
GeneralRe: Message Box will not show on top of window Pin
Brandon T. H.15-Nov-12 8:13
memberBrandon T. H.15-Nov-12 8:13 
GeneralRe: Message Box will not show on top of window Pin
Richard MacCutchan15-Nov-12 23:42
mvpRichard MacCutchan15-Nov-12 23:42 
GeneralRe: Message Box will not show on top of window Pin
Brandon T. H.17-Nov-12 4:30
memberBrandon T. H.17-Nov-12 4:30 
AnswerRe: [RESOLVED] Message Box will not show on top of window Pin
Arun S J18-Nov-12 20:16
memberArun S J18-Nov-12 20:16 
QuestionUsing make file Pin
HungryCPPDev15-Nov-12 0:55
memberHungryCPPDev15-Nov-12 0:55 
AnswerRe: Using make file Pin
Jochen Arndt15-Nov-12 2:20
memberJochen Arndt15-Nov-12 2:20 
Questionhow to create an Un-sorted map in c++ Pin
narmada Padhy14-Nov-12 18:04
membernarmada Padhy14-Nov-12 18:04 
AnswerRe: how to create an Un-sorted map in c++ Pin
Richard MacCutchan14-Nov-12 21:01
mvpRichard MacCutchan14-Nov-12 21:01 
AnswerRe: how to create an Un-sorted map in c++ Pin
Stephen Hewitt14-Nov-12 22:57
memberStephen Hewitt14-Nov-12 22:57 
AnswerRe: how to create an Un-sorted map in c++ Pin
Arun S J18-Nov-12 18:20
memberArun S J18-Nov-12 18:20 
NewsSoftware Engineer (C++) needed in Singapore!! Pin
darkxfire14-Nov-12 17:39
memberdarkxfire14-Nov-12 17:39 
GeneralRe: Software Engineer (C++) needed in Singapore!! Pin
Arun S J18-Nov-12 18:27
memberArun S J18-Nov-12 18:27 
QuestionError MSB6006: "CL.exe" Pin
john563213-Nov-12 22:41
memberjohn563213-Nov-12 22:41 
QuestionRe: Error MSB6006: "CL.exe" Pin
DavidCrow14-Nov-12 3:23
memberDavidCrow14-Nov-12 3:23 
QuestionUDP ports 500 and 4500 are busy? Pin
v_iv13-Nov-12 18:46
memberv_iv13-Nov-12 18:46 
AnswerRe: UDP ports 500 and 4500 are busy? Pin
Richard MacCutchan13-Nov-12 22:34
mvpRichard MacCutchan13-Nov-12 22:34 
QuestionI am Bemused about std::list<> Pin
yu-jian13-Nov-12 4:17
groupyu-jian13-Nov-12 4:17 
AnswerRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 5:37
mvpRichard MacCutchan13-Nov-12 5:37 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 6:03
memberStephen Hewitt13-Nov-12 6:03 
GeneralRe: I am Bemused about std::list<> Pin
yu-jian13-Nov-12 6:25
groupyu-jian13-Nov-12 6:25 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 6:38
mvpRichard MacCutchan13-Nov-12 6:38 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 15:04
memberStephen Hewitt13-Nov-12 15:04 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 20:59
mvpRichard MacCutchan13-Nov-12 20:59 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt13-Nov-12 23:54
memberStephen Hewitt13-Nov-12 23:54 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 23:58
mvpRichard MacCutchan13-Nov-12 23:58 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt14-Nov-12 0:58
memberStephen Hewitt14-Nov-12 0:58 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 1:30
mvpRichard MacCutchan14-Nov-12 1:30 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt14-Nov-12 2:06
memberStephen Hewitt14-Nov-12 2:06 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 2:26
mvpRichard MacCutchan14-Nov-12 2:26 
GeneralRe: I am Bemused about std::list<> Pin
Stephen Hewitt14-Nov-12 2:30
memberStephen Hewitt14-Nov-12 2:30 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 3:36
mvpRichard MacCutchan14-Nov-12 3:36 
GeneralRe: I am Bemused about std::list<> Pin
DavidCrow14-Nov-12 3:16
memberDavidCrow14-Nov-12 3:16 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan14-Nov-12 3:32
mvpRichard MacCutchan14-Nov-12 3:32 
GeneralRe: I am Bemused about std::list<> Pin
yu-jian13-Nov-12 6:25
groupyu-jian13-Nov-12 6:25 
GeneralRe: I am Bemused about std::list<> Pin
Richard MacCutchan13-Nov-12 6:43
mvpRichard MacCutchan13-Nov-12 6:43 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 28 Jul 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid