Error Creating Window Handle

Brain-BulbIt starts with “Can not create Window Handle”… and continuous random crashes. You find out your app reaches the max of 10000 user objects. (Just check the task manager, you’ll see I’m right.)

So, you’ve been using your own usercontrols on a flowlayoutpanel; you add, you remove, you clear… however the user objects count keeps growing and something is leaking somewhere…

You find that .controls.clear() does not work, you have to dispose() of all the objects first. Okay, do that, but it still doesn’t work.
So what’s the trick?
Simply remove first, before the dispose, and do this one at a time.

Just use the following routine:
instead of

Public Sub ClearFlowLayoutPanel(cFlowLayoutPanel As FlowLayoutPanel)
 Do While (cFlowLayoutPanel.Controls.Count > 0)
  Using controltoremove = cFlowLayoutPanel.Controls(0)
  End Using
End Sub

Good Luck! …or ask My Brain.

sources or more info:


Display all PHP Errors and Warnings

ctrl-ZVXWhen debugging PHP I find myself searching again and again for this little piece of code to display the PHP errors. So here it is for future reference…
If you wish to see all the PHP errors and warnings in your script, simply include the following bit of code:

ini_set(‘display_errors’, ‘1’);

Now, continue to beat your head against the keyboard while you hunt down that missing semicolon or closing parenthesis. Need help, contact My Brain.

VB.Net create mdb with a password

f_3dh_partyWhen developing an application with visual basic, you may want to store data. So you create a database during runtime, for example with the following piece of code, as many websites show on various forums:

Dim strMDBPath As String = "C:\SomePath\MyTestDB.mdb"
Dim cat As New ADOX.Catalog()
 cat.Create(Convert.ToString("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=") & strMDBPath)
 cat = Nothing

Next you wish to protect your data, so only your application can open the database. You google again, and find the following solution:

Dim cn As OleDbConnection = New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strMDBPath & ";Mode=Share Deny Read|Share Deny Write;"
Dim cmdpw As OleDbCommand = New OleDbCommand
cmdpw.Connection = cn

Unfortunately, now you are stuck with an error you can not solve:
You attempted to open a database that is already opened by user ‘Admin’ on machine ‘YOURPCNAME’. Try again when the database is available.
Creating the database seems to keep the connection open and you cannot close it to execute the password change on an exclusive connection.

The answer and solution is simple: Set the password in the connection string in the first piece of code when creating the database! The attempt to ALTER DATABASE PASSWORD is no longer needed and you can forget about that…

Dim strMDBPath As String = "C:\SomePath\MyTestDB.mdb"
Dim cat As New ADOX.Catalog()
cat.Create(Convert.ToString("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=MYNEWPASSWORD;Data Source=") & strMDBPath)
cat = Nothing

Enjoy this free advice from My Brain!

Phonegap Build changes

dislikeNice. The ever-developing world of IT… or, “how to create more work for each other”.

My Brain develops Apps using a framework called Phonegap. Quick development, easy coding, simple configuration. Until you need to update an exisiting app and you are suddenly faced with the changes that were implemented since the last build…
This time the App did not want to access the Internet anymore… at all! So, Google to the rescue, finding this document with some good clues. I needed #10, which starts out perfectly phrased: “This is sooo new and obnoxious, one can only have pitty on returning developers.” …

Being a developer you have to love puzzles!

Continue reading Phonegap Build changes

PHP (un)serialize and

SBrain-Bulberialization is changing any object, array or variable into a simple string, so it can be easily transfered over a network or stored into a database. Plus the change back into the original of course. There are many options available, and your best choice is using XML or JSON.

However, if you happen to have a PHP object serialized with the php function… you have a problem when you receive this serialized string from a web request and need to process the data and use the object in a windows visual basic .net application.

So what does My Brain do?
First search for a class or other code sample to do this. But when none is available? Simply write code and start developing my own solution.

Need something like this? Contact My Brain.

App Approvals…

dislikeI would like to have an App. Sure. Development time depends on the complexity of the App, could be weeks, could be months. And after going over several versions and improvements, it’s finally time to submit the final App to the various App Stores.

“So that’s it? Good, so my App will be live tomorrow. What? Not tomorrow… So how long does it take? Really?”

Yes, check it yourself… this is the time Apple takes from the moment of submitting, to when the App is live in the App Store. See:


Google Play and Windows Phone Store usually take a day for approval.
But all these periods are of course excluding the extra time/rounds it takes when the App gets denied at first. Could be incorrect screenshots, bad App descriptions, the App functionality, anything!
Apple, Google and Microsoft all made up their own rules for approving Apps. My Flappy Cows App for example is still not live on Windows Phone, because “it doesn’t offer any additional or unique functionality”… Thank you, Microsoft. Your loss, you’re missing out on my freakin’ cute cow game.

Self-Elevating App

Say What?aaaaaaa

Yes: My Brain wrote a Self-Elevating App.

I have been writing a Windows Application (32-bit x86 executable) in Visual Studio 2010, that uses the HKEY_LOCAL_MACHINE/Software/AppName registry key to save some basic settings. After some strange accesss errors I figured out that you need administrative access to actually be able to do this. Continue reading Self-Elevating App