Advertisement
PrimeNotorious

Untitled

Apr 23rd, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. Error identifier "hwnd" undifined i look up to google but nothing found can somebody explain me how to fix it
  2.  
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <tchar.h>
  7.  
  8. // Global variables
  9.  
  10. // The main window class name.
  11. static TCHAR szWindowClass[] = _T("win32app");
  12.  
  13. // The string that appears in the application's title bar.
  14. static TCHAR szTitle[] = _T("Win32 Guided Tour Application");
  15.  
  16. HINSTANCE hInst;
  17.  
  18. // Forward declarations of functions included in this code module:
  19. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  20.  
  21. int WINAPI WinMain(HINSTANCE hInstance,
  22. HINSTANCE hPrevInstance,
  23. LPSTR lpCmdLine,
  24. int nCmdShow)
  25. {
  26. WNDCLASSEX wcex;
  27.  
  28. wcex.cbSize = sizeof(WNDCLASSEX);
  29. wcex.style = CS_HREDRAW | CS_VREDRAW;
  30. wcex.lpfnWndProc = WndProc;
  31. wcex.cbClsExtra = 0;
  32. wcex.cbWndExtra = 0;
  33. wcex.hInstance = hInstance;
  34. wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
  35. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  36. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  37. wcex.lpszMenuName = NULL;
  38. wcex.lpszClassName = szWindowClass;
  39. wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
  40.  
  41. if (!RegisterClassEx(&wcex))
  42. {
  43. MessageBox(NULL,
  44. _T("Call to RegisterClassEx failed!"),
  45. _T("Win32 Guided Tour"),
  46. NULL);
  47.  
  48. return 1;
  49. }
  50.  
  51. hInst = hInstance; // Store instance handle in our global variable
  52.  
  53. // The parameters to CreateWindow explained:
  54. // szWindowClass: the name of the application
  55. // szTitle: the text that appears in the title bar
  56. // WS_OVERLAPPEDWINDOW: the type of window to create
  57. // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
  58. // 500, 100: initial size (width, length)
  59. // NULL: the parent of this window
  60. // NULL: this application does not have a menu bar
  61. // hInstance: the first parameter from WinMain
  62. // NULL: not used in this application
  63. HWND hWnd = CreateWindow(
  64. szWindowClass,
  65. szTitle,
  66. WS_OVERLAPPEDWINDOW,
  67. CW_USEDEFAULT, CW_USEDEFAULT,
  68. 500, 500,
  69. NULL,
  70. NULL,
  71. hInstance,
  72. NULL
  73. );
  74.  
  75. if (!hWnd)
  76. {
  77. MessageBox(NULL,
  78. _T("Call to CreateWindow failed!"),
  79. _T("Win32 Guided Tour"),
  80. NULL);
  81.  
  82. return 1;
  83. }
  84.  
  85. // The parameters to ShowWindow explained:
  86. // hWnd: the value returned from CreateWindow
  87. // nCmdShow: the fourth parameter from WinMain
  88. ShowWindow(hWnd,
  89. nCmdShow);
  90. UpdateWindow(hWnd);
  91.  
  92. // Main message loop:
  93. MSG msg;
  94. while (GetMessage(&msg, NULL, 0, 0))
  95. {
  96. TranslateMessage(&msg);
  97. DispatchMessage(&msg);
  98. }
  99.  
  100. return (int) msg.wParam;
  101. }
  102.  
  103. //
  104. // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  105. //
  106. // PURPOSE: Processes messages for the main window.
  107. //
  108. // WM_PAINT - Paint the main window
  109. // WM_DESTROY - post a quit message and return
  110. //
  111. //
  112. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  113. {
  114.  
  115. switch (message)
  116. {
  117. case WM_CREATE:
  118. CreateWindow(TEXT("button"), TEXT("Hello world"),
  119. WS_VISIBLE | WS_CHILD,
  120. 10, 10, 80, 25,
  121. hwnd,(HWMENU) 1, NULL, NULL
  122. );
  123. // Here your application is laid out.
  124. // For this introduction, we just print out "Hello, World!"
  125. // in the top left corner.
  126. // End application-specific layout section.
  127.  
  128. break;
  129. case WM_DESTROY:
  130. PostQuitMessage(0);
  131. break;
  132. default:
  133. return DefWindowProc(hWnd, message, wParam, lParam);
  134. break;
  135. }
  136.  
  137. return 0;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement