Results 1 to 32 of 32

Thread: VB6 usercontrol takes away focus from NET usercontrol

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Question VB6 usercontrol takes away focus from NET usercontrol

    Hi all,

    I have a form with a VB6 usercontrol, a .NET usercontrol (made using WPF), a textbox (say "Resetter") and a button.
    VB6 usercontrol has 3 text boxes. .NET usercontrol has one textbox and a label.
    For test purposes both usercontrols have no background logic, just GUI elements.

    In following scenario VB6 usercontrol steals focus from .NET usercontrol when using arrow buttons:
    • Click the middle textbox of VB6 usercontrol
    • Click textbox in .NET usercontrol
    • Try to move the cursor with arrow buttons - the focus jumps back to the VB6 usercontrol


    If I change the scenario a bit - the focus doesn't change:
    • Click the middle textbox of VB6 usercontrol
    • Click the "Resetter" textbox (or button)
    • Click textbox in .NET usercontrol
    • Try to move the cursor with arrow buttons - no focus changes occur, cursor is moved normally


    The question is - how can I avoid those focus changes?
    Attached Files Attached Files
    Last edited by firelex; Dec 3rd, 2021 at 04:29 AM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Welcome to the forums...and as a welcome gift, I removed your attachment.

    We don't allow compiled code to be included in attachments, because we've had trouble with that in the past. Most of what you attached looked good, but you included the compiled exe, which is not allowed. Please strip that out and re attach.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Hi Shaggy Hiker,

    I've removed exe from the attachment. Dll-file is still there - should I remove it as well?

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    Hi Shaggy Hiker,

    I've removed exe from the attachment. Dll-file is still there - should I remove it as well?
    Yes. Any and all compiled binaries should be removed. We can't see what's in compiled binaries, and we've been bitten by that before, so the policy is that you either only post the relevant code in the post (preferred option) or if you post the project, you first delete all binary files before zipping it up and attaching it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    Hi all,

    I have a form with a VB6 usercontrol, a .NET usercontrol (made using WPF), a textbox (say "Resetter") and a button.
    VB6 usercontrol has 3 text boxes. .NET usercontrol has one textbox and a label.
    For test purposes both usercontrols have no background logic, just GUI elements.

    In following scenario VB6 usercontrol steals focus from .NET usercontrol when using arrow buttons:
    • Click the middle textbox of VB6 usercontrol
    • Click textbox in .NET usercontrol
    • Try to move the cursor with arrow buttons - the focus jumps back to the VB6 usercontrol


    If I change the scenario a bit - the focus doesn't change:
    • Click the middle textbox of VB6 usercontrol
    • Click the "Resetter" textbox (or button)
    • Click textbox in .NET usercontrol
    • Try to move the cursor with arrow buttons - no focus changes occur, cursor is moved normally


    The question is - how can I avoid those focus changes?
    It seems this cannot be avoided. I tried a whole bunch of different things to try to eliminate the behavior but everything failed. It seems there is some incompatibility deep in the guts of VB6 and WPF that causes them to not play well together like this.

    I would suggest that if you want to utilize WPF, the entire Form should be a WPF Form. I'd avoid mixing WPF UI elements with VB6 controls on the same Form.

    I'll poke and prod at it in the meantime to see if I can figure it out but don't pin your hopes on this. It's very unlikely I will be able to figure out how to eliminate this behavior.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    The question is - how can I avoid those focus changes?
    IMO the easiest way would be, to just use a COM-Control, which does the same thing as the .NET-one.

    What is it (speciality-wise), the WPF-based control does?

    Olaf

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Schmidt View Post
    What is it (speciality-wise), the WPF-based control does?
    The similarities between VB6/Win32 controls and WPF controls are only skin deep. Beneath the surface, they are completely different. WPF is designed in such a way that you can go wild with customizations without any special knowledge. Like you could have the drop-down of a ComboBox use a DataGrid where each row cell of the DataGrid has a calendar control next to a ListBox stacked on top of a video player. Like you could just just do all kinds of crazy customizations in WPF at will without all the Win32 wizardry you'd need in VB6, C or WinForms that very few people have the knowledge or time to do.

    EDIT:

    Oh and WPF's rendering engine is powered by DirectX so it can be very fast.
    Last edited by Niya; Dec 4th, 2021 at 12:26 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #8
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Niya View Post
    The similarities between VB6/Win32 controls and WPF controls are only skin deep.
    I didn't ask for an explanation how WPF works.

    My question was related to my recommendation, to use a true COM-control (instead of a .NET one).
    (e.g. why not use a VB6-TextBox on a VB6-implemented UserControl to avoid all those focusing-problems)?

    Seems there is something to this "WPF-based control", which the OP thinks is "difficult to find" in the VB6-world.
    I just wanted to know, what this "special something" is...

    Olaf

  9. #9
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Schmidt View Post
    Seems there is something to this "WPF-based control", which the OP thinks is "difficult to find" in the VB6-world.
    I just wanted to know, what this "special something" is...
    I'm trying to say that OP probably wants the easy customization that WPF offers. I could be completely wrong but this is the only reason I'd ever consider mixing WPF and VB6.

    For example if I wanted to spice up a VB6 application with some fancy UI tricks like this, you really think in 2021 I'm going to bother with sub-classing writing a bunch of GDI/User32 code? I'd just write the damn thing in WPF, import it in VB6 and be done with it.

    Of course that's just me. Hopefully OP comes back and can answer your question so you can then provide a pure VB6 solution if possible.
    Last edited by Niya; Dec 4th, 2021 at 12:50 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  10. #10
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    I would also like to point out that I'm sure you're far more knowledgeable than me on the inner workings of Win32/VB6 controls so you could probably solve this focusing problem in in like 2 minutes, which gives the OP exactly what he asked for.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  11. #11
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Niya View Post
    For example if I wanted to spice up a VB6 application with some fancy UI tricks like this,
    you really think in 2021 I'm going to bother with sub-classing writing a bunch of GDI/User32 code?
    There's enough ready-made Virtual (ownerdrawn) Controls in the VB6-Codebank,
    which make stuff like that equally easy.
    e.g. here: https://www.vbforums.com/showthread....x-(OwnerDrawn)

    And FTR, my question was meant for the OP - let's see what he has to say about this.

    Olaf

  12. #12
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Niya View Post
    I would also like to point out that I'm sure you're far more knowledgeable than me on the inner workings of Win32/VB6 controls so you could probably solve this focusing problem in in like 2 minutes, which gives the OP exactly what he asked for.
    I'm not going to do that, because it would be "bad advice" IMO.

    Dragging .NET-stuff into a working VB6-App isn't a good idea at all (as the current problems show)...
    In addition, it just opens a lot of potential deployment-problems "down the line", one has to take into account.

    A little less risky is the opposite direction (using VB6-COM-Components within a .NET-app).
    Though one has to be aware, that this limits the .NET-app to 32Bit then.

    Olaf

  13. #13
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Schmidt View Post
    There's enough ready-made Virtual (ownerdrawn) Controls in the VB6-Codebank,
    which make stuff like that equally easy.
    e.g. here: https://www.vbforums.com/showthread....x-(OwnerDrawn)
    Yea, that's pretty cool but that example seems to be particularly about the ComboBox. In WPF you could do any level of customization with any Control. Like you could have buttons with calendars on them or menu items with media player controls on the left and a ComboBox on the right. Like you could go absolutely nuts in WPF with the kinds of insane things you could do. You just imagine any crazy combination UI elements and WPF could probably do it fairly easily.

    Quote Originally Posted by Schmidt View Post
    And FTR, my question was meant for the OP - let's see what he has to say about this.
    Agreed.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  14. #14
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Schmidt View Post
    I'm not going to do that, because it would be "bad advice" IMO.
    Well, this depends on what the OP wants. We'll find out if he ever comes back.

    Quote Originally Posted by Schmidt View Post
    Dragging .NET-stuff into a working VB6-App isn't a good idea at all (as the current problems show)...
    Hmmmmm. Not really. I mean you're not wrong in that there could be problems. However, it's not as bad as you'd expect especially if you avoid UI related stuff. .Net objects tend to work extremely well in VB6 applications most of the time.

    Quote Originally Posted by Schmidt View Post
    In addition, it just opens a lot of potential deployment-problems "down the line", one has to take into account.
    Actually it doesn't add anything in the way of deployment problems. You have to register .Net COM interop components just as you would have to do with any other COM component. The only real difference is that you have to use RegAsm instead of RegSvr32. The only other problem that could come up is not having the right version of the .Net Framework on the target machine. However, if you know beforehand which versions of Windows you want to target, you can just compile it against the relevant Framework and that problem goes away since all recent versions of Windows come with some version of the .Net Framework already installed.

    Quote Originally Posted by Schmidt View Post
    A little less risky is the opposite direction (using VB6-COM-Components within a .NET-app).
    I agree here since the same version of the VB6 runtime is on practically every Windows installation in the wild. You never have to worry about if it's going to be there or version conflicts. One of the few benefits of Microsoft abandoning VB6. It's very stable.

    Quote Originally Posted by Schmidt View Post
    Though one has to be aware, that this limits the .NET-app to 32Bit then.
    I personally think 64 bit compilation is bit overrated.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  15. #15

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Holy pentium!

    Didn't thought my question would cause such a discussion.

    First of all: usage of NET elements is caused by the evolution of the programm. Originally written in VB5, it was maintained all time long - in terms of VB6. And now because clients complain "GUI isn't sexy enough" it will be step by step transferred into NET.

    Main technique so far is usage of elements capsuled in register-free dlls. It was OK until now because elements were not mixed on one VB-form. Mainly it were new featues, which were completely implemented using WPF. So it was enough to make window border invisible and embed it into VB-form using SetParent.

    Now older forms should be transferred. Due to the complexity it would take much time to replace the whole VB6-form at once. So the idea was to replace only GUI elements and leave VB6 as back-end. Now we've got to the original problem with focus switching back to VB6-controls.

    In the meantime we have got out that using VB6-forms and WPF-forms parallelly leads to the same problem.
    Namely when using a floating WPF-window in a MDI V6 application arrow and TAB keys also make focus get back to the VB6 application.
    Of course only if in VB6 application is currently a form visible with a VB6-usercontrol on it.

  16. #16
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Well I guess we have to solve this focus problem then. My investigation so far has revealed that focus events aren't even being raised when the change of focus happens so something weird is definitely going on underneath the hood. I'll do a little more poking and prodding to see what I come up with. There is probably some simple solution.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  17. #17
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    ...clients complain "GUI isn't sexy enough"
    Can only repeat my advice... stay in VB6 if you want to make it "more sexy".
    There is tons and tons of nice, unicode-capable VB6-controls in the VB6-CodeBank.

    Easiest (as in "cheapest") thing to do in that regard is, to include a Manifest in your compiled executable,
    to make the system render the Common Controls in the current (modern) styles.

    Olaf

  18. #18
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Schmidt View Post
    There is tons and tons of nice, unicode-capable VB6-controls in the VB6-CodeBank.
    I'm curious about this.

    @firelex.

    Why didn't you guys choose this route? Why did you choose to combine WPF with VB6? I mean I could think of reasons why I would have gone this way but I wonder what your reasons were. Is it because you intend to eventually migrate the entire application to .Net?

    My personal opinion is that it should be migrated to .Net ASAP but this is a huge commitment if the application is large. Not many people can commit to something like this and in such cases it's just easier to maintain it in VB6.
    Last edited by Niya; Dec 6th, 2021 at 07:06 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  19. #19

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Schmidt View Post
    Easiest (as in "cheapest") thing to do in that regard is, to include a Manifest in your compiled executable,
    to make the system render the Common Controls in the current (modern) styles.
    Yes, it was the first thing we've tried. It is really simple and makes VB6 application look in modern style.
    It could have worked, but as soon as the head of client's IT department sees "VB6" as basic application language - your app is immediately classified as "old-fashioned" (and not future proof), what brings negative mood no matter how good the application is (and no matter that Microsoft adds VB6 support in every new Windows version).
    It is very annoying, but seen at quite a few potential customers.

  20. #20
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Wait. Are you saying your clients actually care that the application is written in VB6? This is quite surprising to me. I've never heard a client of ours complain about the language our solutions were created using.

    EDIT:

    Oh I just realize you said that it's their IT department that's giving you the headaches. Well in this case, moving to .Net is the best option. You aren't going to convince IT people in 2021 that VB6 is any good. Outside of this forum, most programmers and other IT specialists think it's trash and no real argument exists to convince them otherwise.
    Last edited by Niya; Dec 6th, 2021 at 07:44 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  21. #21

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Niya View Post
    Outside of this forum, most programmers and other IT specialists think it's trash and no real argument exists to convince them otherwise.
    It is true and it is very sad. VB6 is a wonderful and powerful programming language and I think it is undeserved to downgrade it with such clichees.

    But maintaining an app, which is in a "soft changeover" has it's good sides: that annoying IT'er has his bone and doesn't seek much more. Others see "using modern and future proof .NET technology" and are also satisfied. And we are happy having a solid base.

  22. #22
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    ...as soon as the head of client's IT department sees "VB6" as basic application language -
    your app is immediately classified as "old-fashioned"...
    At the place where I work, we maintain a huge VB6-App
    (which certainly looks modern, after an overhaul we did 5 years ago).

    It has about 170MB of regfree deployed COMponents (in about 200 Dlls and OCXes in a Bin-SubFolder).

    With new customers, one doesn't have to mention VB6 directly (unless "directly and specifically asked").

    E.g. one can explain, that MS-COM-technology is used, to be able to interact more directly with MS-Office-Apps
    ("thankful nod" at the customer-side, which in our case, without exception all run MS-Office-Apps so far)...
    And one could also mention *beforehand*, that ones own COM-binaries are produced with a 32Bit-C++-compiler
    (which is true - and often enough "avoids" the question about the implementation-language).

    When questions about 64Bit-binaries (or direct questions about the impl. language) *are* asked,
    you have to be truthful of course - but we accompany that, by mentioning our "awareness" -
    and demonstrate the latest results of our Web-migration-efforts (as well as all the "side-bindings",
    our Desktop-App offers when interacting with a given Customers WebSite, for "Online-Orders" and stuff).

    This "Web-Shifting" started "slowly" (about 4 years ago), but gained speed over the years -
    and we are now roughly at 40-50% of the functionality of the "big Desktop-Monster-App".
    A few customers who don't need "everything and the kitchen-sink", already use that "light-version" of our App.

    We found, that any "mixing" or "migrating" (Desktop-to-Desktop) -
    takes roughly the same amount of time and efforts as a "full Web-Port".

    Maybe that story helps with your own decisions...
    (you might also keep in mind, that many "C#-Shops" are considering "going full Web" as well,
    "leaving the big Desktop-solutions behind")

    Olaf

  23. #23
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    It is true and it is very sad. VB6 is a wonderful and powerful programming language and I think it is undeserved to downgrade it with such clichees.

    But maintaining an app, which is in a "soft changeover" has it's good sides: that annoying IT'er has his bone and doesn't seek much more. Others see "using modern and future proof .NET technology" and are also satisfied. And we are happy having a solid base.
    I'm just going to be honest. I think the best idea is to aim towards an eventual complete port of the application to .Net. It makes no sense exhausting yourself by fighting to keep it in VB6. VB6 isn't really that bad of a development environment but lets face reality, it's 20+ years old and unsupported by Microsoft while .Net is continuously being updated and has a massive community behind it providing support. These IT heads giving you a hard time about VB6 know this. Most people don't have time or the will to wrangle with the issues that come with dealing with outdated tech. I think integrating .Net into your VB6 application is a good first step but it should be fully ported eventually.

    Also, Olaf touched on something very important, the move to web applications. This is also something that is also becoming the new norm and in this case you definitely do not want to find yourself in VB6.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  24. #24
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: VB6 usercontrol takes away focus from NET usercontrol

    As an independent observer to this thread IMO best would be to move away both from VB6 and .Net towards more web friendly tech stack incl. web-based desktop technologies like Electron and many other emerging WebView2-based ones (for Windows at least).

    cheers,
    </wqw>

  25. #25
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by wqweto View Post
    As an independent observer to this thread IMO best would be to move away both from VB6 and .Net towards more web friendly tech stack incl. web-based desktop technologies like Electron and many other emerging WebView2-based ones (for Windows at least).

    cheers,
    </wqw>
    This is also a very good idea as far as web application development goes. However, Microsoft is pushing .Net in this direction also. Stacks like Electron are more mature but I'm willing to bet that in a few short years that technologies like Blazor Hybrid will become very competent in their own right.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  26. #26
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    Yes, it was the first thing we've tried. It is really simple and makes VB6 application look in modern style.
    It could have worked, but as soon as the head of client's IT department sees "VB6" as basic application language - your app is immediately classified as "old-fashioned" (and not future proof), what brings negative mood no matter how good the application is (and no matter that Microsoft adds VB6 support in every new Windows version).
    It is very annoying, but seen at quite a few potential customers.
    Quote Originally Posted by Niya View Post
    Wait. Are you saying your clients actually care that the application is written in VB6? This is quite surprising to me. I've never heard a client of ours complain about the language our solutions were created using.

    EDIT:

    Oh I just realize you said that it's their IT department that's giving you the headaches. Well in this case, moving to .Net is the best option. You aren't going to convince IT people in 2021 that VB6 is any good. Outside of this forum, most programmers and other IT specialists think it's trash and no real argument exists to convince them otherwise.

    Yep... some IT departments care about such things. After you sell them the system, they have to maintain it... and often, they're not going to want to tinker with aging technology. Circa 2008 we lost out on a $3M deal because our app was still in VB6 at the time, and we didn't have plans yet to migrate to .NET.... and that was in 2008! VB6 hadn't even gotten to the rigor mortis stage yet!
    So, yes, some places do care what platform their stuff is built on. When you spend a couple million on something, you want to have confidence that it's going to work for a while. And if you see something that's built on VB6, you don't know if it's going to die tomorrow. There's also the issue of knowledge attrition. The amount of VB6 developers is dropping. Some to retirement, some due to frustration, some due to career change. It's easier to find a .NET developer to make changes than it is to find a VB6 developer. And when you do, you have to worry about that proverbial beer truck. O.O


    Quote Originally Posted by firelex View Post
    It is true and it is very sad. VB6 is a wonderful and powerful programming language and I think it is undeserved to downgrade it with such clichees.

    But maintaining an app, which is in a "soft changeover" has it's good sides: that annoying IT'er has his bone and doesn't seek much more. Others see "using modern and future proof .NET technology" and are also satisfied. And we are happy having a solid base.
    It may also be about knowledge... we get older and we cling to our older tech, younger people are moving in and taking over... they have to maintain this stuff. When I started out, I didn't want to have to maintain COBOL app written '64 any more than someone starting out today wants to maintain a VB6 app written in '2000.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  27. #27
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by techgnome View Post
    And when you do, you have to worry about that proverbial beer truck. O.O

    -tg
    I would have said "bread truck", but when you get right down to it, beer trucks are dangerous in TWO ways. Very few people EAT themselves into a stupor.
    My usual boring signature: Nothing

  28. #28
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    @firelex

    Ok I've found some possible workarounds.

    It seems that siting the WPF UserControl on a VB6 Frame is one of the causes. The Frame object swallows up certain key strokes like the arrow keys. Site the WPF UserControl directly on the VB6 Form or in a PictureBox. Also, if there is a VB6 UserControl on the same Form that contains focusable controls and one of those controls get focus at any point, then from that point forward any arrow key press will change the focus. However, if the controls within the VB6 UserControl are sited directly on the VB6 Form, everything works correctly.

    One more thing, I really didn't like how the WPF controls were exported so I made some changes there. I wanna investigate a little more before I post any code.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  29. #29

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Thanks for your suggestions Niya, but unfortunately moving WPF UserControl directly to the VB6 Form or PictureBox didn't do the trick.

    However, if the controls within the VB6 UserControl are sited directly on the VB6 Form, everything works correctly.
    What do you mean? Siting controls within the VB6 UserControl directly on the VB6 UserControl - and not on the Frame within VB6 UserControl?

  30. #30
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by firelex View Post
    What do you mean? Siting controls within the VB6 UserControl directly on the VB6 UserControl - and not on the Frame within VB6 UserControl?
    I mean instead of siting on a UserControl, you site it on the Form itself.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  31. #31

    Thread Starter
    New Member
    Join Date
    Nov 2021
    Posts
    7

    Re: VB6 usercontrol takes away focus from NET usercontrol

    Quote Originally Posted by Niya View Post
    I mean instead of siting on a UserControl, you site it on the Form itself.
    You mean - not to use VB6 UserControls in such situations? It is a complicated way, but it would do.

    I think I've found solution for this problem. We are testing it now but it seems to be promicing so far.
    I've found an old post on Microsoft Helpdesk forum. An expert said, that using combination "WPF + VB6" will always bring such problems thus techniques of keyboard event handling is too different. However combination "WinForms + VB6" won't because of similiarity of the techniques used.

    So the idea is to use WPF for .NET-UserControl creation, but wrap it in a WinForms form.

  32. #32
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 usercontrol takes away focus from NET usercontrol

    I almost suggested something like that but I felt it was too complicated and you may not have wanted such a convoluted solution that involved WinForms, WPF and VB6.

    But yea, I pretty much reached the same conclusion about VB6 and WPF being incompatible. I've tried all manner tricks and nothing really worked 100%. I'd get close but never quite properly working.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width