Monday, 15 March 2010

c++ - MSDN Windows App Tutorial Trouble -



c++ - MSDN Windows App Tutorial Trouble -

i'm attempting follow introductory tutorial on creating first windows application. says should have code , able create basic window.

#include <windows.h> #include <stdlib.h> #include <string.h> #include <tchar.h> #include <windef.h> lresult callback wndproc(hwnd, uint, wparam, lparam); int winapi winmain(hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) { wndclassex wcex; wcex.cbsize = sizeof(wndclassex); wcex.style = cs_hredraw | cs_vredraw; wcex.lpfnwndproc = wndproc; wcex.cbclsextra = 0; wcex.cbwndextra = 0; wcex.hinstance = hinstance; wcex.hicon = loadicon(hinstance, makeintresource(idi_application)); wcex.hcursor = loadcursor(null, idc_arrow); wcex.hbrbackground = (hbrush)(color_window+1); wcex.lpszmenuname = null; wcex.lpszclassname = szwindowclass; wcex.hiconsm = loadicon(wcex.hinstance, makeintresource(idi_application)); if (!registerclassex(&wcex)) { messagebox(null, _t("call registerclassex failed!"), _t("win32 guided tour"), null); homecoming 1; } hinst = hinstance; // store instance handle in our global variable // parameters createwindow explained: // szwindowclass: name of application // sztitle: text appears in title bar // ws_overlappedwindow: type of window create // cw_usedefault, cw_usedefault: initial position (x, y) // 500, 100: initial size (width, length) // null: parent of window // null: application dows not have menu bar // hinstance: first parameter winmain // null: not used in application hwnd hwnd = createwindow( szwindowclass, sztitle, ws_overlappedwindow, cw_usedefault, cw_usedefault, 500, 100, null, null, hinstance, null ); if (!hwnd) { messagebox(null, _t("call createwindow failed!"), _t("win32 guided tour"), null); homecoming 1; } // parameters showwindow explained: // hwnd: value returned createwindow // ncmdshow: 4th parameter winmain showwindow(hwnd, ncmdshow); updatewindow(hwnd); // main message loop: msg msg; while (getmessage(&msg, null, 0, 0)) { translatemessage(&msg); dispatchmessage(&msg); } homecoming (int) msg.wparam; }

it tells me szclassname undefined, hinst undefined, , sztile defined. missing obvious here? here link tutorial if helps "http://msdn.microsoft.com/en-us/library/bb384843.aspx".

well error says all. looks in tutorial, this

static tchar szwindowclass[] = _t("win32app"); static tchar sztitle[] = _t("win32 guided tour application");

as far hinst not beingness defined, i'm not sure. seek adding 2 lines , see if works. think find forgetting 2 lines.

you should have wndproc function define so:

lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) { homecoming defwindowproc(hwnd, message, wparam, lparam); }

c++ visual-studio-2012

No comments:

Post a Comment