Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GetSafeHwnd Error
Forum Updated to NodeBB v4.3 + New Features

GetSafeHwnd Error

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alecs26
    wrote on last edited by
    #1

    Hello,

    I am trying to integrate a licensing solution for my software (windows10, Qt MinWG 5.7). The solution asks me to write this line:

    result = CallIpEx((PPHWND)GetSafeHwnd(), IP2LIB_FLAGS_NONE,  > (LPCSTR)key, (LPCSTR)path, NULL, NULL, NULL, 0, 0, 0);
    

    However, I have this error message:
    C:\softwaredev9\main.cpp:51: error: 'GetSafeHwnd' was not declared in this scope result = CallIpEx((PPHWND)GetSafeHwnd(), IP2LIB_FLAGS_NONE, (LPCSTR)key, (LPCSTR)path, NULL, NULL, NULL, 0, 0, 0);

    I contacted the licensing software support and here is what they told me. The example they provide is for a MFC example with Visual Studio.
    "This is likely because you're not using MFC, so GetSafeHwnd is not available. Qt may have an equivalent you can use in its place so that the licensing dialogs are shown as modal dialogs that must be dismissed before one of your dialogs can be accessed. Alternatively, you can call the CallIpEx function before displaying any of your own dialogs, which allows you to pass NULL for this first argument."

    I am not sure to understand what to do in Qt to make this work.

    Thank you very much !

    Alex

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      @alecs26 said in GetSafeHwnd Error:

      GetSafeHwnd

      Hi
      Since
      https://msdn.microsoft.com/en-us/library/d64ehwhz(v=vs.80).aspx
      returns a HWND
      You might just need
      HWND hWnd = (HWND)this->winId();
      result = CallIpEx((PPHWND)hWnd , xxxx

      "This" should be a real window. In QMainwindow, it should work for a modal dialog.
      There can be issues as Qt not always use native controls and hence there is no HWND to get.

      What support say is that you can call it with NULL for HWND if you do it in main before any GUI is shown
      result = CallIpEx((PPHWND)nullptr, IP2LIB_FLAGS_NONE, > (LPCSTR)key, (LPCSTR)path, NULL, NULL, NULL, 0, 0, 0);

      1 Reply Last reply
      1
      • A Offline
        A Offline
        alecs26
        wrote on last edited by
        #3

        Thanks !

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved