Advertisement
Guest User

menu displays incorrectly on window

a guest
Jan 3rd, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.29 KB | None | 0 0
  1. MainWindow::MainWindow(HINSTANCE hInstance, int nCmdShow) {
  2.   //register window class
  3.   ZeroMemory(&wc, sizeof(wc));
  4.   wc.cbSize        = sizeof(WNDCLASSEX);
  5.   wc.style         = 0;
  6.   wc.lpfnWndProc   = WndProc;
  7.   wc.cbClsExtra    = 0;
  8.   wc.cbWndExtra    = 0;
  9.   wc.hInstance     = hInstance;
  10.   wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  11.   wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
  12.   wc.lpszMenuName  = NULL;
  13.   wc.lpszClassName = "MainWindow";
  14.   wc.hIcon  = NULL;
  15.   wc.hIconSm  = NULL;
  16.   if(!RegisterClassEx(&wc)) {
  17.     MessageBox(NULL, "Window Registration Failed!", "Error", MB_ICONEXCLAMATION|MB_OK);
  18.     exit(0);
  19.   }
  20.  
  21.   //create dependancies
  22.   font = CreateFont(-11, 0, 0, 0, 400, FALSE, FALSE, FALSE, 1, 400, 0, 0, 0, ("Ms Shell Dlg"));
  23.   HMENU hMainMenu = CreateMenu();
  24.   HMENU hFileMenu = CreatePopupMenu();
  25.   AppendMenu(hMainMenu, MF_STRING|MF_POPUP|MF_MENUBREAK, (UINT_PTR)hFileMenu, ("File"));
  26.   AppendMenu(hFileMenu, MF_STRING, 301, ("New Game"));
  27.   AppendMenu(hFileMenu, MF_STRING, 302, ("Save Game"));
  28.   AppendMenu(hFileMenu, MF_STRING, 303, ("Load Game"));
  29.   AppendMenu(hFileMenu, MF_STRING, 304, ("Quit"));
  30.   HMENU hHelpMenu = CreatePopupMenu();
  31.   AppendMenu(hMainMenu, MF_STRING|MF_POPUP|MF_MENUBREAK, (UINT_PTR)hHelpMenu, ("Help"));
  32.   AppendMenu(hHelpMenu, MF_STRING, 305, ("About"));
  33.  
  34.   //create window and populate controls
  35.   main_win = CreateWindowEx(WS_EX_DLGMODALFRAME, "MainWindow", "Landing Party", WS_CAPTION|WS_POPUPWINDOW, 200, 200, 741, 555, 0, hMainMenu, hInstance, 0);
  36.   HWND hCtrlStcDisplay = CreateWindowEx(WS_EX_STATICEDGE, WC_STATIC, (""), WS_VISIBLE | WS_CHILD | WS_GROUP | SS_LEFT, 6, 7, 600, 465, main_win, (HMENU)201, hInstance, 0);
  37.   SendMessage(hCtrlStcDisplay, WM_SETFONT, (WPARAM)font, FALSE);
  38.   HWND hCtrlBtnFire = CreateWindowEx(0, WC_BUTTON, ("Open Fire"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 623, 29, 98, 33, main_win, (HMENU)202, hInstance, 0);
  39.   SendMessage(hCtrlBtnFire, WM_SETFONT, (WPARAM)font, FALSE);
  40.   HWND hCtrlBtnPunch = CreateWindowEx(0, WC_BUTTON, ("Hand-to-Hand"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 623, 68, 98, 33, main_win, (HMENU)204, hInstance, 0);
  41.   SendMessage(hCtrlBtnPunch, WM_SETFONT, (WPARAM)font, FALSE);
  42.   HWND hCtrlBtnTalk = CreateWindowEx(0, WC_BUTTON, ("Negotiate"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 623, 107, 98, 33, main_win, (HMENU)203, hInstance, 0);
  43.   SendMessage(hCtrlBtnTalk, WM_SETFONT, (WPARAM)font, FALSE);
  44.   HWND hCtrlBtnFlee = CreateWindowEx(0, WC_BUTTON, ("Flee"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, 623, 146, 98, 33, main_win, (HMENU)205, hInstance, 0);
  45.   SendMessage(hCtrlBtnFlee, WM_SETFONT, (WPARAM)font, FALSE);
  46.   HWND hCtrlStcParty = CreateWindowEx(0, WC_BUTTON, ("Party"), WS_VISIBLE | WS_CHILD | 0x00000007, 614, 195, 116, 278, main_win, (HMENU)206, hInstance, 0);
  47.   SendMessage(hCtrlStcParty, WM_SETFONT, (WPARAM)font, FALSE);
  48.   HWND hCtrlStcCmds = CreateWindowEx(0, WC_BUTTON, ("Commands"), WS_VISIBLE | WS_CHILD | 0x00000007, 614, 7, 116, 182, main_win, (HMENU)207, hInstance, 0);
  49.   SendMessage(hCtrlStcCmds, WM_SETFONT, (WPARAM)font, FALSE);
  50.   HWND hCtrlProgress = CreateWindowEx(0, PROGRESS_CLASS, 0, WS_VISIBLE | WS_CHILD, 6, 478, 725, 24, main_win, (HMENU)208, hInstance, 0);
  51.   SendMessage(hCtrlProgress, WM_SETFONT, (WPARAM)font, FALSE);
  52.   ShowWindow(main_win, nCmdShow);
  53.   UpdateWindow(main_win);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement