|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB6-rotate form 90 degrees?I have a problem that could be solved more easily if my VB6 form with
a text input field and several drop-down controls can be rotated 90 degrees clockwise. (Monitor is being turned sideways - long story - exploring solutions.) Is this possible with Classic VB? Not just to rotate text on the form, but to rotate the entire form so it looks and functions normally? If so, what commands do I need? Ed "Ed from AZ" <prof_ofw***@yahoo.com> wrote in message What about mouse movements?news:a7ed093e-38d2-49f2-a606-f5621b34cf0c@i19g2000pro.googlegroups.com... >I have a problem that could be solved more easily if my VB6 form with > a text input field and several drop-down controls can be rotated 90 > degrees clockwise. (Monitor is being turned sideways - long story - > exploring solutions.) Is this possible with Classic VB? Not just to > rotate text on the form, but to rotate the entire form so it looks and > functions normally? If so, what commands do I need? Show quoteHide quote > Ed > What about mouse movements? Sucks, but I can get by with just keyboard input. The mouse is usedjust to preselect some of the drop-downs; after that, it's all keyboard. I could even put a button on the form to rotate it after pre-selections are made. Ed Show quoteHide quote On Aug 9, 7:26 am, "mbyerley" <mDotByerley@VerizonDottieNettie> wrote: > "Ed from AZ" <prof_ofw***@yahoo.com> wrote in messagenews:a7ed093e-38d2-49f2-a606-f5621b34c***@i19g2000pro.googlegroups.com... > > >I have a problem that could be solved more easily if my VB6 form with > > a text input field and several drop-down controls can be rotated 90 > > degrees clockwise. (Monitor is being turned sideways - long story - > > exploring solutions.) Is this possible with Classic VB? Not just to > > rotate text on the form, but to rotate the entire form so it looks and > > functions normally? If so, what commands do I need? > > What about mouse movements? > > > > > Ed- Hide quoted text - > > - Show quoted text - "mbyerley" <mDotByerley@VerizonDottieNettie> wrote in message Actually the mouse movements can easily be dealt with. In this specific news:x42dnaCzcIm1jf3RnZ2dnUVZ_gydnZ2d@giganews.com... >> "Ed from AZ" <prof_ofw***@yahoo.com> wrote in message >> news:a7ed093e-38d2-49f2-a606-f5621b34cf0c@i19g2000pro.googlegroups.com... >> I have a problem that could be solved more easily if my VB6 form >> with a text input field and several drop-down controls can be rotated >> 90 degrees clockwise. (Monitor is being turned sideways - long story >> - exploring solutions.) Is this possible with Classic VB? > > What about mouse movements? case, the OP (as indicated by his later postings) is having problems getting his display to rotate to portrait mode due to a video card driver problem brought about by a WinXP SP3 update, and I and others have given him some suggestions as to how he may solve that problem. However, if SP3 has totally knackered the video card driver in that respect and if all of those suggestions fail then there is always the "last resort" of drawing his own Controls in portrait mode (although that of course would itself require a great deal of work) and then manipulating the user's mouse movements at a low level so as to finish the job. In fact, the OP's question got me to thinking about how we can "fiddle" the user's mouse movements system wide in VB code in general, and it turns out to be not too difficult a task if you use a low level hook with the appropriate logic. Here, for example, is some VB code I have just written that changes the x and y mouse movements for the entire system so that "up becomes down" and "left becomes right". I decided to perform that specific task because it is slightly easier (from a logical viewpoint) than the "swap mouse orientation" that the OP might require if all else fails, and because this example code of mine was really just a "proof of concept" thing, but swapping orientation is very definitely just as "doable" with a little more thought. There are two blocks of code below (the first small block to be pasted into a Form and the second larger block to be pasted into a standard code Module). The code is just a first "proof of concept" model and I have not bothered with lots of things (multiple monitors and all sorts of stuff) and it is written in a bit of a "suck it and see" way that does not usually produce the neatest code, but it definitelty does seem to work okay (although of course there is always room for improvement). In fact, I've just this minute noticed a little problem with it if you drag a Form down so that its Caption Bar is partially below the taskbar, but these of course are just "teething troubles" and the basic idea seems to be fairly sound. Mike ' ***** START OF FORM CODE ***** Option Explicit Private Sub Form_Load() Caption = "Close this Form to return " _ & "mouse movement to normal." SetHook End Sub Private Sub Form_Unload(Cancel As Integer) ReleaseHook End Sub ' ***** END OF FORM CODE ***** ' ' ' ***** START OF MODULE CODE ***** Option Explicit ' Code by Mike Williams (2010) to modify the user's ' mouse movement in accordance with any set of rules ' (this specific example reverses the direction of ' both the x and y mouse movements, but it can easily ' be modified to perform other tasks, for example to ' swap the mouse orientation from landscape to portrait Private Declare Function SetWindowsHookEx _ Lib "user32" Alias "SetWindowsHookExA" _ (ByVal idHook As Long, ByVal lpfn As Long, _ ByVal hmod As Long, ByVal dwThreadId As Long) As Long Private Declare Function UnhookWindowsHookEx _ Lib "user32" (ByVal hHook As Long) As Long Private Declare Function CallNextHookEx _ Lib "user32" (ByVal hHook As Long, _ ByVal nCode As Long, ByVal wParam As Long, _ lParam As Any) As Long Private Declare Sub CopyMemory Lib "kernel32" _ Alias "RtlMoveMemory" (Destination As Any, _ Source As Any, ByVal Length As Long) Private Declare Function SetCursorPos Lib "user32" _ (ByVal X As Long, ByVal Y As Long) As Long Private Const WH_MOUSE_LL As Long = 14 'low level Private Const WH_MOUSE As Long = 7 ' app level Private Const HC_ACTION = 0 Private Const WM_RBUTTONDOWN As Long = &H204 Private Const WM_RBUTTONUP As Long = &H205 Private Const WM_RBUTTONDBLCLK As Long = &H206 Private Const WM_MOUSEMOVE As Long = &H200 Private Const WM_LBUTTONDOWN As Long = &H201 Private Const WM_LBUTTONUP As Long = &H202 Private Const WM_MBUTTONDOWN As Long = &H207 Private Const WM_MBUTTONUP As Long = &H208 Private Const WM_SCROLL As Long = &H20A Private Type POINTAPI X As Long Y As Long End Type Private Type MOUSELLHOOKSTRUCT point As POINTAPI data As Long flags As Long time As Long extra As Long End Type Private mousedata As MOUSELLHOOKSTRUCT Private oldCoords As POINTAPI Private Hook As Long Private xMax As Long, yMax As Long Public Sub SetHook() xMax = (Screen.Width / Screen.TwipsPerPixelX) - 1 yMax = (Screen.Height / Screen.TwipsPerPixelY) - 1 Hook = SetWindowsHookEx(WH_MOUSE_LL, _ AddressOf MouseProc, App.hInstance, 0) End Sub Public Sub ReleaseHook() UnhookWindowsHookEx Hook End Sub Private Function MouseProc(ByVal nCode As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Static Initialised As Boolean, temp As Long Dim diffX As Long, diffY As Long If (nCode = HC_ACTION) And (wParam = WM_MOUSEMOVE) Then CopyMemory mousedata, ByVal lParam, Len(mousedata) If Not Initialised Then oldCoords.X = mousedata.point.X oldCoords.Y = mousedata.point.Y Initialised = True MouseProc = CallNextHookEx _ (0, nCode, wParam, ByVal lParam) End If diffX = mousedata.point.X - oldCoords.X diffY = mousedata.point.Y - oldCoords.Y If diffX = 0 And diffY = 0 Then ' same coords as previous coords, so this must be ' the move triggered by our Call to SetCursorPos, ' in which case we need to allow the system to ' deal with it MouseProc = CallNextHookEx _ (0, nCode, wParam, ByVal lParam) Else ' different coords, so this must be a standard mouse ' movement not triggered by our Call to SetCursorPos, ' in which case we need to modify the mouse movement ' in accordance with whatever rules we have set (this ' specific example reverses the movement in both the ' x plane and the y plane) abd we then need to tell ' the system to ignore the unwanted mouse movement ' that triggered this event. ' We modify the movement by first setting the mouse ' to the position we want it to be (using a call to ' SetCursorPos) and we instruct the system to ignore ' the "unwanted" mouse movement that triggered this ' event by setting the return value to True oldCoords.X = mousedata.point.X - diffX - diffX oldCoords.Y = mousedata.point.Y - diffY - diffY If oldCoords.X < 0 Then oldCoords.X = 0 If oldCoords.X > xMax Then oldCoords.X = xMax If oldCoords.Y < 0 Then oldCoords.Y = 0 If oldCoords.Y > yMax Then oldCoords.Y = yMax SetCursorPos oldCoords.X, oldCoords.Y MouseProc = True Exit Function End If End If End Function ' ***** END OF MODULE CODE *****
Show quote
Hide quote
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message Hey Mike... The lazy way would be to rotate the mouse 90 deg in your news:i3sj50$dp1$1@speranza.aioe.org... > "mbyerley" <mDotByerley@VerizonDottieNettie> wrote in message > news:x42dnaCzcIm1jf3RnZ2dnUVZ_gydnZ2d@giganews.com... >>> "Ed from AZ" <prof_ofw***@yahoo.com> wrote in message >>> news:a7ed093e-38d2-49f2-a606-f5621b34cf0c@i19g2000pro.googlegroups.com... >>> I have a problem that could be solved more easily if my VB6 form >>> with a text input field and several drop-down controls can be rotated >>> 90 degrees clockwise. (Monitor is being turned sideways - long story >>> - exploring solutions.) Is this possible with Classic VB? >> >> What about mouse movements? > > Actually the mouse movements can easily be dealt with. In this specific > case, the OP (as indicated by his later postings) is having problems > getting his display to rotate to portrait mode due to a video card driver > problem brought about by a WinXP SP3 update, and I and others have given > him some suggestions as to how he may solve that problem. However, if SP3 > has totally knackered the video card driver in that respect and if all of > those suggestions fail then there is always the "last resort" of drawing > his own Controls in portrait mode (although that of course would itself > require a great deal of work) and then manipulating the user's mouse > movements at a low level so as to finish the job. In fact, the OP's > question got me to thinking about how we can "fiddle" the user's mouse > movements system wide in VB code in general, and it turns out to be not > too difficult a task if you use a low level hook with the appropriate > logic. > > Here, for example, is some VB code I have just written that changes the x > and y mouse movements for the entire system so that "up becomes down" and > "left becomes right". I decided to perform that specific task because it > is slightly easier (from a logical viewpoint) than the "swap mouse > orientation" that the OP might require if all else fails, and because this > example code of mine was really just a "proof of concept" thing, but > swapping orientation is very definitely just as "doable" with a little > more thought. > > There are two blocks of code below (the first small block to be pasted > into a Form and the second larger block to be pasted into a standard code > Module). The code is just a first "proof of concept" model and I have not > bothered with lots of things (multiple monitors and all sorts of stuff) > and it is written in a bit of a "suck it and see" way that does not > usually produce the neatest code, but it definitelty does seem to work > okay (although of course there is always room for improvement). In fact, > I've just this minute noticed a little problem with it if you drag a Form > down so that its Caption Bar is partially below the taskbar, but these of > course are just "teething troubles" and the basic idea seems to be fairly > sound. > > Mike hand.... ;-) Show quoteHide quote > ' ***** START OF FORM CODE ***** > Option Explicit > > Private Sub Form_Load() > Caption = "Close this Form to return " _ > & "mouse movement to normal." > SetHook > End Sub > > Private Sub Form_Unload(Cancel As Integer) > ReleaseHook > End Sub > ' ***** END OF FORM CODE ***** > ' > ' > ' ***** START OF MODULE CODE ***** > Option Explicit > ' Code by Mike Williams (2010) to modify the user's > ' mouse movement in accordance with any set of rules > ' (this specific example reverses the direction of > ' both the x and y mouse movements, but it can easily > ' be modified to perform other tasks, for example to > ' swap the mouse orientation from landscape to portrait > Private Declare Function SetWindowsHookEx _ > Lib "user32" Alias "SetWindowsHookExA" _ > (ByVal idHook As Long, ByVal lpfn As Long, _ > ByVal hmod As Long, ByVal dwThreadId As Long) As Long > Private Declare Function UnhookWindowsHookEx _ > Lib "user32" (ByVal hHook As Long) As Long > Private Declare Function CallNextHookEx _ > Lib "user32" (ByVal hHook As Long, _ > ByVal nCode As Long, ByVal wParam As Long, _ > lParam As Any) As Long > Private Declare Sub CopyMemory Lib "kernel32" _ > Alias "RtlMoveMemory" (Destination As Any, _ > Source As Any, ByVal Length As Long) > Private Declare Function SetCursorPos Lib "user32" _ > (ByVal X As Long, ByVal Y As Long) As Long > Private Const WH_MOUSE_LL As Long = 14 'low level > Private Const WH_MOUSE As Long = 7 ' app level > Private Const HC_ACTION = 0 > Private Const WM_RBUTTONDOWN As Long = &H204 > Private Const WM_RBUTTONUP As Long = &H205 > Private Const WM_RBUTTONDBLCLK As Long = &H206 > Private Const WM_MOUSEMOVE As Long = &H200 > Private Const WM_LBUTTONDOWN As Long = &H201 > Private Const WM_LBUTTONUP As Long = &H202 > Private Const WM_MBUTTONDOWN As Long = &H207 > Private Const WM_MBUTTONUP As Long = &H208 > Private Const WM_SCROLL As Long = &H20A > Private Type POINTAPI > X As Long > Y As Long > End Type > Private Type MOUSELLHOOKSTRUCT > point As POINTAPI > data As Long > flags As Long > time As Long > extra As Long > End Type > Private mousedata As MOUSELLHOOKSTRUCT > Private oldCoords As POINTAPI > Private Hook As Long > Private xMax As Long, yMax As Long > > Public Sub SetHook() > xMax = (Screen.Width / Screen.TwipsPerPixelX) - 1 > yMax = (Screen.Height / Screen.TwipsPerPixelY) - 1 > Hook = SetWindowsHookEx(WH_MOUSE_LL, _ > AddressOf MouseProc, App.hInstance, 0) > End Sub > > Public Sub ReleaseHook() > UnhookWindowsHookEx Hook > End Sub > > Private Function MouseProc(ByVal nCode As Long, _ > ByVal wParam As Long, ByVal lParam As Long) As Long > Static Initialised As Boolean, temp As Long > Dim diffX As Long, diffY As Long > If (nCode = HC_ACTION) And (wParam = WM_MOUSEMOVE) Then > CopyMemory mousedata, ByVal lParam, Len(mousedata) > If Not Initialised Then > oldCoords.X = mousedata.point.X > oldCoords.Y = mousedata.point.Y > Initialised = True > MouseProc = CallNextHookEx _ > (0, nCode, wParam, ByVal lParam) > End If > diffX = mousedata.point.X - oldCoords.X > diffY = mousedata.point.Y - oldCoords.Y > If diffX = 0 And diffY = 0 Then > ' same coords as previous coords, so this must be > ' the move triggered by our Call to SetCursorPos, > ' in which case we need to allow the system to > ' deal with it > MouseProc = CallNextHookEx _ > (0, nCode, wParam, ByVal lParam) > Else > ' different coords, so this must be a standard mouse > ' movement not triggered by our Call to SetCursorPos, > ' in which case we need to modify the mouse movement > ' in accordance with whatever rules we have set (this > ' specific example reverses the movement in both the > ' x plane and the y plane) abd we then need to tell > ' the system to ignore the unwanted mouse movement > ' that triggered this event. > ' We modify the movement by first setting the mouse > ' to the position we want it to be (using a call to > ' SetCursorPos) and we instruct the system to ignore > ' the "unwanted" mouse movement that triggered this > ' event by setting the return value to True > oldCoords.X = mousedata.point.X - diffX - diffX > oldCoords.Y = mousedata.point.Y - diffY - diffY > If oldCoords.X < 0 Then oldCoords.X = 0 > If oldCoords.X > xMax Then oldCoords.X = xMax > If oldCoords.Y < 0 Then oldCoords.Y = 0 > If oldCoords.Y > yMax Then oldCoords.Y = yMax > SetCursorPos oldCoords.X, oldCoords.Y > MouseProc = True > Exit Function > End If > End If > End Function > ' ***** END OF MODULE CODE ***** > > > > > "mbyerley" <mDotByerley@VerizonDottieNettie> wrote in message Now that's really Cool® . . . I like it ;-)news:haOdnVcxE6Ybif_RnZ2dnUVZ_qqdnZ2d@giganews.com... >> >> "Mike Williams" <M***@WhiskyAndCoke.com> wrote: >> Here, for example, is some VB code I have just written that >> changes the x and y mouse movements for the entire system > > Hey Mike... The lazy way would be to rotate the > mouse 90 deg in your hand.... ;-) Mike On Mon, 9 Aug 2010 07:05:23 -0700 (PDT), Ed from AZ wrote:
> I have a problem that could be solved more easily if my VB6 form with Generally done at the video driver level. AFAIK, it would be much harder to> a text input field and several drop-down controls can be rotated 90 > degrees clockwise. (Monitor is being turned sideways - long story - > exploring solutions.) Is this possible with Classic VB? Not just to > rotate text on the form, but to rotate the entire form so it looks and > functions normally? If so, what commands do I need? > > Ed rotate a single form that it would be to just rotate the entire display. Samsung has a program called MagicRotate. This consists of an EXE, DLL and SYS file. Still it's done at the driver level. -- HK The video driver used to do it, but it broke with the upgrade from XP
SP2 to SP3. Known issue, no fix, so brainstorming for other possible solutions. Older laptop, not worth it to get a new video card. A free 3rd-party driver solution would be nice - a whole lot nicer than trying to rotate this form and deal with all the fallout! That Samsung program looks great and might even be compatible - I'll have to give that a try. Thanks!! Ed On Aug 9, 9:55 am, H-Man <S***@bites.fs> wrote: Show quoteHide quote > On Mon, 9 Aug 2010 07:05:23 -0700 (PDT), Ed from AZ wrote: > > I have a problem that could be solved more easily if my VB6 form with > > a text input field and several drop-down controls can be rotated 90 > > degrees clockwise. (Monitor is being turned sideways - long story - > > exploring solutions.) Is this possible with Classic VB? Not just to > > rotate text on the form, but to rotate the entire form so it looks and > > functions normally? If so, what commands do I need? > > > Ed > > Generally done at the video driver level. AFAIK, it would be much harder to > rotate a single form that it would be to just rotate the entire display. > Samsung has a program called MagicRotate. This consists of an EXE, DLL and > SYS file. Still it's done at the driver level. > > -- > HK "Ed from AZ" <prof_ofw***@yahoo.com> wrote in message I'm not sure what card you have but the above problem (as you appear to news:fedb7345-02f1-43da-ace4-290750f314a0@o7g2000prg.googlegroups.com... > The video driver used to do it, but it broke with the > upgrade from XP SP2 to SP3. Known issue, no fix, > so brainstorming for other possible solutions. Older > laptop, not worth it to get a new video card. already know) is a known issue with some cards, and specifically with ATI cards using Catalyst driver version 8.2: http://support.microsoft.com/kb/947309 On a laptop it is not usually wise to install anything other than the laptop manufacturer's custom modifed drivers so unless the manufacturer of your specific laptop has an updated driver available for download then you might be screwed. It would still be worth trying the orientation utility at the link I provided in my previous response though, because your card obviously still has the capacity to rotate the display and it is just a driver problem. I don't know whether the utility will circumvent your driver to achieve orientation, but it is definitely worth giving it a try. Here is the link again: http://www.softpedia.com/progDownload/iRotate-Download-17093.html You could always ditch SP3 of course and go back to your SP2 setup, unless of course Micro$oft in their infinite wisdom have prevented SP2 systems from obtaining other security updates :-) Mike "Ed from AZ" <prof_ofw***@yahoo.com> wrote in message You don't need to look for ways to rotate Forms or individual controls news:a7ed093e-38d2-49f2-a606-f5621b34cf0c@i19g2000pro.googlegroups.com... > I have a problem that could be solved more easily if my > VB6 form with a text input field and several drop-down > controls can be rotated 90 degrees clockwise. (Monitor > is being turned sideways - long story - exploring solutions.) > Is this possible with Classic VB? Not just to rotate text > on the form, but to rotate the entire form so it looks and > functions normally? If so, what commands do I need? (which would in any case be a complicated task). All you need to do is display your Form and its controls in the standard way but write your VB6 code so that it automatically places your Form's controls at sensible positions on the Form, in response to the Form Resize event, regardless of whether your user has maximized the Form or has dragged it out to some other smaller than maximum size, and regardless of whether that size (in either case) is wider than it is high or vice versa. That's what you should be doing anyway in virtually any VB program that you write. In that way your program will work properly regardless of the user's resizing of your Form or the pixel area or dpi setting or orientation (portrait or landscape) of the user's monitor. As far as rotating your own monitor display is concerned so that it matches the physical orientation of the monitor, most modern graphics cards are capable of performing that task. All laptop graphics cards have this function readily available, and it is usually a case of simply right clicking a blank part of the desktop and selecting the desired rotation from the appropriate dropdown menu. In such cases the orientation of the mouse will automatically set itself to the same orientation as the desktop, and so everything will work just as normal in portrait orientation as it does in the standard landscape orientation. For desktop machines (where you have a computer tower and a separate monitor) the same functionality is usually also available, although the menu option is sometimes not quite as easy to find. For example, on the Vista desktop machine I am using at the moment which uses an ATI Radeon graphics card I need to open the ATI Catalyst Control Center (how I hate those American spellings!) and select Graphics / Desktop Properties / Mode and then select the desired orientation in one of the drop down Lists on that page. On most desktop machines (as far as I recall) choosing a Portrait orientation automatically causes the mouse to orientate itself in that manner as well (in just the same way as it automatically does on laptops), but on this specific desktop machine I am using at the moment (probably a bit of a video or mouse driver fault) is does not do so and the desktop goes into portrait mode whilst the mouse stays in landscape mode (making the machine a bit hard to use, to say the least!). However, I think you'll find most modern desktop machines do not have that problem (at least as far as I recall from memory) and even if they do then it is not an insurmountable problem. By the way, a word of warning if you are using one of those modern "All-In-One" desktop machines that seem to be fashionable these days (those in which the entire computer is built into the monitor). Many of those machines have orientation settings in just the same way as laptops do, but on many of them the act of running it whilst it is physically turned to portrait orientation can cause some of its internal components to fail, probably because of overheating due to the way the air flow is arranged, and so I would not advise you to do it on those machines, at least not without first thoroughly checking the documentation that came with the machine to determine whether you are allowed to run them on their sides. In your case the first thing I would advise you to do is look in detail at the options provided by your graphics card driver's UI software and check out whether it has an orientation setting available. You might need to look at all the menu options in great detail just in case it is buried deep down somewhere. If you still cannot find the appropriate option on your own machine then it might be because your graphics card is quite old and simple cannot perform that task, but it might be just that at does actually have that functionality built into its hardware but that the driver you are using is out of date or perhaps simply does not present the option to the user. If that is the case then you can download some freeware that will examine your graphics card's capability and attempt to provide you with an orientation setting if your card can physically handle it. Here is one example: http://www.softpedia.com/progDownload/iRotate-Download-17093.html If you still have problems then perhaps it might be useful if you posted more details of exactly what you are doing (and, often just as importantly, why you are doing it) and specifically what problems you have come across that are currently preventing you from doing so. Mike
ini in app.pth works for xp, best practice for Vista/W7?
compile error Only udts defined in public object modules can be coerced ... Make a Backup Old VB Project doesn't work with New Office or Windows 7 Class Access Error 32765 Reading keyboard's key names (Internalization) Instantiation Cleanup remnants RegClean Revisited |
|||||||||||||||||||||||