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. How to activate a window in Windows 2003?
Qt 6.11 is out! See what's new in the release blog

How to activate a window in Windows 2003?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.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.
  • J Offline
    J Offline
    jcyangzh
    wrote on last edited by
    #1

    I have a program which only allow one instance under windows. If a user clicked the program link when the program have already started, the new program instance will activate the old running program. My code:
    @//only allow to run one single instance
    HANDLE hMutex = CreateMutex(NULL, TRUE, TEXT("ChavSoftRecorderServer"));
    if (ERROR_ALREADY_EXISTS == GetLastError()) {
    HWND hWnd = FindWindow(NULL, TEXT("畅远信息录音系统-服务端"));
    ShowWindow(hWnd, SW_SHOWDEFAULT);
    SetForegroundWindow(hWnd);
    return 0;
    }@
    But the result turn out to be t!http://i.imgur.com/eesVp.jpg(result)!

    I have write a sample using MFC and the same mutex code as above. The MFC edition works fine under both win7 and 2003.
    But qt version only works fine under win7.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      henryxuv
      wrote on last edited by
      #2

      You should review the Win32 SDK for detail about the two functions you called.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jcyangzh
        wrote on last edited by
        #3

        But I have tested it with another simple application using mfc, it works well.
        [quote author="henryxuv" date="1345431032"]You should review the Win32 SDK for detail about the two functions you called.[/quote]

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          The suggestion still stands, since this question has nothing to do with Qt.

          It is possible that your compiler is mangling the extended characters because UNICODE is not defined so TEXT() treats the string as a plain C string. See winnt.h

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            Can you please show the Qt version of your program to us?

            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