Not MSDN FORUM: Modern Windows GUI / API tutorial

nessa121 21 Reputation points
2021-05-28T00:37:11.673+00:00

I have been following this tutorial however certain data types do not work.. such as identifier is not defined or wrong parameters.. ?? I am using Visual Studio Community 2019 - Win32 Application project .. not a .net forum!!
https://www.youtube.com/watch?v=9JMQkUOhW1s
For instance, CreateWindowW tries to become CreateWindowExW and so I looked into the documentation of how to use it but the windows studio is not satisfied. Even the hMenu = CreateMenu(); states that hMenu is not defined.. or does not have a datatype. so I tried to do HMENU hMenu = Createmenu();// please help guys I will further eleaborate my questions as needed
Or could you guys help provide an example of how to call this ??

FORMAT:

CreateWindowExW(
In DWORD dwExStyle,
_In_opt_ LPCWSTR lpClassName,
_In_opt_ LPCWSTR lpWindowName,
In DWORD dwStyle,
In int X,
In int Y,
In int nWidth,
In int nHeight,
_In_opt_ HWND hWndParent,
_In_opt_ HMENU hMenu,
_In_opt_ HINSTANCE hInstance,
_In_opt_ LPVOID lpParam);
100310-program.png

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,471 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,591 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 11,746 Reputation points Microsoft Vendor
    2021-05-28T03:07:11.927+00:00
    #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\  
    nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\  
    CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\  
    nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)  
    

    As the previous snippet shows, CreateWindowW(...) expands to CreateWindowExW(0, ...). It is recommended to use CreateWindow or CreateWindowEx.
    And the following picture shows the corrected program has a global variable HMENU hMenu.

    100404-image.png


2 additional answers

Sort by: Most helpful
  1. Sam of Simple Samples 5,516 Reputation points
    2021-05-28T02:27:03.677+00:00

    The first parameter for your CreateWindowW is 0L; remove that.

    I am not sure what you did with hMenu and such; undo what you did and restore it back to what is in the YouTube.

    I am not going to watch the entire YouTube.

    I suggest you use Visual Studio to generate a sample application. You can build it immediately after creating the project and see how Microsoft does it. I am using VS 2017 but I assume the procedure for VS 2019 is the same or close enough. In the C++ templates find the Windows Desktop Wizard. Select it and then select a Desktop Application. See Windows Desktop Wizard; create a Windows Application using the defaults. Also see Walkthrough: Create a traditional Windows Desktop application (C++); that begins with a blank project and builds from there; I assume the result is the same as if you created the Windows Application that is not blank.

    1 person found this answer helpful.
    0 comments No comments

  2. nessa121 21 Reputation points
    2021-05-28T21:51:38.367+00:00

    Nevermind guys I got it working now thank you :) !!

    0 comments No comments