I need to create menu items on top of my DX11 windowed app - similar to most windowed applications (File, Edit, etc...). How can I achieve this ? There is a hMenu handle to pass to the DirectX window creation function but I have no idea how to create this object.

Additionnaly I'd like to have 1 or several ribbons under the window menu with icons to trigger functionnality.

EDIT My menu is all good now and I chose to implement a windows ribbon, but I'm still having problems at creating the ribbon. Here is a screenshot of my app. The green color is the Direct3D clear color - I would like my ribbon to display under the menu (and eventually remove the menu after that).

enter image description here

My ribbon code being :

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    PAINTSTRUCT paintStruct;
    HDC hDC;

    switch (message)
    case WM_CREATE:
        if (!SetupMenus(hwnd)) MessageBox(nullptr, TEXT("Failed to setup GUI."), TEXT("Error"), MB_OK);

    // ...

bool SetupMenus(HWND hwnd) {

    // Create the menu
    // ...

    // Create the ribbon
    IUIFramework* pFramework = NULL;
    HRESULT hr = ::CoCreateInstance(CLSID_UIRibbonFramework, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pFramework));
    if (FAILED(hr)) std::cerr << "Fail #1" << std::endl;

    hr = pFramework->Initialize(hwnd, IUIApp);
    if (FAILED(hr)) std::cerr << "Fail #2" << std::endl;

outputs Fail #1. Why can't I create the ribbon ?

  • \$\begingroup\$ I would create A DX11 subwindow inside your standard window \$\endgroup\$ – CobaltHex Oct 21 '15 at 1:11
  • \$\begingroup\$ Can you provide a link to how to achieve this ? I never used subwindows before. \$\endgroup\$ – PinkTurtle Oct 21 '15 at 9:11
  • 2
    \$\begingroup\$ technically all controls in Windows are windows so I just mean to say create a new window inside the current one, and use its HWND for your DirectX device -- this may require certain flags on the window to draw correctly \$\endgroup\$ – CobaltHex Oct 21 '15 at 20:34

There is a CreateMenu method you can use. More information on MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646977.aspx

I don't know about the ribbon functionality.


For CoCreateInstance to work you need to prepare the call with either CoInitialize or CoInitializeEx function.

CoInitialize function

Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA).

CoInitializeEx function

Initializes the COM library for use by the calling thread, sets the thread's concurrency model, and creates a new apartment for the thread if one is required.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.