Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Draggin and dropping functionality in windows 8 environment

Draggin and dropping functionality in windows 8 environment

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++workspace
10 Posts 2 Posters 0 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.
  • U Offline
    U Offline
    User 3776112
    wrote on last edited by
    #1

    Hi, i have developed an application in which i have icons in left side pane of application which can be dragged and dropped in client screen. Application is working fine with all the resolution except 1920x1080. when setting the resolution to 1920x1080 while dragging icons to client area, icon is not attach to mouse pointer. instead there is a gap between the mouse pointer and the icon. i wrote code to identify the screen resolution but it does not seem to recognize 1920x1080 resolution. below code is giving incorrect resolution for 1920x1080 setting. RECT actualDesktop; GetClientRect(GetDesktopWindow(),&actualDesktop); value of 'actualDesktop' variable is {top=0 bottom=783 left=0 right=1536} which is incorrect. according to current resolution size value should be {top=0 bottom=1080 left=0 right=1920}. Due to this, all the icons while dragging are adjusting according to incorrect resolution setting. Can someone help me to identify the issue and let me know if there is any limitation with respect to screen resolution in VC++ 6.0 with windows 8 environment. If require i will place more detailed code about the drag and drop functionality. Regards, Aniket

    L 1 Reply Last reply
    0
    • U User 3776112

      Hi, i have developed an application in which i have icons in left side pane of application which can be dragged and dropped in client screen. Application is working fine with all the resolution except 1920x1080. when setting the resolution to 1920x1080 while dragging icons to client area, icon is not attach to mouse pointer. instead there is a gap between the mouse pointer and the icon. i wrote code to identify the screen resolution but it does not seem to recognize 1920x1080 resolution. below code is giving incorrect resolution for 1920x1080 setting. RECT actualDesktop; GetClientRect(GetDesktopWindow(),&actualDesktop); value of 'actualDesktop' variable is {top=0 bottom=783 left=0 right=1536} which is incorrect. according to current resolution size value should be {top=0 bottom=1080 left=0 right=1920}. Due to this, all the icons while dragging are adjusting according to incorrect resolution setting. Can someone help me to identify the issue and let me know if there is any limitation with respect to screen resolution in VC++ 6.0 with windows 8 environment. If require i will place more detailed code about the drag and drop functionality. Regards, Aniket

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 3778954 wrote:

      VC++ 6.0 with windows 8 environment.

      That may well be your problem; VC 6 is very old and probably has many issues with Windows 8. I strongly suggest you upgrade to the latest version of Visual Studio.

      U 1 Reply Last reply
      0
      • L Lost User

        Member 3778954 wrote:

        VC++ 6.0 with windows 8 environment.

        That may well be your problem; VC 6 is very old and probably has many issues with Windows 8. I strongly suggest you upgrade to the latest version of Visual Studio.

        U Offline
        U Offline
        User 3776112
        wrote on last edited by
        #3

        Hi, Thanks for replying. But i am getting same issue when compiling in VS2012 in windows 8. code does not seem to recognize 1920x1080 resolution setting and downgrading my application look and feel by setting it to lower resolution. Any help would be appreciated. Regards, Aniket

        L 1 Reply Last reply
        0
        • U User 3776112

          Hi, Thanks for replying. But i am getting same issue when compiling in VS2012 in windows 8. code does not seem to recognize 1920x1080 resolution setting and downgrading my application look and feel by setting it to lower resolution. Any help would be appreciated. Regards, Aniket

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I would suggest that using GetClientRect is not the best way to get screen size as this may well take into account reserved areas on the desktop. You could try GetWindowRect instead, or better still use GetSystemMetrics with the SM_CXSCREEN and SM_CYSCREEN parameters, to get the physical dimensions.

          U 1 Reply Last reply
          0
          • L Lost User

            I would suggest that using GetClientRect is not the best way to get screen size as this may well take into account reserved areas on the desktop. You could try GetWindowRect instead, or better still use GetSystemMetrics with the SM_CXSCREEN and SM_CYSCREEN parameters, to get the physical dimensions.

            U Offline
            U Offline
            User 3776112
            wrote on last edited by
            #5

            Thanks Richard, I was finally able to make my application DPI aware in VC6.0. Now i am able to get the correct resolution settings of my machine. However another issue started after making these changes. Since the application is now recognizing the screen resolution and adjusting all child window according to that but the menu bar text seem not to be adjust at all automatically. The text size of menu item is large and hiding behind the toolbar. How can i programmatically change menu bar text size? Kindly suggest any solution. Regards, Aniket

            L 1 Reply Last reply
            0
            • U User 3776112

              Thanks Richard, I was finally able to make my application DPI aware in VC6.0. Now i am able to get the correct resolution settings of my machine. However another issue started after making these changes. Since the application is now recognizing the screen resolution and adjusting all child window according to that but the menu bar text seem not to be adjust at all automatically. The text size of menu item is large and hiding behind the toolbar. How can i programmatically change menu bar text size? Kindly suggest any solution. Regards, Aniket

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Member 3778954 wrote:

              I was finally able to make my application DPI aware in VC6.0.

              Please tell us the solution so other people may benefit.

              Member 3778954 wrote:

              The text size of menu item is large and hiding behind the toolbar.

              Without seeing some code it's impossible to guess why.

              U 1 Reply Last reply
              0
              • L Lost User

                Member 3778954 wrote:

                I was finally able to make my application DPI aware in VC6.0.

                Please tell us the solution so other people may benefit.

                Member 3778954 wrote:

                The text size of menu item is large and hiding behind the toolbar.

                Without seeing some code it's impossible to guess why.

                U Offline
                U Offline
                User 3776112
                wrote on last edited by
                #7

                Hi Richard, I have added below lines of code in my App class init function to make the application aware of DPI settings. HMODULE hUser32 = LoadLibrary(_T("user32.dll")); typedef BOOL (*SetProcessDPIAwareFunc)(); SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware"); if (setDPIAware) setDPIAware(); FreeLibrary(hUser32); User32.dll library is present in "System" folder of windows directory. After adding the above code, my application is now scaling according to DPI settings but menu items font size is increased too much so that it is hiding behind the toolbar. Menu bar is created by default as it is created in a MDI application. if(!m_wndMenuBar.Create(this)) { TRACE0("Failed to create menubar\n"); return -1; } When application get scaled automatically based on DPI settings (Larger 150%), menu bar text become large and hide behind the toolbar. Any help would be appreciated. Regards, Aniket

                L 1 Reply Last reply
                0
                • U User 3776112

                  Hi Richard, I have added below lines of code in my App class init function to make the application aware of DPI settings. HMODULE hUser32 = LoadLibrary(_T("user32.dll")); typedef BOOL (*SetProcessDPIAwareFunc)(); SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware"); if (setDPIAware) setDPIAware(); FreeLibrary(hUser32); User32.dll library is present in "System" folder of windows directory. After adding the above code, my application is now scaling according to DPI settings but menu items font size is increased too much so that it is hiding behind the toolbar. Menu bar is created by default as it is created in a MDI application. if(!m_wndMenuBar.Create(this)) { TRACE0("Failed to create menubar\n"); return -1; } When application get scaled automatically based on DPI settings (Larger 150%), menu bar text become large and hide behind the toolbar. Any help would be appreciated. Regards, Aniket

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Why are you using LoadLibrary to get access to user32.dll when it is automatically linked in to just about every Win32 program ever written? Just make the direct call to SetProcessDPIAware, or better still do what is suggested at http://msdn.microsoft.com/en-gb/library/windows/desktop/ms633543(v=vs.85).aspx[^]. As to your menu issue I have no idea I'm afraid, the code you have shown above merely shows how a menu is created. It would also help if you used indentation and put <pre> tags around your code so it is easier to read, like:

                  if(!m_wndMenuBar.Create(this))
                  {
                  TRACE0("Failed to create menubar\n");
                  return -1;
                  }

                  Use the code button above the edit box.

                  U 1 Reply Last reply
                  0
                  • L Lost User

                    Why are you using LoadLibrary to get access to user32.dll when it is automatically linked in to just about every Win32 program ever written? Just make the direct call to SetProcessDPIAware, or better still do what is suggested at http://msdn.microsoft.com/en-gb/library/windows/desktop/ms633543(v=vs.85).aspx[^]. As to your menu issue I have no idea I'm afraid, the code you have shown above merely shows how a menu is created. It would also help if you used indentation and put <pre> tags around your code so it is easier to read, like:

                    if(!m_wndMenuBar.Create(this))
                    {
                    TRACE0("Failed to create menubar\n");
                    return -1;
                    }

                    Use the code button above the edit box.

                    U Offline
                    U Offline
                    User 3776112
                    wrote on last edited by
                    #9

                    Hi Richard, I need to load User32.dll because in VC6.0 this library is not linked automatically and to make my application DPI aware, i have to load it manually. As far as menu bar is concern, i found one strange thing. If i set my DPI settings to 'Large' (150%) or higher and open my application then at first menu is hiding behind the toolbar as the text of item big. But once I change my system text size (COntrol panel -> display -> change on the text size options) to any size and windows is refreshed and then my application menu become proper. My doubt is that application is scaling child window and main window but not the menu item when opened first but when system text size is changed and windows is refreshed then application is also scaling all the text size according to system settings. How can i make my application set all the text including menu according to system text settings in the first place. Regards, Aniket

                    L 1 Reply Last reply
                    0
                    • U User 3776112

                      Hi Richard, I need to load User32.dll because in VC6.0 this library is not linked automatically and to make my application DPI aware, i have to load it manually. As far as menu bar is concern, i found one strange thing. If i set my DPI settings to 'Large' (150%) or higher and open my application then at first menu is hiding behind the toolbar as the text of item big. But once I change my system text size (COntrol panel -> display -> change on the text size options) to any size and windows is refreshed and then my application menu become proper. My doubt is that application is scaling child window and main window but not the menu item when opened first but when system text size is changed and windows is refreshed then application is also scaling all the text size according to system settings. How can i make my application set all the text including menu according to system text settings in the first place. Regards, Aniket

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Sorry, I don't know the answer. I can only suggest you try some further searching, or maybe one of the Microsoft forums.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups