LostFocus() event not triggered after application installation - installation

I have simple code in the LostFocus event of a textbox control
that changes the text to upper case:
Private Sub txtIntegration_LostFocus()
If Trim(txtIntegration.Text) <> "" Then
txtIntegration.Text = UCase(Trim(txtIntegration.Text))
End If
End Sub
When the application is installed, the code to uppercase the text does not work in.
I'm creating the installer with the "Package and Deployment Wizard" of Visual Basic 6.

As a troubleshooting step and potential solution for what you are trying to achieve, you can force the text to uppercase as it is being typed:
Private Sub txtIntegration_Change()
Dim iPosition As Integer
With txtIntegration
iPosition = .SelStart ' Save cursor position
.Text = UCase$(.Text)
.SelStart = iPosition ' Restore cursor position
End With
End Sub
You can at least try this approach and see if it works once installed. There should be no reason the installation process breaks any of your code.

The solution was, when you add or remove the program, the removal program does not uninstall the .EXE completely
Simply delete the Directory and solve it!

Related

VB6 - User control/ActiveX control - how to get parent dimensions

I'm writing a vb6 user control (for my sins) and all has gone well up until now. I'm struggling to get the height and width of the parent/container.
The User-control is exported as an activeX control (.ocx), registered on the target machine using Regsvr32 and then embedded into an existing app.
I don't have access to the existing apps code so I can't inject anything that way.
I've tried accessing the UserControl.Parent object but receiving errors.
Does anyone know how to do this or can set me down the right path. My main language is c# so be kind to me please.
Most likely you are trying to fiddle with Parent before the control has been sited. Doing this instead works just fine:
Option Explicit
Public Sub Update()
'Call from parent container's Resize event handler, etc.
Cls
With Parent
Print .ScaleWidth; " × "; .ScaleHeight
Print .Width; " × "; .Height
End With
End Sub
Private Sub UserControl_Initialize()
AutoRedraw = True 'We're using Print here.
End Sub
Private Sub UserControl_InitProperties()
Update
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Update
End Sub

Powerpoint VBA App_SlideShowBegin

In order to use the SlideShowBegin event in Powerpoint, you have to have a Class Module configured the following way:
Public WithEvents App As Application
Private Sub App_SlideShowBegin(ByVal Wn As SlideShowWindow)
MsgBox "SlideShowBegin"
End Sub
Then, inside of a non-class module, you have to create an object of that type and set the App to Application.
Dim X As New Class1
Sub InitializeApp()
Set X.App = Application
End Sub
Now, the only issue I have is, if you don't manually called InitializeApp with the Macro Menu in Powerpoint, the events don't work. You have to call this sub before anything can called at the beginning of a slideshow INCLUDING this sub.
How can I go about calling this sub before running my powerpoint? Is there a better way to do this?
EDIT:
I've tried using Class_Initialize but it only gets called once it is first used or you make a statement like Dim X as Class1; X = new Class1
Usually event handlers are installed as part of an add-in, where you'd initialize the class in the Auto_Open subroutine, which always runs when the add-in loads. If you want to include an event handler in a single presentation, one way to cause it to init is to include a shape that, when moused over or clicked fires a macro, which inits your event handler and goes to the next slide.
Answering to an old question, but I hope my solution might helpt somebody ending up at this question.
The general advice for this issue is using a plug-in or placing some element on the slide and when that is clicked or hovered perform the initialization. Both are not always desired so I have the following approach:
In some module:
Dim slideShowRunning As Boolean
-----------------------------
Sub SlideShowBegin(ByVal Wn As SlideShowWindow)
' Your code for start-up
End Sub
-----------------------------
Public Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
If TypeName(slideShowRunning) = "Empty" Or slideShowRunning = False Then
slideShowRunning = True
SlideShowBegin Wn
End If
End Sub
----------------------------
Public Sub OnSlideShowTerminate(ByVal Wn As SlideShowWindow)
slideShowRunning = False
End Sub
For me this works perfectly. NOTE I am by no means a vba expert, actually I might have less than 50 hours of vba programming (maybe only 8 in powerpoint). So this might be an horrible solution. I don't know, but for me it works so I liked to share.
In fact, OnSlideShowPageChange runs when slideshow begins. Just make sure it doesn't work in the subsequent page changes if not needed using a global variable. See answer from C. Binair for details.

Combobox from Visual Studio Macros

When you need to debug a Website that hosts on IIS Express, you usually don't restart it all over again, every time when you need to rebuilt your code. You just attach VS to the process. And the macros script helps a lot:
Public Module AttachToProcess
Public Sub AttachToWebServer()
Dim attached As Boolean = False
Dim proc As EnvDTE.Process
For Each proc In DTE.Debugger.LocalProcesses
If (Right(proc.Name, 14) = "iisexpress.exe") Then
proc.Attach()
attached = True
Exit For
End If
Next
If attached = False Then
MsgBox("iisexpress.exe is not running")
End If
End Sub
End Module
You can assign a keystroke and voila. The only problem is if your solution contains more than one webapp, there would be more than one iisexpress.exe processes with different PIDs, and VS would sometimes choose the wrong one.
The question: Is it possible to popup a dialog if there is more than one iisexpress.exe running to choose the right one?
Of course you can always use default 'Attach To Proccess' dialog, but it's not gonna be as quick as using that script and keyboard shortcut.
You can open a dialog, but it's not the most straightforward thing. You will need to put all your UI code into the macro, EG layout, size of controls, etc...
It's about 200ish lines of code, and rather than put it all here I will defer you to my blog at http://www.brianschmitt.com/2010/09/save-and-change-tool-layout-in-visual.html
You should be able to reuse the View Switcher dialog box and list out all instances of IISExpress. It shouldn't take much to do what you need it to.

Is there some way to collapse folders recursively in the Visual Web Developer 2010 Express Solution Explorer?

This is something I want to do quite often, as I end up with hundreds of source files visible in Solution Explorer and things can get quite confusing.
I have found several extensions which will do this in Visual Studio, but as Visual Web Developer 2010 Express doesn't support extensions I'm looking for an alternative solution.
Any suggestions gratefully received!
Edit: In case it wasn't clear from the question title, I want to collapse folders recursively, not just hide the expanded sub-tree and have it show in the same state when I open the parent folder again.
If you double click on a folder, that folder gets collapsed, but not the folders inside the one you clicked. I think, you may not need as you do not get to see those folders inside the one you clicked as they are hidden inside the collapsed folder.
does this macro help?
http://kylefinley.net/archive/2006/02/02/37.aspx
Imports EnvDTE
Imports System.Diagnostics
Public Module Personal
Sub CollapseAll()
'DESCRIPTION: Collapse all the nodes in the project tree
' Get the the Solution Explorer tree
Dim oSolutionExplorer As UIHierarchy
oSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (oSolutionExplorer.UIHierarchyItems.Count = 0) Then
Return
End If
' Get the top node (the name of the solution)
Dim oRootItem As UIHierarchyItem
oRootItem = oSolutionExplorer.UIHierarchyItems.Item(1)
Dim oChildItem As UIHierarchyItem
' Collapse each project node
For Each oChildItem In oRootItem.UIHierarchyItems
CollapseMe(oChildItem, oSolutionExplorer)
Next
' Select the solution node, or else when you click on the solution window
' scrollbar, it will synchronize the open document with the tree and pop
' out the corresponding node which is probably not what you want.
oRootItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub
Sub CollapseMe(ByVal oRootItem As UIHierarchyItem, ByVal oSolutionExplorer As UIHierarchy)
Dim oChildItem As UIHierarchyItem
For Each oChildItem In oRootItem.UIHierarchyItems
CollapseMe(oChildItem, oSolutionExplorer)
Next
oRootItem.UIHierarchyItems.Expanded = False
' Added to deal with the Visual Studio bug
If (oRootItem.UIHierarchyItems.Expanded = True) Then
oRootItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
oSolutionExplorer.DoDefaultAction()
End If
End Sub
End Module
Ok, after five months I'm assuming there just isn't a way to do this. Marking as answered.

How do I make Visual Studio automatically go to the first error in a build?

This is done manually by going to the "Error List" output window and double-clicking on the first error or pressing F8. Is there a way to automate this?
(I'm using C++ if that matters.)
vittore is on track...
In VS press Alt+F11 to open the Macros IDE. Under 'MyMacros' open 'EnvironmentEvents' module and below these three lines
'Event Sources End
'End of automatically generated code
#End Region
paste this Sub:
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean)Handles BuildEvents.OnBuildProjConfigDone
If Success = False Then
DTE.ExecuteCommand("Build.Cancel")
Beep()
System.Windows.Forms.MessageBox.Show("Build failed!", "Build Events", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
DTE.ExecuteCommand("Edit.GoToNextLocation")
End If
End Sub
Obviously, you can comment out or delete the Beep and the message box...
Adding to the previous answer:
I suggest View.NextError command instead of Edit.GoToNextLocation. Do not get confused by its group (View), it actually GOes TO error location in the editor, like if you double-click error item in the error list.
You can also map it to the keyboard this way:
Ctrl+Shift+PgUp = View.GoToPreviousError
Ctrl+Shift+PgDn = View.GoToNextError
This will allow you to check for errors (and move between them in editor) even without need of displaying the error window and even without running the build.

Resources