Announcement

Collapse
No announcement yet.

prevent console from being dragged deny drag

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • prevent console from being dragged deny drag

    It would be useful to stop the console from being dragged, can this be done without subclassing the console?

  • #2
    I've never seen ANY window which can't dragged. But I reckon you could maximize it, that can't be dragged anywhere.

    But how can it be useful to PREVENT the console window from being dragged somewhere? Surely there is some better way to accomplish whatever this is supposed to accomplish.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I've seen some and even created some on my own. (And I have even dragged a Maximized window...) In a GUI Window you could alter the mouse like some windows do that let you drag by clicking anywhere on the window...but the opposite of this.

      To stop the Drag ability you only have one option that I know of and it would work on both it and GUI is altering the System Menu.

      In a GUI world I access it with:

      Code:
      lngSystemMenu = GetSystemMenu(HWND, 0)
      RemoveMenu lngSystemMenu, %SC_SIZE, %MF_BYCOMMAND 'no resize
      RemoveMenu lngSystemMenu, %SC_MAXIMIZE, %MF_BYCOMMAND 'no maximize
      Usually removing or disabling the Move and Size menu items will prevent your Window from moving.
      sigpic
      Mobile Solutions
      Sys Analyst and Development

      Comment


      • #4
        Originally posted by Michael Mattias View Post
        Surely there is some better way to accomplish whatever this is supposed to accomplish.
        Correct!

        Comment


        • #5
          Originally posted by Roger Garstang View Post
          To stop the Drag ability you only have one option that I know of and it would work on both it and GUI is altering the System Menu.
          Thank you Roger!

          Comment


          • #6
            Glad it worked. The SC_ commands are pretty cool. You can add your own menus or use the built-in menu options. You can even call them without them being in the menu. If I recall there are a bunch of neat ones like Power Save and Screensaver options. I never played with it on a Console though, but I guess the only difficult matter is getting the Hwnd of the Console Window...CONSHNDL.
            Last edited by Roger Garstang; 22 Aug 2008, 07:35 AM.
            sigpic
            Mobile Solutions
            Sys Analyst and Development

            Comment


            • #7
              >>Surely there is some better way to accomplish whatever
              >> this is supposed to accomplish.

              >Correct

              May we buy a vowel?
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Why Yes Vanna you can!

                I would say the code below, but it didn't seem to do it on my XP box..

                Code:
                #Compile Exe
                #Dim All
                 
                %SC_SIZE         = &HF000&
                %SC_MOVE         = &HF010&
                %SC_MINIMIZE     = &HF020&
                %SC_MAXIMIZE     = &HF030&
                %SC_RESTORE      = &HF120&
                %SC_CLOSE        = &HF060&
                %MF_BYCOMMAND    = &H0&
                %MF_GRAYED       = &H1&
                %MF_DISABLED     = &H2& 
                 
                Declare Function DeleteMenu Lib "USER32.DLL" Alias "DeleteMenu" (ByVal hMenu As Dword, ByVal nPosition As Long, ByVal wFlags As Dword) As Long
                Declare Function GetSystemMenu Lib "USER32.DLL" Alias "GetSystemMenu" (ByVal hWnd As Dword, ByVal bRevert As Long) As Long
                 
                Function PBMain () As Long
                Local lngSystemMenu As Long
                 
                    lngSystemMenu = GetSystemMenu(ConsHndl, 0)
                    DeleteMenu lngSystemMenu, %SC_SIZE, %MF_BYCOMMAND Or %MF_GRAYED Or %MF_DISABLED 'no resize
                    DeleteMenu lngSystemMenu, %SC_MOVE, %MF_BYCOMMAND Or %MF_GRAYED Or %MF_DISABLED 'no move
                    DeleteMenu lngSystemMenu, %SC_MINIMIZE, %MF_BYCOMMAND Or %MF_GRAYED Or %MF_DISABLED 'no minimize
                    DeleteMenu lngSystemMenu, %SC_MAXIMIZE, %MF_BYCOMMAND Or %MF_GRAYED Or %MF_DISABLED 'no maximize
                    DeleteMenu lngSystemMenu, %SC_RESTORE, %MF_BYCOMMAND Or %MF_GRAYED Or %MF_DISABLED 'no restore
                    DeleteMenu lngSystemMenu, %SC_CLOSE, %MF_BYCOMMAND Or %MF_GRAYED Or %MF_DISABLED 'no close
                 
                    Print "Try To Move Me."
                    WaitKey$
                End Function
                Only removed the menu items, didn't disable everything like a GUI window. In searching it looks like many threads mention the same problem. Especially concerning just Disable/Grey of the item instead of remove.

                (Only %MF_BYCOMMAND should be needed for the DeleteMenu, I was just trying everything, and it made it easier when moving between other menu api calls)
                Last edited by Roger Garstang; 22 Aug 2008, 02:33 PM.
                sigpic
                Mobile Solutions
                Sys Analyst and Development

                Comment


                • #9
                  Originally posted by Michael Mattias View Post
                  May we buy a vowel?
                  sorry, weather interrupted my work.

                  The scenario is mapping a window over an area of a console - see other contemporary thread re tooltips. If the console gets dragged away, the tooltip-owning window looks a bit silly on its own. So I thought - let's lock the console down. However, a better way is to dismiss the window when anything is done to the console, but I have been unable to identify an unambiguous message received by the tto window to trigger closing the tto. So that means looking at subclassing the console, I suppose.

                  Getting the tooltips to work on the console screen would be better still. I found a post by Semen here, #6 which tantalisingly mentions tooltips on a console. So far I have not suceeded in getting this to work, trying stuff along the lines of:

                  Code:
                  '
                  '
                  #COMPILE EXE
                  #DIM ALL
                  #INCLUDE "COMMCTRL.INC"
                  #INCLUDE "win32api.inc"
                  
                  '------------------------------------------------------------------------
                  GLOBAL  ghwnd AS DWORD
                  GLOBAL hWndToolTip  AS DWORD
                  '-----------------------------------------------------------------
                  SUB CreateTip(  Tip AS STRING, x AS LONG, y AS LONG, w AS LONG, h AS LONG )
                      STATIC Crt          AS CREATESTRUCT
                      STATIC TlInfo       AS TOOLINFO
                      STATIC hInst        AS LONG
                      LOCAL hdlg          AS DWORD
                      LOCAL lresult AS LONG
                  
                      IF hWndToolTip THEN ' deploy tooltip
                          TlInfo.hwnd = CONSHNDL
                          setrect(TlInfo.rec,x, y, w, h)
                          TlInfo.uId = 0 ' using rect method not window mathod
                          TlInfo.lpszText = STRPTR(Tip)
                          lresult = SendMessage( hwndtooltip, %TTM_ADDTOOL, 0, VARPTR( TlInfo ) )
                          IF lresult = 0 THEN ? "failed to add tooltip to console
                          SendMessage( hwndtooltip, %TTM_ACTIVATE, 1, 0 )
                          ' no return value defined for the above message!
                      ELSE 'create tooltip
                          ? "init
                          LOCAL ice AS INIT_COMMON_CONTROLSEX
                          ice.dwSize = SIZEOF(ice)
                          ice.dwICC = %ICC_WIN95_CLASSES
                          InitCommonControlsEx(ice)
                          hdlg = hinst
                          hInst = GetModuleHandle("")
                          Tip = "ToolTip"
                          Crt.lpCreateParams = 0
                          Crt.hInstance    = hInst
                          Crt.hMenu        = 0
                          Crt.hwndParent   = hinst
                          Crt.style        = %WS_POPUP OR %TTS_NOPREFIX OR %TTS_ALWAYSTIP
                          Crt.lpszName     = STRPTR(Tip)
                          Tip = $TOOLTIPS_CLASS
                          Crt.lpszClass    = STRPTR(Tip)
                          Crt.dwExStyle    = %WS_EX_TOPMOST
                  
                          hWndToolTip = CreateWindowEx( %WS_EX_TOPMOST, $TOOLTIPS_CLASS, "", _
                          %WS_POPUP OR %TTS_NOPREFIX OR %TTS_ALWAYSTIP OR %TTS_BALLOON, _
                              %CW_USEDEFAULT, %CW_USEDEFAULT, %CW_USEDEFAULT, _
                              %CW_USEDEFAULT, 0, 0, hInst, Crt )
                  
                          IF hwndtooltip = 0 THEN ?"failed to create tooltip"
                          SENDmessage hWndToolTip, %TTM_SETMAXTIPWIDTH, 0, 200
                  
                          SetWindowPos( hWndToolTip, %HWND_TOPMOST, 100, 100, 300, 300, _
                              %SWP_NOMOVE OR %SWP_NOSIZE OR %SWP_NOACTIVATE )
                  
                          SendMessage( hWndToolTip, %TTM_SETDELAYTIME, %TTDT_INITIAL, 100 ) 'time a pointer must remain stationary before the tooltip appears
                          SendMessage( hWndToolTip, %TTM_SETDELAYTIME, %TTDT_AUTOPOP, 5000 ) 'time a tooltip window remains visible If the Pointer is stationary
                          SendMessage( hWndToolTip, %TTM_SETDELAYTIME, %TTDT_RESHOW, 500 ) 'time before subsequent tooltips to appear
                  
                          '------------------------------
                          TlInfo.cbSize = SIZEOF( TOOLINFO )
                          TlInfo.uFlags = %TTF_SUBCLASS OR %TTS_ALWAYSTIP OR %TTS_BALLOON OR %TTF_CENTERTIP
                          TlInfo.hinst = hInst
                      END IF
                  END SUB
                  '--------------------------------------------------
                  FUNCTION PBMAIN () AS LONG
                      LOCAL s, stip AS STRING
                      LOCAL point AS POINTAPI
                      LOCAL chrwidth, mx, my, orgx, orgy, initialH, initialW, lineheight, w, h, x, y AS LONG
                  
                      initcommoncontrols
                      initialH = 10: initialW = 40
                      CONSOLE SET SCREEN initialH,initialW
                  
                      MOUSE ON
                      MOUSE 3, DOUBLE, DOWN
                      COLOR 7,8
                      CLS
                      LOCATE 3, 10: COLOR ,4: PRINT SPACE$(6)
                  
                      LOCATE 6, 20: COLOR ,2: PRINT SPACE$(6)
                      CreateTip "",0,0,0,0
                      DO
                          SLEEP 10
                          s = WAITKEY$
                          IF LEN(s) = 4 THEN ' mouse event
                  
                              stip = ""
                              my = MOUSEY: mx = MOUSEX
                              CONSOLE GET LOC TO orgx, orgy
                              CONSOLE GET SIZE TO w, h
                              lineheight = h \ initialh
                              chrwidth = w \ initialW
                  
                              IF (MOUSEY) = 3 AND (MOUSEX >=3) AND (MOUSEX <= 16) THEN
                                  y = (3-1) * lineheight : h = lineheight -1
                                  x = (MOUSEX-1) * chrwidth : w = 6 * chrwidth
                                  stip = "red"
                                  createtip(stip, x + orgX, y + OrgY, w, h) ' todo: need to add in NC width & height
                              END IF
                  
                          ELSE
                              IF s = $ESC THEN  sendmessage ghwnd, %WM_CLOSE, 0, 0
                          END IF
                  
                      LOOP
                      s = WAITKEY$
                  
                  END FUNCTION

                  Comment


                  • #10
                    I have no idea if this will work, but what if you create a "real" window as a container, then made HwndConsole a child of that window using SetParent()?

                    Then you could display your tooltips relative to the client area of the container window.

                    If you are married to a 'real' console (PB/CC program, or AllocConsole) here, this won't help, but it would sure simplify tooltips:
                    Use Listview control as a console. September 13 2003.

                    I am in a really good mood today. We just installed and did a final test on a major project I have been working on for a couple of months.

                    These are the moments I live for, when the client executes the "one button" which is supposed to do all kinds of stuff, replacing about separate ten manual operations .. and all it works flawlessly and the client says "thank you" and means it.

                    Nothing like it. Anywhere. At any price.

                    MCM
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Originally posted by Michael Mattias View Post
                      ... but what if you create a "real" window as a container, then made HwndConsole a child of that window using SetParent()?
                      I'll try it just for a laugh.

                      If you are married to a 'real' console (PB/CC program, or AllocConsole) here
                      yes I am, PBCC.

                      I am in a really good mood today....replacing about separate ten manual operations .. and all it works flawlessly and the client says "thank you" and means it.
                      have you no sympathy for the poor, hardworking clerk who you just put out of work?

                      Comment


                      • #12
                        >have you no sympathy for the poor, hardworking clerk who you just put out of work

                        Funny you should bring that up.

                        On Thursday I had about an hour-long phone conversation with that hardworking clerk's immediate supervisor on that exact subject. Seems there was some doubt about the project in the heart and mind of the lead operator.

                        Between what I've done the past fourteen years (sheesh, has it been that long?) and even more so when I was general manager of a VAR firm, I have encountered the fear, "the computer is going to cost me my job" literally hundreds of times.

                        While I'm sure "reducing personnel" is a goal somewhere, I have (fortunately?) never experienced. My customers' and clients' goals - as expressed by the senior management - have always been to "do more with the same" rather than "do the same with less."

                        Unfortunately, sometimes this does not get conveyed down the line all the way and you end up with the situation described: "Why should I lift a finger to cooperate on this project when all it's going to do is get me laid off?"

                        You can only have a successful software implementation when everyone is on-board and looking forward to it.

                        No, it's not the consultant's job to sell everyone on the project; however, it IS the consultant's job to ensure management is doing the required selling throughout the client organization.


                        MCM
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Productivity.
                          In the last twenty-five years, it seems to me, more people have got jobs because of software/hardware solutions than lost them. Usually better paying as well.
                          If the clerk doesn't want to learn new things, they can get left behind real quick in this ever changing world, which is the same position that management is in, and any business is in.
                          Rod
                          In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                          Comment


                          • #14
                            Originally posted by Rodney Hicks View Post
                            ... more people have got jobs because of software/hardware solutions than lost them...
                            that is counter-intuitive. Traditional businesses use IT to minimise administratitive costs. What is the largest such cost? Payroll.

                            Comment


                            • #15
                              It only seems counter intuitive. Every place(3) that I'm familiar with that hired 1 IT specialist to do a job now have IT teams, with very little loss of other workers, although a good many of those other workers have slightly different job descriptions.
                              All 3 that I'm closely familiar with are more productive as well, getting more done from existing personnel.

                              While my experience does not a world make, it does seem to support MCM's
                              My customers' and clients' goals - as expressed by the senior management - have always been to "do more with the same" rather than "do the same with less."
                              Rod
                              In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                              Comment


                              • #16
                                Originally posted by Rodney Hicks View Post
                                It only seems counter intuitive.
                                Rodney may I frame that one?

                                Every place(3) that I'm familiar with...While my experience does not a world make, it does seem to support MCM's
                                Not even the two of ye doth a world make.

                                For your story to work you have to be in a business sector that is expanding. IT has actually grown into some big sectors which are not expanding in themselves, or are doing so under severe fiscal pressure. Central and Local Government and retail would be examples. At the sharp end - the small business, a major employer here in the UK, managers will jump at the chance to shed headcount and IT in the form of PC accounting and technical applications is one of the reasons for the expansion of the sector, because it means that you don't have to employ an accountant or engineer in house.

                                Don't think for a moment that I'm wringing my hands about these ex-employees, or feel guilty about being involved in their little disaster - you can no more undo it than you can un-invent the bicycle. It's just the bit of history that we live in.

                                Comment


                                • #17
                                  Rodney may I frame that one?
                                  Yes, since I can't counter it.

                                  Not even the two of ye doth a world make.
                                  Nor even the three of us.

                                  We may be too close to some trees to see the forest.

                                  PS
                                  Two of those companies are expanding in while their sector is not. An aberration that may correct itself.
                                  Last edited by Rodney Hicks; 23 Aug 2008, 03:26 PM. Reason: add PS
                                  Rod
                                  In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                                  Comment

                                  Working...
                                  X