MsgBox displaying old icons. How do I fix this? [duplicate] - vbscript

This question already has answers here:
How can I load the same icon as used by MessageBox on Windows 10?
(2 answers)
Closed 2 years ago.
So I have minimal experience in VBScript. I only need it for a little project I'm doing and I just need a bit of assistance because I can't find this anywhere else. When it creates a MsgBox, the error icons are the ones from Windows 7. Although this doesn't matter that much to me it would be nice of someone knew how to fix this.

That is the icon in user32.dll. VBS Msgbox is a wrapper around the system's MessageBox() function in that dll.
See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
The icon you want is from ComCtl32.dll.

Related

windows file sorting in a directory [duplicate]

This question already has answers here:
Windows 7 Explorer cannot sort files alphabetically
(2 answers)
Closed 6 years ago.
I'm just programming some functions concerning sorting files in a windows directory (windows 7).
While testing I found out, that if you have two files:
a3s.txt
a-s.txt
Windows does NOT put the "a-s.txt" to the first place, although "-" has ASCII code 45 and "3" has ASCII code 51.
This only happens in windows explorer, it does not happen in windows command shell.
Why is this?
Thanks a lot in advance
EDIT:
This is not a duplicate question.
In the other postings they talk about situations, when the file names contain numbers. But here the problem also happens when you have "a_s.txt" and "a-s.txt". Furthermore the problem does not only happen in Windows 7, but also on Windows Server 2003.
This is by design. MSFT uses a custom sorting algorithm in Windows Explorer that they believe is more intuitive for most users. For more information and a brief history, see this TechNet article. The article describes that the custom sorting began with Windows XP, which was the precursor to Server 2003.
"This is not a duplicate question"
The symptoms are different, but the root cause is the same. Windows Explorer does not use lexicographical sorting.

Where canI find AppleScript scriptable references? [duplicate]

This question already has answers here:
Applescript API documentation
(4 answers)
Closed 8 years ago.
I am reading an excellent article http://www.macosxautomation.com/applescript/features/system-prefs.html. The examples are good and easy to understand.
But now I have a question. The article only lists a few 'tell's, where can I find the complete references to those scriptable objects?
In your Applescript editor, you will find in the leftmost menu some reference named "Dictionaries".
Keep in mind that those are present only if the application you want to pilot via applescript is open.
I use Satimage's Smile to develop/debug my applescripts, but the native editor is OK as well.
You'll also receive help reading articles from places like MacScripter, Satimage's site, AppleScript Support COmmunities... and SOF :)

How to create a system restore point? [duplicate]

This question already has answers here:
How to create a system restore point programmatically?
(3 answers)
Closed 2 years ago.
Installing paint.net, I found a string Creating system restore point...
I guess it is creating a restore point for Volume Shadow Service. -Isn't it? I'm not sure.
If I'm right, how do I do this in my app?
Let me know please if there are proper Apis.
You can do this using the System Restore API.
See the documentation for the SRSetRestorePoint function, along with adetailed example.

Decompiler for Visual Basic 6 program? [duplicate]

This question already has answers here:
Is there a Visual Basic 6 decompiler? [closed]
(6 answers)
Closed 3 years ago.
In the FAQ of the Boomerang decompiler (which currently only decompiles to C-code) they make a brief mention that Visual Basic exes happen to include a lot of metadata, so a Visual Basic decompiler might be able to produce better source code for Visual Basic programs than what Boomerang can give you. Since the program I'm trying to decompile might actually be a VB 6 program, do you know of any decompilers for VB6 exes?
(Don't worry this isn't for nefarious purposes. I just have to create a data file this program parses, and getting a sense of the strategy it uses to parse the file will help get the file format right.)
You might want to try VBReFormer
VB Decompiler is another tool. And works fine too!)

Your favorite Visual Basic 6.0 tools and tips [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
This is somewhat related to a similar post, but that post was Visual Studio 6 in general and a lot of the suggestions didn't apply to Visual Basic 6.0.
Suggest or vote for tools/tips. Please one tool/tip per post so that everyone can vote on them individually. Include a brief description of what the tools do.
Enable mouse wheel in VB6:
Microsoft:enable the mouse scroll wheel
MZ Tools.
Free.
Lots of extra tools for the IDE, like "Favorite Procedures" and "Add error routine to prodedure" and lots more.
http://www.mztools.com/v3/mztools3.aspx
After installing VB6, I always do these customisations on Tools-Options.
Switch off Auto Syntax Check on the Editor tab. You don't want message boxes when you type a syntax error - you just want the problem line shown in red so you can fix it later.
Switch on Require Variable Declaration on the Editor tab. Don't think, just do it.
Switch off Compile On Demand on the General tab. You want to be told about syntax errors immediately when you run your code, not just when the dodgy routine actually gets called.
EDIT: Prompt to save changes when program starts, on the Environment tab. (Thanks wqw for reminding me in the comments.)
Set Error Trapping to "Break on unhandled errors" on the General tab. Actually, this is a personal preference - but you should select the setting that suits you. Hopefully you've worked out an error handling strategy for the VB6 program?
I have an LCD screen, and the default colours don't work very well, so I change them to lighter ones. I'm also using the Consolas font. Makes my VB6 code look twenty-first century anyway :)
It's amazing how many people don't use the IDE buttons for commenting-out and uncommenting blocks of source code. They are on the Edit toolbar and look like this: alt text http://img231.imageshack.us/img231/1949/vb6commentbuttons.gif. Right-click in an unoccupied part of the toolbar area and tick the Edit option to display the toolbar.
I once attended an "Advanced VB6" course where the instructor didn't know about those buttons.
EDIT: AngryHacker has a way to associate shortcut keys with these buttons to comment and uncomment code blocks at a keystroke.
I can't believe no one has yet posted Bruce McKinney's Hardcore Visual Basic (now free online on mvps.org)! OK it's a book rather than a piece of software, but it expands to a veritable cornucopia of tools and tips.
SmartIndenter takes care of all the auto-indenting. It does one thing and it does it really well. And it's free.
http://www.oaltd.co.uk/Indenter/Default.htm
SmartIndenter http://img151.imageshack.us/img151/1392/screencaps1.jpg
The vbAccelerator website. It has so many great examples and free controls with the full source. The site has not been updated in a few years now, but it still keeps running and I still go back to it when working in VB6.
I realllly hate checking to see if an array is uninitialized by passing it to a helper function that tries to do a UBound and catches the error if it occurs.
Solution?
Use VarPtr to get the array's address, pass the address to CopyMemory to get the SafeArray structure for the array, if the SafeArray structure indicates 0 dimensions, the array is uninitialized.
EDIT thanks to Lance for good link with example
http://vbnet.mvps.org/index.html?code/helpers/getarraydims.htm
The entire mvps.org site here
I recommend Karl Peterson' One stop source and Randy Birch's VBnet (which has nothing to do with VB.NET) and Common Controls Replacement Project.
Design Patterns by the GoF. While it doesn't seem specific for VB6 the fact that most of the patterns are based interface implementation and aggregating objects (as opposed to inheritance) makes it well suited for use with VB6. They talk about this on pages 16 to 18 and sum it up in one statement. Program to an interface, not an implmentation If there is one thing that VB6 and COM does well is handle interfaces.
Make My Manifest can produce Reg-Free COM manifests (chucking in "Styles" as needed, etc.). This allows XCopy deployment of many VB6 EXEs to WinXP or later.
No more "dependency" fears or DLL Hell!
The VB6 IDE doesn't remember your preference for maximizing the code windows. To start up with the VB6 code windows maximized, set this string registry key:
[HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0]
"MdiMaximized"="1"
Check out http://angryhacker.com/blog/archive/2008/05/01/vb6-swiss-army-knife.aspx
It has most tools I use for whenever I have to delve into VB6, plus a description of what they do. In addition to the tools mentioned here, it also has the following:
PDSA Property Creator
ADO Stored Proc Generator Add-in
Collection Class Master Add-in
Matt Curlands Power VB book and the VBoost tools that came with it, especially the Type library editor.
Just watch out for the non-DEP compliant techniques.
The vbAdvance add-in is now free.
vbAdvance is a Visual Basic Add-In that gives you access to advanced build features and many IDE convenience features. Create console apps, create standard DLLs that export functions, create a DllMain entry point in your DLLs, XP Manifest compiler for XP styles, Terminal Server, etc.
CodeSmart 2009 for VB6
I've not tried this.
http://www.axtools.com/products/cs2k3vb_screenshots.htm
I discovered a lot of things when I was first learning by using the wizards to make forms/small applications, and then examining the code they output.
One great tool that is out there and I've used is called CodeFixer. I believe I first stumbled across CodeFixer here.
It's even open source. I have had a little contact with the author, Roger Gilchrist, and he seems to still be working on it in his, surely limited, free time.
VB6 error handling sucks. So I've adopted these patterns to make it easier:
The Try-Catch block:
'Try
On Error Goto catchX
...
'Catch
catchX: if err.number then
...
resume resumX
resumX: end if
On Error Goto outside_catch_label_name
'End Try
Including a stack trace in errors:
sub rethrow(byval source as string)
Err.Source = Err.Source & vbNewLine & vbTab & "# " & Source
Err.Raise Err.Number, Err.Source, Err.Description
end sub
sub some_sub: on error goto throw
...
throw: if err.number then rethrow("some_sub")
end sub
I haven't tried this myself yet, but CodeShine is a cheap refactoring add-in for VB6. It can do the useful extract method refactoring, apparently.
I must stop wasting time here and download the free trial to try it out.
Aivosto's Project Analyzer http://www.aivosto.com/project/project.html
Spider Eye Flexbag
The collection class replacement from Spider Eye called Spider Eye Flexbag is an absolute must. Its 100% better than the collection classes that ship with VB and its blindingly fast compared to the original collections. The Flexbag collection was written by Gary Wisniewski of "Carl 'n Gary's Visual Basic Home Page" fame.
Unfortunately the Spider Eye website doesn't seem to have a link to the Flex Bag at the moment, but I'm sure if you contact them they'd be happy to sort something out for you. If you are doing any collection based work at all then it would be well worth the effort.
AVE Code Finder
The AVE Code Finder is handy because the Find function in the VB6 IDE can't be trusted. AVE Code Finder is also much much faster then the built in Find. It was written by Jarek Zwierz of www.ave.com.pl but the site doesn't seem to exist anymore so the version I've linked to is at VB2TheMax.
The VB6 Credits Easter Egg that lists the development team :)
To show the VB6 Program Credits create an 'About' button to the standard
toolbar and rename its caption to 'Show VB Credits'. Here's a bit more
detail:
Right-Click on a toolbar and select 'Customize'
Within the 'Commands' tab select the 'Help' category
Drag the 'About Microsoft Visual Basic' command (right windows of dialog
box) up to the end of the standard toolbar.
Without closing the 'Customize' dialog box, Right-Click on the button you
just created and change its Name to 'Show VB Credits'
Close 'Customize' and click the new button.
Bonus points for spotting famous names.
I purchased the Codejock SuitePro for my company. They have many components to be used in VB6 and C++, including the support to XAML in controls, that is a lightweight version of the WPF.

Resources